Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: third_party/pkg/angular/test/directive/ng_a_spec.dart

Issue 256553002: Revert "Update all Angular libs (run update_all.sh)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 library ng_a_spec; 1 library ng_a_spec;
2 2
3 import '../_specs.dart'; 3 import '../_specs.dart';
4 import 'dart:html' as dom; 4 import 'dart:html' as dom;
5 5
6 main() { 6 main() {
7 isBrowser(String pattern) => window.navigator.userAgent.contains(pattern);
8
9 describe('ADirective', () { 7 describe('ADirective', () {
10 TestBed _; 8 TestBed _;
11 9
12 beforeEach((TestBed tb) => _ = tb); 10 beforeEach(inject((TestBed tb) => _ = tb));
13 11
14 it('should bind click listener when href zero length string', (Scope scope) { 12 it('should bind click listener when href zero length string', inject((Scope scope) {
15 _.compile('<a href="" ng-click="abc = 4; event = \$event"></a>'); 13 _.compile('<a href="" ng-click="abc = true; event = \$event"></a>');
16 _.triggerEvent(_.rootElement, 'click', 'MouseEvent'); 14 _.triggerEvent(_.rootElement, 'click', 'MouseEvent');
17 expect(_.rootScope.context['abc']).toEqual(4); 15 expect(_.rootScope.context['abc']).toEqual(true);
18 expect(_.rootScope.context['event'] is dom.UIEvent).toEqual(true); 16 expect(_.rootScope.context['event'] is dom.UIEvent).toEqual(true);
19 }); 17 }));
20 18
21 it('should bind click listener when href empty', (Scope scope) { 19 it('should bind click listener when href empty', inject((Scope scope) {
22 _.compile('<a href ng-click="abc = 5; event = \$event"></a>'); 20 _.compile('<a href ng-click="abc = true; event = \$event"></a>');
23 _.triggerEvent(_.rootElement, 'click', 'MouseEvent'); 21 _.triggerEvent(_.rootElement, 'click', 'MouseEvent');
24 expect(_.rootScope.context['abc']).toEqual(5); 22 expect(_.rootScope.context['abc']).toEqual(true);
25 expect(_.rootScope.context['event'] is dom.UIEvent).toEqual(true); 23 expect(_.rootScope.context['event'] is dom.UIEvent).toEqual(true);
26 }); 24 }));
27 25
28 it('should not bind click listener to non empty href', (Scope scope) { 26 it('should not bind click listener to non empty href', inject((Scope scope) {
29 // NOTE(deboer): In Firefox, after the dispatchEvent, the location.href
30 // value does not update synchronously. I do not know how to test this.
31 if (isBrowser('Firefox')) return;
32
33 window.location.href = '#something'; 27 window.location.href = '#something';
34 _.compile('<a href="#"></a>'); 28 _.compile('<a href="#"></a>');
35 _.triggerEvent(_.rootElement, 'click', 'MouseEvent'); 29 _.triggerEvent(_.rootElement, 'click', 'MouseEvent');
36 expect(window.location.href.endsWith("#")).toEqual(true); 30 expect(window.location.href.endsWith("#")).toEqual(true);
37 }); 31 }));
38 32
39 it('should not cancel click with non-empty interpolated href', (Scope scope) { 33 it('should not cancel click with non-empty interpolated href', inject((Scope scope) {
40 // NOTE(deboer): In Firefox, after the dispatchEvent, the location.href
41 // value does not update synchronously. I do not know how to test this.
42 if (isBrowser('Firefox')) return;
43
44 _.compile('<a href="{{url}}" ng-click="abc = true; event = \$event"></a>') ; 34 _.compile('<a href="{{url}}" ng-click="abc = true; event = \$event"></a>') ;
45 _.triggerEvent(_.rootElement, 'click', 'MouseEvent'); 35 _.triggerEvent(_.rootElement, 'click', 'MouseEvent');
46 expect(_.rootScope.context['abc']).toEqual(true); 36 expect(_.rootScope.context['abc']).toEqual(true);
47 expect(_.rootScope.context['event'] is dom.UIEvent).toEqual(true); 37 expect(_.rootScope.context['event'] is dom.UIEvent).toEqual(true);
48 window.location.href = '#'; 38 window.location.href = '#';
49 _.rootScope.context['url'] = '#url'; 39 _.rootScope.context['url'] = '#url';
50 _.rootScope.apply(); 40 _.rootScope.apply();
51 _.triggerEvent(_.rootElement, 'click', 'MouseEvent'); 41 _.triggerEvent(_.rootElement, 'click', 'MouseEvent');
52 expect(window.location.href.endsWith("#url")).toEqual(true); 42 expect(window.location.href.endsWith("#url")).toEqual(true);
53 }); 43 }));
54 }); 44 });
55 } 45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698