| Index: third_party/pkg/angular/test/directive/ng_a_spec.dart
|
| diff --git a/third_party/pkg/angular/test/directive/ng_a_spec.dart b/third_party/pkg/angular/test/directive/ng_a_spec.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..082da14484aee9ae9587aa835d5b149d59f5ca4e
|
| --- /dev/null
|
| +++ b/third_party/pkg/angular/test/directive/ng_a_spec.dart
|
| @@ -0,0 +1,44 @@
|
| +library ng_a_spec;
|
| +
|
| +import '../_specs.dart';
|
| +import 'dart:html' as dom;
|
| +
|
| +main() {
|
| + describe('ADirective', () {
|
| + TestBed _;
|
| +
|
| + beforeEach(inject((TestBed tb) => _ = tb));
|
| +
|
| + it('should bind click listener when href zero length string', inject((Scope scope) {
|
| + _.compile('<a href="" ng-click="abc = true; event = \$event"></a>');
|
| + _.triggerEvent(_.rootElement, 'click', 'MouseEvent');
|
| + expect(_.rootScope['abc']).toEqual(true);
|
| + expect(_.rootScope['event'] is dom.UIEvent).toEqual(true);
|
| + }));
|
| +
|
| + it('should bind click listener when href empty', inject((Scope scope) {
|
| + _.compile('<a href ng-click="abc = true; event = \$event"></a>');
|
| + _.triggerEvent(_.rootElement, 'click', 'MouseEvent');
|
| + expect(_.rootScope['abc']).toEqual(true);
|
| + expect(_.rootScope['event'] is dom.UIEvent).toEqual(true);
|
| + }));
|
| +
|
| + it('should not bind click listener to non empty href', inject((Scope scope) {
|
| + _.compile('<a href="#"></a>');
|
| + _.triggerEvent(_.rootElement, 'click', 'MouseEvent');
|
| + expect(window.location.href.endsWith("#")).toEqual(true);
|
| + }));
|
| +
|
| + it('should not cancel click with non-empty interpolated href', inject((Scope scope) {
|
| + _.compile('<a href="{{url}}" ng-click="abc = true; event = \$event"></a>');
|
| + _.triggerEvent(_.rootElement, 'click', 'MouseEvent');
|
| + expect(_.rootScope['abc']).toEqual(true);
|
| + expect(_.rootScope['event'] is dom.UIEvent).toEqual(true);
|
| + window.location.href = '#';
|
| + _.rootScope['url'] = '#url';
|
| + _.rootScope.$digest();
|
| + _.triggerEvent(_.rootElement, 'click', 'MouseEvent');
|
| + expect(window.location.href.endsWith("#url")).toEqual(true);
|
| + }));
|
| + });
|
| +}
|
|
|