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

Unified Diff: third_party/pkg/angular/test/core_dom/ng_mustache_spec.dart

Issue 180843004: Revert revision 33053 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/test/core_dom/ng_mustache_spec.dart
===================================================================
--- third_party/pkg/angular/test/core_dom/ng_mustache_spec.dart (revision 33054)
+++ third_party/pkg/angular/test/core_dom/ng_mustache_spec.dart (working copy)
@@ -6,65 +6,50 @@
describe('ng-mustache', () {
TestBed _;
beforeEach(module((Module module) {
- module.type(_HelloFilter);
+ module.type(_ListenerDirective);
}));
beforeEach(inject((TestBed tb) => _ = tb));
- it('should replace {{}} in text', inject((Compiler $compile, Scope rootScope, Injector injector, DirectiveMap directives) {
+ it('should replace {{}} in text', inject((Compiler $compile, Scope $rootScope, Injector injector) {
var element = $('<div>{{name}}<span>!</span></div>');
- var template = $compile(element, directives);
+ var template = $compile(element);
- rootScope.context['name'] = 'OK';
+ $rootScope.name = 'OK';
var block = template(injector);
element = $(block.elements);
- rootScope.apply();
+ expect(element.text()).toEqual('!');
+ $rootScope.$digest();
expect(element.text()).toEqual('OK!');
}));
- it('should replace {{}} in attribute', inject((Compiler $compile, Scope rootScope, Injector injector, DirectiveMap directives) {
+ it('should allow listening on text change events', inject((Logger logger) {
+ _.compile('<div listener>{{text}}</div>');
+ _.rootScope.text = 'works';
+ _.rootScope.$apply();
+ expect(_.rootElement.text).toEqual('works');
+ expect(logger).toEqual(['', 'works']);
+ }));
+
+
+ it('should replace {{}} in attribute', inject((Compiler $compile, Scope $rootScope, Injector injector) {
var element = $('<div some-attr="{{name}}" other-attr="{{age}}"></div>');
- var template = $compile(element, directives);
+ var template = $compile(element);
- rootScope.context['name'] = 'OK';
- rootScope.context['age'] = 23;
+ $rootScope.name = 'OK';
+ $rootScope.age = 23;
var block = template(injector);
element = $(block.elements);
- rootScope.apply();
+ expect(element.attr('some-attr')).toEqual('');
+ expect(element.attr('other-attr')).toEqual('');
+ $rootScope.$digest();
expect(element.attr('some-attr')).toEqual('OK');
expect(element.attr('other-attr')).toEqual('23');
}));
-
-
- it('should allow newlines in attribute', inject((Compiler $compile, RootScope rootScope, Injector injector, DirectiveMap directives) {
- var element = $('<div multiline-attr="line1: {{line1}}\nline2: {{line2}}"></div>');
- var template = $compile(element, directives);
-
- rootScope.context['line1'] = 'L1';
- rootScope.context['line2'] = 'L2';
- var block = template(injector);
-
- element = $(block.elements);
-
- rootScope.apply();
- expect(element.attr('multiline-attr')).toEqual('line1: L1\nline2: L2');
- }));
-
-
- it('should handle filters', inject((Compiler $compile, RootScope rootScope, Injector injector, DirectiveMap directives) {
- var element = $('<div>{{"World" | hello}}</div>');
- var template = $compile(element, directives);
- var block = template(injector);
- rootScope.apply();
-
- element = $(block.elements);
-
- expect(element.html()).toEqual('Hello, World!');
- }));
});
describe('NgShow', () {
@@ -72,48 +57,51 @@
beforeEach(inject((TestBed tb) => _ = tb));
- it('should add/remove ng-hide class', () {
+ it('should add/remove ng-show class', () {
var element = _.compile('<div ng-show="isVisible"></div>');
- expect(element).not.toHaveClass('ng-hide');
+ expect(element).not.toHaveClass('ng-show');
- _.rootScope.apply(() {
- _.rootScope.context['isVisible'] = true;
+ _.rootScope.$apply(() {
+ _.rootScope['isVisible'] = true;
});
- expect(element).not.toHaveClass('ng-hide');
+ expect(element).toHaveClass('ng-show');
- _.rootScope.apply(() {
- _.rootScope.context['isVisible'] = false;
+ _.rootScope.$apply(() {
+ _.rootScope['isVisible'] = false;
});
- expect(element).toHaveClass('ng-hide');
+ expect(element).not.toHaveClass('ng-show');
});
it('should work together with ng-class', () {
var element = _.compile('<div ng-class="currentCls" ng-show="isVisible"></div>');
expect(element).not.toHaveClass('active');
- expect(element).not.toHaveClass('ng-hide');
+ expect(element).not.toHaveClass('ng-show');
- _.rootScope.apply(() {
- _.rootScope.context['currentCls'] = 'active';
+ _.rootScope.$apply(() {
+ _.rootScope['currentCls'] = 'active';
});
expect(element).toHaveClass('active');
- expect(element).toHaveClass('ng-hide');
+ expect(element).not.toHaveClass('ng-show');
- _.rootScope.apply(() {
- _.rootScope.context['isVisible'] = true;
+ _.rootScope.$apply(() {
+ _.rootScope['isVisible'] = true;
});
expect(element).toHaveClass('active');
- expect(element).not.toHaveClass('ng-hide');
+ expect(element).toHaveClass('ng-show');
});
});
}
-@NgFilter(name:'hello')
-class _HelloFilter {
- call(String str) {
- return 'Hello, $str!';
- }
+@NgDirective(
+ selector: '[listener]',
+ publishTypes: const [TextChangeListener],
+ visibility: NgDirective.DIRECT_CHILDREN_VISIBILITY
+)
+class _ListenerDirective implements TextChangeListener {
+ Logger logger;
+ _ListenerDirective(Logger this.logger);
+ call(String text) => logger(text);
}
-
« no previous file with comments | « third_party/pkg/angular/test/core_dom/http_spec.dart ('k') | third_party/pkg/angular/test/core_dom/selector_spec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698