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

Unified Diff: third_party/pkg/angular/test/core/templateurl_spec.dart

Issue 176943008: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://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/templateurl_spec.dart
diff --git a/third_party/pkg/angular/test/core/templateurl_spec.dart b/third_party/pkg/angular/test/core/templateurl_spec.dart
index 4a71f6b8f633ded9b0b34112b7821ac9e7d384bb..e24043a5ceeca12b41b3e0e86c3e1124603932eb 100644
--- a/third_party/pkg/angular/test/core/templateurl_spec.dart
+++ b/third_party/pkg/angular/test/core/templateurl_spec.dart
@@ -18,7 +18,7 @@ class HtmlAndCssComponent {
@NgComponent(
selector: 'html-and-css',
templateUrl: 'simple.html',
- cssUrls: const ['simple.css', 'another.css'])
+ cssUrl: const ['simple.css', 'another.css'])
class HtmlAndMultipleCssComponent {
}
@@ -47,20 +47,21 @@ main() => describe('template url', () {
describe('loading with http rewriting', () {
beforeEach(module((Module module) {
module
- ..type(HtmlAndCssComponent)
- ..type(UrlRewriter, implementedBy: PrefixedUrlRewriter);
+ ..type(HtmlAndCssComponent)
+ ..type(UrlRewriter, implementedBy: PrefixedUrlRewriter);
}));
it('should use the UrlRewriter for both HTML and CSS URLs', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Logger log, Injector injector, NgZone zone,
- MockHttpBackend backend) {
+ MockHttpBackend backend, DirectiveMap directives) {
- backend.whenGET('PREFIX:simple.html').respond('<div log="SIMPLE">Simple!</div>');
- backend.whenGET('PREFIX:simple.css').respond('.hello{}');
+ backend
+ ..whenGET('PREFIX:simple.html').respond('<div log="SIMPLE">Simple!</div>')
+ ..whenGET('PREFIX:simple.css').respond('.hello{}');
var element = $('<div><html-and-css log>ignore</html-and-css><div>');
zone.run(() {
- $compile(element)(injector, element);
+ $compile(element, directives)(injector, element);
});
backend.flush();
@@ -76,33 +77,34 @@ main() => describe('template url', () {
describe('async template loading', () {
beforeEach(module((Module module) {
- module.type(LogAttrDirective);
- module.type(SimpleUrlComponent);
- module.type(HtmlAndCssComponent);
- module.type(OnlyCssComponent);
- module.type(InlineWithCssComponent);
+ module
+ ..type(LogAttrDirective)
+ ..type(SimpleUrlComponent)
+ ..type(HtmlAndCssComponent)
+ ..type(OnlyCssComponent)
+ ..type(InlineWithCssComponent);
}));
it('should replace element with template from url', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Logger log, Injector injector,
- MockHttpBackend backend) {
+ MockHttpBackend backend, DirectiveMap directives) {
backend.expectGET('simple.html').respond('<div log="SIMPLE">Simple!</div>');
var element = $('<div><simple-url log>ignore</simple-url><div>');
- $compile(element)(injector, element);
+ $compile(element, directives)(injector, element);
backend.flush();
microLeap();
expect(renderedText(element)).toEqual('Simple!');
- $rootScope.$digest();
+ $rootScope.apply();
// Note: There is no ordering. It is who ever comes off the wire first!
expect(log.result()).toEqual('LOG; SIMPLE');
})));
it('should load template from URL once', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Logger log, Injector injector,
- MockHttpBackend backend) {
+ MockHttpBackend backend, DirectiveMap directives) {
backend.whenGET('simple.html').respond('<div log="SIMPLE">Simple!</div>');
var element = $(
@@ -110,25 +112,26 @@ main() => describe('template url', () {
'<simple-url log>ignore</simple-url>' +
'<simple-url log>ignore</simple-url>' +
'<div>');
- $compile(element)(injector, element);
+ $compile(element, directives)(injector, element);
backend.flush();
microLeap();
expect(renderedText(element)).toEqual('Simple!Simple!');
- $rootScope.$digest();
+ $rootScope.apply();
// Note: There is no ordering. It is who ever comes off the wire first!
expect(log.result()).toEqual('LOG; LOG; SIMPLE; SIMPLE');
})));
it('should load a CSS file into a style', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Logger log, Injector injector,
- MockHttpBackend backend) {
- backend.expectGET('simple.css').respond('.hello{}');
- backend.expectGET('simple.html').respond('<div log="SIMPLE">Simple!</div>');
+ MockHttpBackend backend, DirectiveMap directives) {
+ backend
+ ..expectGET('simple.css').respond('.hello{}')
+ ..expectGET('simple.html').respond('<div log="SIMPLE">Simple!</div>');
var element = $('<div><html-and-css log>ignore</html-and-css><div>');
- $compile(element)(injector, element);
+ $compile(element, directives)(injector, element);
backend.flush();
microLeap();
@@ -137,27 +140,45 @@ main() => describe('template url', () {
expect(element[0].nodes[0].shadowRoot.innerHtml).toEqual(
'<style>.hello{}</style><div log="SIMPLE">Simple!</div>'
);
- $rootScope.$digest();
+ $rootScope.apply();
// Note: There is no ordering. It is who ever comes off the wire first!
expect(log.result()).toEqual('LOG; SIMPLE');
})));
it('should load a CSS file with a \$template', async(inject((Http $http,
- Compiler $compile, Scope $rootScope, Injector injector, MockHttpBackend backend) {
+ Compiler $compile, Scope $rootScope, Injector injector,
+ MockHttpBackend backend, DirectiveMap directives) {
var element = $('<div><inline-with-css log>ignore</inline-with-css><div>');
backend.expectGET('simple.css').respond('.hello{}');
- $compile(element)(injector, element);
+ $compile(element, directives)(injector, element);
backend.flush();
microLeap();
expect(renderedText(element)).toEqual('.hello{}inline!');
})));
+ it('should ignore CSS load errors ', async(inject((Http $http,
+ Compiler $compile, Scope $rootScope, Injector injector,
+ MockHttpBackend backend, DirectiveMap directives) {
+ var element = $('<div><inline-with-css log>ignore</inline-with-css><div>');
+ backend.expectGET('simple.css').respond(500, 'some error');
+ $compile(element, directives)(injector, element);
+
+ backend.flush();
+ microLeap();
+ expect(renderedText(element)).toEqual(
+ '/*\n'
+ 'HTTP 500: some error\n'
+ '*/\n'
+ 'inline!');
+ })));
+
it('should load a CSS with no template', async(inject((Http $http,
- Compiler $compile, Scope $rootScope, Injector injector, MockHttpBackend backend) {
+ Compiler $compile, Scope $rootScope, Injector injector,
+ MockHttpBackend backend, DirectiveMap directives) {
var element = $('<div><only-css log>ignore</only-css><div>');
backend.expectGET('simple.css').respond('.hello{}');
- $compile(element)(injector, element);
+ $compile(element, directives)(injector, element);
backend.flush();
microLeap();
@@ -165,12 +186,14 @@ main() => describe('template url', () {
})));
it('should load the CSS before the template is loaded', async(inject((Http $http,
- Compiler $compile, Scope $rootScope, Injector injector, MockHttpBackend backend) {
- backend.expectGET('simple.css').respond('.hello{}');
- backend.expectGET('simple.html').respond('<div>Simple!</div>');
+ Compiler $compile, Scope $rootScope, Injector injector,
+ MockHttpBackend backend, DirectiveMap directives) {
+ backend
+ ..expectGET('simple.css').respond('.hello{}')
+ ..expectGET('simple.html').respond('<div>Simple!</div>');
var element = $('<html-and-css>ignore</html-and-css>');
- $compile(element)(injector, element);
+ $compile(element, directives)(injector, element);
backend.flush();
microLeap();
@@ -180,19 +203,21 @@ main() => describe('template url', () {
describe('multiple css loading', () {
beforeEach(module((Module module) {
- module.type(LogAttrDirective);
- module.type(HtmlAndMultipleCssComponent);
+ module
+ ..type(LogAttrDirective)
+ ..type(HtmlAndMultipleCssComponent);
}));
it('should load multiple CSS files into a style', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Logger log, Injector injector,
- MockHttpBackend backend) {
- backend.expectGET('simple.css').respond('.hello{}');
- backend.expectGET('another.css').respond('.world{}');
- backend.expectGET('simple.html').respond('<div log="SIMPLE">Simple!</div>');
+ MockHttpBackend backend, DirectiveMap directives) {
+ backend
+ ..expectGET('simple.css').respond('.hello{}')
+ ..expectGET('another.css').respond('.world{}')
+ ..expectGET('simple.html').respond('<div log="SIMPLE">Simple!</div>');
var element = $('<div><html-and-css log>ignore</html-and-css><div>');
- $compile(element)(injector, element);
+ $compile(element, directives)(injector, element);
backend.flush();
microLeap();
@@ -201,7 +226,7 @@ main() => describe('template url', () {
expect(element[0].nodes[0].shadowRoot.innerHtml).toEqual(
'<style>.hello{}.world{}</style><div log="SIMPLE">Simple!</div>'
);
- $rootScope.$digest();
+ $rootScope.apply();
// Note: There is no ordering. It is who ever comes off the wire first!
expect(log.result()).toEqual('LOG; SIMPLE');
})));

Powered by Google App Engine
This is Rietveld 408576698