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

Side by Side Diff: third_party/pkg/angular/test/tools/selector_spec.dart

Issue 257423008: 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 angular.selector_spec; 1 library angular.selector_spec;
2 2
3 import 'package:angular/tools/selector.dart'; 3 import 'package:angular/tools/selector.dart';
4 import 'package:html5lib/dom.dart'; 4 import 'package:html5lib/dom.dart';
5 import 'package:unittest/unittest.dart'; 5 import 'package:unittest/unittest.dart';
6 6
7 import '../jasmine_syntax.dart'; 7 import '../jasmine_syntax.dart';
8 8
9 main() => describe('selector', () { 9 void main() {
10 describe('selector', () {
10 11
11 it('should match directive on element', () { 12 it('should match directive on element', () {
12 var node = new Element.html('<b></b>'); 13 var node = new Element.html('<b></b>');
13 expect(matchesNode(node, 'b'), isTrue); 14 expect(matchesNode(node, 'b'), isTrue);
14 expect(matchesNode(node, 'em'), isFalse); 15 expect(matchesNode(node, 'em'), isFalse);
15 }); 16 });
16 17
17 it('should match directive on class', () { 18 it('should match directive on class', () {
18 var node = new Element.html('<div class="b"></div>'); 19 var node = new Element.html('<div class="b"></div>');
19 expect(matchesNode(node, '.b'), isTrue); 20 expect(matchesNode(node, '.b'), isTrue);
20 expect(matchesNode(node, '.c'), isFalse); 21 expect(matchesNode(node, '.c'), isFalse);
21 }); 22 });
22 23
23 24
24 it('should match directive on [attribute]', () { 25 it('should match directive on [attribute]', () {
25 var node = new Element.html('<div directive></div>'); 26 var node = new Element.html('<div directive></div>');
26 expect(matchesNode(node, '[directive]'), isTrue); 27 expect(matchesNode(node, '[directive]'), isTrue);
27 expect(matchesNode(node, '[directiff]'), isFalse); 28 expect(matchesNode(node, '[directiff]'), isFalse);
28 29
29 node = new Element.html('<div directive="abc"></div>'); 30 node = new Element.html('<div directive="abc"></div>');
30 expect(matchesNode(node, '[directive=abc]'), isTrue); 31 expect(matchesNode(node, '[directive=abc]'), isTrue);
31 expect(matchesNode(node, '[directive=bcd]'), isFalse); 32 expect(matchesNode(node, '[directive=bcd]'), isFalse);
32 }); 33 });
33 34
34 35
35 it('should match directive on element[attribute]', () { 36 it('should match directive on element[attribute]', () {
36 var node = new Element.html('<b directive=abc></b>'); 37 var node = new Element.html('<b directive=abc></b>');
37 expect(matchesNode(node, 'b[directive]'), isTrue); 38 expect(matchesNode(node, 'b[directive]'), isTrue);
38 expect(matchesNode(node, 'c[directive]'), isFalse); 39 expect(matchesNode(node, 'c[directive]'), isFalse);
39 }); 40 });
40 41
41 42
42 it('should match directive on [attribute=value]', () { 43 it('should match directive on [attribute=value]', () {
43 var node = new Element.html('<div directive=value></div>'); 44 var node = new Element.html('<div directive=value></div>');
44 expect(matchesNode(node, '[directive=value]'), isTrue); 45 expect(matchesNode(node, '[directive=value]'), isTrue);
45 }); 46 });
46 47
47 48
48 it('should match directive on element[attribute=value]', () { 49 it('should match directive on element[attribute=value]', () {
49 var node = new Element.html('<b directive=value></b>'); 50 var node = new Element.html('<b directive=value></b>');
50 expect(matchesNode(node, 'b[directive=value]'), isTrue); 51 expect(matchesNode(node, 'b[directive=value]'), isTrue);
51 expect(matchesNode(node, 'b[directive=wrongvalue]'), isFalse); 52 expect(matchesNode(node, 'b[directive=wrongvalue]'), isFalse);
53 });
54
55 it('should match attributes', () {
56 var node = new Element.html('<div attr="before-xyz-after"></div>');
57 expect(matchesNode(node, '[*=/xyz/]'), isTrue);
58 expect(matchesNode(node, '[*=/xyzz/]'), isFalse);
59 });
60
61 it('should match whildcard attributes', () {
62 var node = new Element.html('<div attr-foo="blah"></div>');
63 expect(matchesNode(node, '[attr-*]'), isTrue);
64 expect(matchesNode(node, '[attr-*=blah]'), isTrue);
65 expect(matchesNode(node, '[attr-*=halb]'), isFalse);
66 expect(matchesNode(node, '[foo-*]'), isFalse);
67 expect(matchesNode(node, '[foo-*=blah]'), isFalse);
68 expect(matchesNode(node, '[foo-*=halb]'), isFalse);
69 });
70
71 it('should match text', () {
72 var node = new Text('before-abc-after');
73 expect(matchesNode(node, ':contains(/abc/)'), isTrue);
74 expect(matchesNode(node, ':contains(/cde/)'), isFalse);
75 });
76
77 it('should match on multiple directives', () {
78 var node = new Element.html('<div directive="d" foo="f"></div>');
79 expect(matchesNode(node, '[directive=d][foo=f]'), isTrue);
80 expect(matchesNode(node, '[directive=d][bar=baz]'), isFalse);
81 });
82
52 }); 83 });
53 84 }
54 it('should match attributes', () {
55 var node = new Element.html('<div attr="before-xyz-after"></div>');
56 expect(matchesNode(node, '[*=/xyz/]'), isTrue);
57 expect(matchesNode(node, '[*=/xyzz/]'), isFalse);
58 });
59
60 it('should match whildcard attributes', () {
61 var node = new Element.html('<div attr-foo="blah"></div>');
62 expect(matchesNode(node, '[attr-*]'), isTrue);
63 expect(matchesNode(node, '[attr-*=blah]'), isTrue);
64 expect(matchesNode(node, '[attr-*=halb]'), isFalse);
65 expect(matchesNode(node, '[foo-*]'), isFalse);
66 expect(matchesNode(node, '[foo-*=blah]'), isFalse);
67 expect(matchesNode(node, '[foo-*=halb]'), isFalse);
68 });
69
70 it('should match text', () {
71 var node = new Text('before-abc-after');
72 expect(matchesNode(node, ':contains(/abc/)'), isTrue);
73 expect(matchesNode(node, ':contains(/cde/)'), isFalse);
74 });
75
76 it('should match on multiple directives', () {
77 var node = new Element.html('<div directive="d" foo="f"></div>');
78 expect(matchesNode(node, '[directive=d][foo=f]'), isTrue);
79 expect(matchesNode(node, '[directive=d][bar=baz]'), isFalse);
80 });
81
82 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698