@@ -22,10 +22,6 @@ class HtmlAndCssComponent {
22
22
class InlineWithCssComponent {
23
23
static String $template = '<div>inline!</div>' ;
24
24
static String $cssUrl = 'simple.css' ;
25
- static TemplateLoader lastTemplateLoader;
26
- InlineWithCssComponent (TemplateLoader templateLoader) {
27
- lastTemplateLoader = templateLoader;
28
- }
29
25
}
30
26
31
27
class OnlyCssComponent {
@@ -79,55 +75,58 @@ main() {
79
75
$http.assertAllGetsCalled ();
80
76
}));
81
77
82
- it ('should replace element with template from url' , inject ((MockHttp $http, Compiler $compile, Scope $rootScope, Log log, Injector injector) {
78
+ it ('should replace element with template from url' , async ( inject ((MockHttp $http, Compiler $compile, Scope $rootScope, Log log, Injector injector) {
83
79
$http.expectGET ('simple.html' , '<div log="SIMPLE">Simple!</div>' );
84
80
85
81
var element = $('<div><simple-url log>ignore</simple-url><div>' );
86
82
$compile (element)(injector, element);
87
83
88
- $http.flush ().then (expectAsync1 ((data) {
89
- expect (renderedText (element)).toEqual ('Simple!' );
90
- // Note: There is no ordering. It is who ever comes off the wire first!
91
- expect (log.result ()).toEqual ('LOG; SIMPLE' );
92
- }));
93
- }));
84
+ $http.flush ();
85
+ nextTurn (true );
94
86
95
- it ('should load template from URL once' , inject ((MockHttp $http, Compiler $compile, Scope $rootScope, Log log, Injector injector) {
87
+ expect (renderedText (element)).toEqual ('Simple!' );
88
+ // Note: There is no ordering. It is who ever comes off the wire first!
89
+ expect (log.result ()).toEqual ('LOG; SIMPLE' );
90
+ })));
91
+
92
+ it ('should load template from URL once' , async (inject ((MockHttp $http, Compiler $compile, Scope $rootScope, Log log, Injector injector) {
96
93
$http.expectGET ('simple.html' , '<div log="SIMPLE">Simple!</div>' , times: 2 );
97
94
98
95
var element = $('<div><simple-url log>ignore</simple-url><simple-url log>ignore</simple-url><div>' );
99
96
$compile (element)(injector, element);
100
97
101
- $http.flush ().then (expectAsync1 ((data) {
102
- expect (renderedText (element)).toEqual ('Simple!Simple!' );
103
- // Note: There is no ordering. It is who ever comes off the wire first!
104
- expect (log.result ()).toEqual ('LOG; LOG; SIMPLE; SIMPLE' );
105
- }));
106
- }));
98
+ $http.flush ();
99
+ nextTurn (true );
107
100
108
- it ('should load a CSS file into a style' , inject ((MockHttp $http, Compiler $compile, Scope $rootScope, Log log, Injector injector) {
101
+ expect (renderedText (element)).toEqual ('Simple!Simple!' );
102
+ // Note: There is no ordering. It is who ever comes off the wire first!
103
+ expect (log.result ()).toEqual ('LOG; LOG; SIMPLE; SIMPLE' );
104
+ })));
105
+
106
+ it ('should load a CSS file into a style' , async (inject ((MockHttp $http, Compiler $compile, Scope $rootScope, Log log, Injector injector) {
109
107
$http.expectGET ('simple.html' , '<div log="SIMPLE">Simple!</div>' );
110
108
111
109
var element = $('<div><html-and-css log>ignore</html-and-css><div>' );
112
110
$compile (element)(injector, element);
113
111
114
- $http.flush ().then (expectAsync1 ((data) {
115
- expect (renderedText (element)).toEqual ('@import "simple.css"Simple!' );
116
- expect (element[0 ].nodes[0 ].shadowRoot.innerHtml).toEqual (
117
- '<style>@import "simple.css"</style><div log="SIMPLE">Simple!</div>'
118
- );
119
- // Note: There is no ordering. It is who ever comes off the wire first!
120
- expect (log.result ()).toEqual ('LOG; SIMPLE' );
121
- }));
122
- }));
112
+ $http.flush ();
113
+ nextTurn (true );
123
114
124
- it ('should load a CSS file with a \$ template' , inject ((Compiler $compile, Scope $rootScope, Injector injector) {
115
+ expect (renderedText (element)).toEqual ('@import "simple.css"Simple!' );
116
+ expect (element[0 ].nodes[0 ].shadowRoot.innerHtml).toEqual (
117
+ '<style>@import "simple.css"</style><div log="SIMPLE">Simple!</div>'
118
+ );
119
+ // Note: There is no ordering. It is who ever comes off the wire first!
120
+ expect (log.result ()).toEqual ('LOG; SIMPLE' );
121
+ })));
122
+
123
+ it ('should load a CSS file with a \$ template' , async (inject ((Compiler $compile, Scope $rootScope, Injector injector) {
125
124
var element = $('<div><inline-with-css log>ignore</inline-with-css><div>' );
126
125
$compile (element)(injector, element);
127
- InlineWithCssComponent .lastTemplateLoader.template. then ( expectAsync1 ((_) {
128
- expect ( renderedText (element)). toEqual ( '@import "simple.css"inline!' );
129
- }) );
130
- }));
126
+
127
+ nextTurn ( true );
128
+ expect ( renderedText (element)). toEqual ( '@import "simple.css"inline!' );
129
+ }))) ;
131
130
132
131
it ('should load a CSS with no template' , inject ((Compiler $compile, Scope $rootScope, Injector injector) {
133
132
var element = $('<div><only-css log>ignore</only-css><div>' );
@@ -136,7 +135,7 @@ main() {
136
135
expect (renderedText (element)).toEqual ('@import "simple.css"' );
137
136
}));
138
137
139
- it ('should load the CSS before the template is loaded' , inject ((MockHttp $http, Compiler $compile, Scope $rootScope, Injector injector) {
138
+ it ('should load the CSS before the template is loaded' , async ( inject ((MockHttp $http, Compiler $compile, Scope $rootScope, Injector injector) {
140
139
$http.expectGET ('simple.html' , '<div>Simple!</div>' );
141
140
142
141
var element = $('<html-and-css>ignore</html-and-css>' );
@@ -145,10 +144,8 @@ main() {
145
144
// The HTML is not loaded yet, but the CSS @import should be in the DOM.
146
145
expect (renderedText (element)).toEqual ('@import "simple.css"' );
147
146
148
- $http.flush ().then (expectAsync1 ((data) {
149
- expect (renderedText (element)).toEqual ('@import "simple.css"Simple!' );
150
- }));
151
- }));
147
+ nextTurn (true );
148
+ expect (renderedText (element)).toEqual ('@import "simple.css"Simple!' );
149
+ })));
152
150
});
153
151
}
154
-
0 commit comments