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

Side by Side Diff: third_party/pkg/angular/test/introspection_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 introspection_spec; 1 library introspection_spec;
2 2
3 import '_specs.dart'; 3 import '_specs.dart';
4 import 'dart:js' as js;
5 import 'package:angular/application_factory.dart';
4 6
5 main() => describe('introspection', () { 7 void main() {
6 it('should retrieve ElementProbe', inject((TestBed _) { 8 describe('introspection', () {
7 _.compile('<div ng-bind="true"></div>'); 9 it('should retrieve ElementProbe', (TestBed _) {
8 ElementProbe probe = ngProbe(_.rootElement); 10 _.compile('<div ng-bind="true"></div>');
9 expect(probe.injector.parent).toBe(_.injector); 11 ElementProbe probe = ngProbe(_.rootElement);
10 expect(ngInjector(_.rootElement).parent).toBe(_.injector); 12 expect(probe.injector.parent).toBe(_.injector);
11 expect(probe.directives[0] is NgBindDirective).toBe(true); 13 expect(ngInjector(_.rootElement).parent).toBe(_.injector);
12 expect(ngDirectives(_.rootElement)[0] is NgBindDirective).toBe(true); 14 expect(probe.directives[0] is NgBind).toBe(true);
13 expect(probe.scope).toBe(_.rootScope); 15 expect(ngDirectives(_.rootElement)[0] is NgBind).toBe(true);
14 expect(ngScope(_.rootElement)).toBe(_.rootScope); 16 expect(probe.scope).toBe(_.rootScope);
15 })); 17 expect(ngScope(_.rootElement)).toBe(_.rootScope);
18 });
16 19
17 toHtml(List list) => list.map((e) => e.outerHtml).join(''); 20 toHtml(List list) => list.map((e) => e.outerHtml).join('');
18 21
19 it('should select elements using CSS selector', () { 22 it('should select elements using CSS selector', () {
20 var div = new Element.html('<div><p><span></span></p></div>'); 23 var div = new Element.html('<div><p><span></span></p></div>');
21 var span = div.querySelector('span'); 24 var span = div.querySelector('span');
22 var shadowRoot = span.createShadowRoot(); 25 var shadowRoot = span.createShadowRoot();
23 shadowRoot.innerHtml = '<ul><li>stash</li><li>secret</li><ul>'; 26 shadowRoot.innerHtml = '<ul><li>stash</li><li>secret</li><ul>';
24 27
25 expect(toHtml(ngQuery(div, 'li'))).toEqual('<li>stash</li><li>secret</li>'); 28 expect(toHtml(ngQuery(div, 'li'))).toEqual('<li>stash</li><li>secret</li>' );
26 expect(toHtml(ngQuery(div, 'li', 'stash'))).toEqual('<li>stash</li>'); 29 expect(toHtml(ngQuery(div, 'li', 'stash'))).toEqual('<li>stash</li>');
27 expect(toHtml(ngQuery(div, 'li', 'secret'))).toEqual('<li>secret</li>'); 30 expect(toHtml(ngQuery(div, 'li', 'secret'))).toEqual('<li>secret</li>');
28 expect(toHtml(ngQuery(div, 'li', 'xxx'))).toEqual(''); 31 expect(toHtml(ngQuery(div, 'li', 'xxx'))).toEqual('');
32 });
33
34 it('should select elements in the root shadow root', () {
35 var div = new Element.html('<div></div>');
36 var shadowRoot = div.createShadowRoot();
37 shadowRoot.innerHtml = '<ul><li>stash</li><li>secret</li><ul>';
38 expect(toHtml(ngQuery(div, 'li'))).toEqual('<li>stash</li><li>secret</li>' );
39 });
40
41 // Does not work in dart2js. deboer is investigating.
42 it('should be available from Javascript', () {
43 // The probe only works if there is a directive.
44 var elt = e('<div ng-app id=ngtop ng-bind="\'introspection FTW\'"></div>') ;
45 // Make it possible to find the element from JS
46 document.body.append(elt);
47 (applicationFactory()..element = elt).run();
48
49 expect(js.context['ngProbe']).toBeDefined();
50 expect(js.context['ngScope']).toBeDefined();
51 expect(js.context['ngInjector']).toBeDefined();
52 expect(js.context['ngQuery']).toBeDefined();
53
54
55 // Polymer does not support accessing named elements directly (e.g. window .ngtop)
56 // so we need to use getElementById to support Polymer's shadow DOM polyfi ll.
57 expect(js.context['ngProbe'].apply([document.getElementById('ngtop')])).to BeDefined();
58 });
29 }); 59 });
30 60 }
31 it('should select elements in the root shadow root', () {
32 var div = new Element.html('<div></div>');
33 var shadowRoot = div.createShadowRoot();
34 shadowRoot.innerHtml = '<ul><li>stash</li><li>secret</li><ul>';
35 expect(toHtml(ngQuery(div, 'li'))).toEqual('<li>stash</li><li>secret</li>');
36 });
37 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698