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

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

Issue 180873006: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review feedback 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
diff --git a/third_party/pkg/angular/test/core_dom/ng_mustache_spec.dart b/third_party/pkg/angular/test/core_dom/ng_mustache_spec.dart
index 7df03b1eb32532d6ae7c89d94cbbac5dbbf7ee18..6a2c1dffcf41bceb8604fd9692ca1ec02dfd6cf8 100644
--- a/third_party/pkg/angular/test/core_dom/ng_mustache_spec.dart
+++ b/third_party/pkg/angular/test/core_dom/ng_mustache_spec.dart
@@ -6,50 +6,65 @@ main() {
describe('ng-mustache', () {
TestBed _;
beforeEach(module((Module module) {
- module.type(_ListenerDirective);
+ module.type(_HelloFilter);
}));
beforeEach(inject((TestBed tb) => _ = tb));
- it('should replace {{}} in text', inject((Compiler $compile, Scope $rootScope, Injector injector) {
+ it('should replace {{}} in text', inject((Compiler $compile, Scope rootScope, Injector injector, DirectiveMap directives) {
var element = $('<div>{{name}}<span>!</span></div>');
- var template = $compile(element);
+ var template = $compile(element, directives);
- $rootScope.name = 'OK';
+ rootScope.context['name'] = 'OK';
var block = template(injector);
element = $(block.elements);
- expect(element.text()).toEqual('!');
- $rootScope.$digest();
+ rootScope.apply();
expect(element.text()).toEqual('OK!');
}));
- 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) {
+ it('should replace {{}} in attribute', inject((Compiler $compile, Scope rootScope, Injector injector, DirectiveMap directives) {
var element = $('<div some-attr="{{name}}" other-attr="{{age}}"></div>');
- var template = $compile(element);
+ var template = $compile(element, directives);
- $rootScope.name = 'OK';
- $rootScope.age = 23;
+ rootScope.context['name'] = 'OK';
+ rootScope.context['age'] = 23;
var block = template(injector);
element = $(block.elements);
- expect(element.attr('some-attr')).toEqual('');
- expect(element.attr('other-attr')).toEqual('');
- $rootScope.$digest();
+ rootScope.apply();
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', () {
@@ -57,51 +72,48 @@ main() {
beforeEach(inject((TestBed tb) => _ = tb));
- it('should add/remove ng-show class', () {
+ it('should add/remove ng-hide class', () {
var element = _.compile('<div ng-show="isVisible"></div>');
- expect(element).not.toHaveClass('ng-show');
+ expect(element).not.toHaveClass('ng-hide');
- _.rootScope.$apply(() {
- _.rootScope['isVisible'] = true;
+ _.rootScope.apply(() {
+ _.rootScope.context['isVisible'] = true;
});
- expect(element).toHaveClass('ng-show');
+ expect(element).not.toHaveClass('ng-hide');
- _.rootScope.$apply(() {
- _.rootScope['isVisible'] = false;
+ _.rootScope.apply(() {
+ _.rootScope.context['isVisible'] = false;
});
- expect(element).not.toHaveClass('ng-show');
+ expect(element).toHaveClass('ng-hide');
});
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-show');
+ expect(element).not.toHaveClass('ng-hide');
- _.rootScope.$apply(() {
- _.rootScope['currentCls'] = 'active';
+ _.rootScope.apply(() {
+ _.rootScope.context['currentCls'] = 'active';
});
expect(element).toHaveClass('active');
- expect(element).not.toHaveClass('ng-show');
+ expect(element).toHaveClass('ng-hide');
- _.rootScope.$apply(() {
- _.rootScope['isVisible'] = true;
+ _.rootScope.apply(() {
+ _.rootScope.context['isVisible'] = true;
});
expect(element).toHaveClass('active');
- expect(element).toHaveClass('ng-show');
+ expect(element).not.toHaveClass('ng-hide');
});
});
}
-@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);
+@NgFilter(name:'hello')
+class _HelloFilter {
+ call(String str) {
+ return 'Hello, $str!';
+ }
}
+
« 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