| Index: third_party/pkg/angular/test/directive/ng_if_spec.dart
|
| diff --git a/third_party/pkg/angular/test/directive/ng_if_spec.dart b/third_party/pkg/angular/test/directive/ng_if_spec.dart
|
| index ec2a92f51197db5644a36e2529c8df870410312c..b5251b261ed1515e2357d1179e29baca19190b09 100644
|
| --- a/third_party/pkg/angular/test/directive/ng_if_spec.dart
|
| +++ b/third_party/pkg/angular/test/directive/ng_if_spec.dart
|
| @@ -2,47 +2,43 @@ library ng_if_spec;
|
|
|
| import '../_specs.dart';
|
|
|
| -@NgDirective(
|
| +@Decorator(
|
| selector: '[child-controller]',
|
| - children: NgAnnotation.TRANSCLUDE_CHILDREN)
|
| + children: Directive.TRANSCLUDE_CHILDREN)
|
| class ChildController {
|
| - ChildController(BoundBlockFactory boundBlockFactory,
|
| - BlockHole blockHole,
|
| + ChildController(BoundViewFactory boundViewFactory,
|
| + ViewPort viewPort,
|
| Scope scope) {
|
| scope.context['setBy'] = 'childController';
|
| - boundBlockFactory(scope).insertAfter(blockHole);
|
| + viewPort.insert(boundViewFactory(scope));
|
| }
|
| }
|
|
|
| main() {
|
| var compile, html, element, rootScope, logger, directives;
|
|
|
| - void configInjector() {
|
| - module((Module module) {
|
| - module
|
| - ..type(ChildController)
|
| + void configInjector(Module module) {
|
| + module..type(ChildController)
|
| ..type(LogAttrDirective);
|
| - });
|
| }
|
|
|
| - void configState() {
|
| - inject((Scope scope, Compiler compiler, Injector injector, Logger _logger, DirectiveMap _directives) {
|
| - rootScope = scope;
|
| - logger = _logger;
|
| - compile = (html, [applyFn]) {
|
| - element = $(html);
|
| - compiler(element, _directives)(injector, element);
|
| - scope.apply(applyFn);
|
| - };
|
| - directives = _directives;
|
| - });
|
| + void configState(Scope scope, Compiler compiler, Injector injector,
|
| + Logger _logger, DirectiveMap _directives) {
|
| + rootScope = scope;
|
| + logger = _logger;
|
| + compile = (html, [applyFn]) {
|
| + element = e(html);
|
| + compiler([element], _directives)(injector, [element]);
|
| + scope.apply(applyFn);
|
| + };
|
| + directives = _directives;
|
| }
|
|
|
| they(should, htmlForElements, callback, [exclusive=false]) {
|
| htmlForElements.forEach((html) {
|
| var directiveName = html.contains('ng-if') ? 'ng-if' : 'ng-unless';
|
| describe(directiveName, () {
|
| - beforeEach(configInjector);
|
| + beforeEachModule(configInjector);
|
| beforeEach(configState);
|
| (exclusive ? iit : it)(should, () {
|
| callback(html);
|
| @@ -57,22 +53,20 @@ main() {
|
| (html) {
|
| compile(html);
|
| // The span node should NOT exist in the DOM.
|
| - expect(element.contents().length).toEqual(1);
|
| - expect(element.find('span').html()).toEqual('');
|
| + expect(element.querySelectorAll('span').length).toEqual(0);
|
|
|
| rootScope.apply(() {
|
| rootScope.context['isVisible'] = true;
|
| });
|
|
|
| // The span node SHOULD exist in the DOM.
|
| - expect(element.contents().length).toEqual(2);
|
| - expect(element.find('span').html()).toEqual('content');
|
| + expect(element.querySelector('span')).toHaveHtml('content');
|
|
|
| rootScope.apply(() {
|
| rootScope.context['isVisible'] = false;
|
| });
|
|
|
| - expect(element.find('span').html()).toEqual('');
|
| + expect(element.querySelectorAll('span').length).toEqual(0);
|
| }
|
| );
|
|
|
| @@ -81,31 +75,31 @@ main() {
|
| // ng-if
|
| '<div>' +
|
| ' <div ng-if="isVisible">'.trim() +
|
| - ' <span child-controller id="inside">{{setBy}}</span>'.trim() +
|
| + ' <span child-controller id="inside">inside {{setBy}};</span>'.trim() +
|
| ' </div>'.trim() +
|
| - ' <span id="outside">{{setBy}}</span>'.trim() +
|
| + ' <span id="outside">outside {{setBy}}</span>'.trim() +
|
| '</div>',
|
| // ng-unless
|
| '<div>' +
|
| ' <div ng-unless="!isVisible">'.trim() +
|
| - ' <span child-controller id="inside">{{setBy}}</span>'.trim() +
|
| + ' <span child-controller id="inside">inside {{setBy}};</span>'.trim() +
|
| ' </div>'.trim() +
|
| - ' <span id="outside">{{setBy}}</span>'.trim() +
|
| + ' <span id="outside">outside {{setBy}}</span>'.trim() +
|
| '</div>'],
|
| (html) {
|
| rootScope.context['setBy'] = 'topLevel';
|
| compile(html);
|
| - expect(element.contents().length).toEqual(2);
|
| + expect(element).toHaveText('outside topLevel');
|
|
|
| rootScope.apply(() {
|
| rootScope.context['isVisible'] = true;
|
| });
|
| - expect(element.contents().length).toEqual(3);
|
| + expect(element).toHaveText('inside childController;outside topLevel');
|
| // The value on the parent scope.context['should'] be unchanged.
|
| expect(rootScope.context['setBy']).toEqual('topLevel');
|
| - expect(element.find('#outside').html()).toEqual('topLevel');
|
| + expect(element.querySelector('#outside')).toHaveHtml('outside topLevel');
|
| // A child scope.context['must'] have been created and hold a different value.
|
| - expect(element.find('#inside').html()).toEqual('childController');
|
| + expect(element.querySelector('#inside')).toHaveHtml('inside childController;');
|
| }
|
| );
|
|
|
| @@ -113,28 +107,28 @@ main() {
|
| [
|
| // ng-if
|
| '<div>' +
|
| - ' <div ng-repeat="i in values"></div>'.trim() +
|
| - ' <div ng-if="values.length==4"></div>'.trim() +
|
| - ' <div ng-repeat="i in values"></div>'.trim() +
|
| + ' <div ng-repeat="i in values">repeat;</div>'.trim() +
|
| + ' <div ng-if="values.length==4">if;</div>'.trim() +
|
| + ' <div ng-repeat="i in values">repeat2;</div>'.trim() +
|
| '</div>',
|
| // ng-unless
|
| '<div>' +
|
| - ' <div ng-repeat="i in values"></div>'.trim() +
|
| - ' <div ng-unless="values.length!=4"></div>'.trim() +
|
| - ' <div ng-repeat="i in values"></div>'.trim() +
|
| + ' <div ng-repeat="i in values">repeat;</div>'.trim() +
|
| + ' <div ng-unless="values.length!=4">if;</div>'.trim() +
|
| + ' <div ng-repeat="i in values">repeat2;</div>'.trim() +
|
| '</div>'],
|
| (html) {
|
| var values = rootScope.context['values'] = [1, 2, 3, 4];
|
| compile(html);
|
| - expect(element.contents().length).toBe(12);
|
| + expect(element).toHaveText('repeat;repeat;repeat;repeat;if;repeat2;repeat2;repeat2;repeat2;');
|
| rootScope.apply(() {
|
| values.removeRange(0, 1);
|
| });
|
| - expect(element.contents().length).toBe(9);
|
| + expect(element).toHaveText('repeat;repeat;repeat;repeat2;repeat2;repeat2;');
|
| rootScope.apply(() {
|
| values.insert(0, 1);
|
| });
|
| - expect(element.contents().length).toBe(12);
|
| + expect(element).toHaveText('repeat;repeat;repeat;repeat;if;repeat2;repeat2;repeat2;repeat2;');
|
| }
|
| );
|
|
|
| @@ -145,18 +139,18 @@ main() {
|
| (html) {
|
| rootScope.context['isVisible'] = true;
|
| compile(html);
|
| - expect(element.contents().length).toEqual(2);
|
| - element.find('span').removeClass('my-class');
|
| - expect(element.find('span').hasClass('my-class')).not.toBe(true);
|
| + expect(element).toHaveText('content');
|
| + element.querySelector('span').classes.remove('my-class');
|
| + expect(element.querySelector('span')).not.toHaveClass('my-class');
|
| rootScope.apply(() {
|
| rootScope.context['isVisible'] = false;
|
| });
|
| - expect(element.contents().length).toEqual(1);
|
| + expect(element).toHaveText('');
|
| rootScope.apply(() {
|
| rootScope.context['isVisible'] = true;
|
| });
|
| // The newly inserted node should be a copy of the compiled state.
|
| - expect(element.find('span').hasClass('my-class')).toBe(true);
|
| + expect(element.querySelector('span')).toHaveClass('my-class');
|
| }
|
| );
|
|
|
| @@ -169,7 +163,7 @@ main() {
|
| rootScope.apply(() {
|
| rootScope.context['isVisible'] = false;
|
| });
|
| - expect(element.find('span').html()).toEqual('');
|
| + expect(element.querySelectorAll('span').length).toEqual(0);
|
| }
|
| );
|
|
|
| @@ -179,19 +173,19 @@ main() {
|
| '<div><li log="ALWAYS"></li><span log="JAMES" ng-unless="!isVisible">content</span></div>'],
|
| (html) {
|
| compile(html);
|
| - expect(element.find('span').html()).toEqual('');
|
| + expect(element.querySelectorAll('span').length).toEqual(0);
|
|
|
| rootScope.apply(() {
|
| rootScope.context['isVisible'] = false;
|
| });
|
| - expect(element.find('span').html()).toEqual('');
|
| + expect(element.querySelectorAll('span').length).toEqual(0);
|
| expect(logger.result()).toEqual('ALWAYS');
|
|
|
|
|
| rootScope.apply(() {
|
| rootScope.context['isVisible'] = true;
|
| });
|
| - expect(element.find('span').html()).toEqual('content');
|
| + expect(element.querySelector('span')).toHaveHtml('content');
|
| expect(logger.result()).toEqual('ALWAYS; JAMES');
|
| }
|
| );
|
| @@ -202,7 +196,7 @@ main() {
|
| '<div><div ng-unless="!a"><div ng-unless="!b">content</div></div></div>'],
|
| (html) {
|
| compile(html);
|
| - expect(element.find('span').html()).toEqual('');
|
| + expect(element.querySelectorAll('span').length).toEqual(0);
|
|
|
| expect(() {
|
| rootScope.apply(() {
|
| @@ -210,7 +204,7 @@ main() {
|
| rootScope.context['b'] = false;
|
| });
|
| }).not.toThrow();
|
| - expect(element.find('span').html()).toEqual('');
|
| + expect(element.querySelectorAll('span').length).toEqual(0);
|
|
|
|
|
| expect(() {
|
| @@ -219,7 +213,7 @@ main() {
|
| rootScope.context['b'] = true;
|
| });
|
| }).not.toThrow();
|
| - expect(element.find('span').html()).toEqual('');
|
| + expect(element.querySelectorAll('span').length).toEqual(0);
|
| }
|
| );
|
| }
|
|
|