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

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

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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
(Empty)
1 library angular.selector_spec;
2
3 import 'package:angular/tools/selector.dart';
4 import 'package:html5lib/dom.dart';
5 import 'package:unittest/unittest.dart';
6
7 import '../jasmine_syntax.dart';
8
9 main() => describe('selector', () {
10
11 it('should match directive on element', () {
12 var node = new Element.html('<b></b>');
13 expect(matchesNode(node, 'b'), isTrue);
14 expect(matchesNode(node, 'em'), isFalse);
15 });
16
17 it('should match directive on class', () {
18 var node = new Element.html('<div class="b"></div>');
19 expect(matchesNode(node, '.b'), isTrue);
20 expect(matchesNode(node, '.c'), isFalse);
21 });
22
23
24 it('should match directive on [attribute]', () {
25 var node = new Element.html('<div directive></div>');
26 expect(matchesNode(node, '[directive]'), isTrue);
27 expect(matchesNode(node, '[directiff]'), isFalse);
28
29 node = new Element.html('<div directive="abc"></div>');
30 expect(matchesNode(node, '[directive=abc]'), isTrue);
31 expect(matchesNode(node, '[directive=bcd]'), isFalse);
32 });
33
34
35 it('should match directive on element[attribute]', () {
36 var node = new Element.html('<b directive=abc></b>');
37 expect(matchesNode(node, 'b[directive]'), isTrue);
38 expect(matchesNode(node, 'c[directive]'), isFalse);
39 });
40
41
42 it('should match directive on [attribute=value]', () {
43 var node = new Element.html('<div directive=value></div>');
44 expect(matchesNode(node, '[directive=value]'), isTrue);
45 });
46
47
48 it('should match directive on element[attribute=value]', () {
49 var node = new Element.html('<b directive=value></b>');
50 expect(matchesNode(node, 'b[directive=value]'), isTrue);
51 expect(matchesNode(node, 'b[directive=wrongvalue]'), isFalse);
52 });
53
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 text', () {
61 var node = new Text('before-abc-after');
62 expect(matchesNode(node, ':contains(/abc/)'), isTrue);
63 expect(matchesNode(node, ':contains(/cde/)'), isFalse);
64 });
65
66 it('should match on multiple directives', () {
67 var node = new Element.html('<div directive="d" foo="f"></div>');
68 expect(matchesNode(node, '[directive=d][foo=f]'), isTrue);
69 expect(matchesNode(node, '[directive=d][bar=baz]'), isFalse);
70 });
71
72 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698