@@ -15,7 +15,7 @@ import {IS_DART} from '../platform';
15
15
import { SpyXHR } from '../core/spies' ;
16
16
import { BaseException , WrappedException } from 'angular2/src/core/facade/exceptions' ;
17
17
18
- import { CONST_EXPR , isPresent } from 'angular2/src/core/facade/lang' ;
18
+ import { CONST_EXPR , isPresent , StringWrapper } from 'angular2/src/core/facade/lang' ;
19
19
import { PromiseWrapper , Promise } from 'angular2/src/core/facade/async' ;
20
20
import { evalModule } from './eval_module' ;
21
21
import { StyleCompiler } from 'angular2/src/compiler/style_compiler' ;
@@ -69,7 +69,7 @@ export function main() {
69
69
} ) ;
70
70
compiler . compileComponentRuntime ( comp ( styles , styleAbsUrls , encapsulation ) )
71
71
. then ( ( value ) => {
72
- expect ( value ) . toEqual ( expectedStyles ) ;
72
+ compareStyles ( value , expectedStyles ) ;
73
73
async . done ( ) ;
74
74
} ) ;
75
75
} ) ;
@@ -121,7 +121,7 @@ export function main() {
121
121
compiler . compileComponentCodeGen ( comp ( styles , styleAbsUrls , encapsulation ) ) ;
122
122
evalModule ( testableModule ( sourceModule . source ) , sourceModule . imports , null )
123
123
. then ( ( value ) => {
124
- expect ( value ) . toEqual ( expectedStyles ) ;
124
+ compareStyles ( value , expectedStyles ) ;
125
125
async . done ( ) ;
126
126
} ) ;
127
127
} ) ;
@@ -139,7 +139,8 @@ export function main() {
139
139
140
140
it ( 'should allow to import rules' ,
141
141
runTest ( [ 'div {color: red}' ] , [ IMPORT_ABS_MODULE_NAME ] , encapsulation ,
142
- [ 'div {color: red}' , 'span {color: blue}' ] ) ) ;
142
+ [ 'div {color: red}' , 'span {color: blue}' ] ) ,
143
+ 1000 ) ;
143
144
} ) ;
144
145
145
146
describe ( 'with shim' , ( ) => {
@@ -153,7 +154,8 @@ export function main() {
153
154
it ( 'should allow to import rules' ,
154
155
runTest (
155
156
[ 'div {color: red}' ] , [ IMPORT_ABS_MODULE_NAME ] , encapsulation ,
156
- [ 'div[_ngcontent-23] {\ncolor: red;\n}' , 'span[_ngcontent-23] {\ncolor: blue;\n}' ] ) ) ;
157
+ [ 'div[_ngcontent-23] {\ncolor: red;\n}' , 'span[_ngcontent-23] {\ncolor: blue;\n}' ] ) ,
158
+ 1000 ) ;
157
159
} ) ;
158
160
} ) ;
159
161
@@ -165,8 +167,9 @@ export function main() {
165
167
evalModule ( testableModule ( sourceModule . source ) ,
166
168
sourceModule . imports , null ) ) )
167
169
. then ( ( values ) => {
168
- expect ( values [ 0 ] ) . toEqual ( expectedStyles ) ;
169
- expect ( values [ 1 ] ) . toEqual ( expectedShimStyles ) ;
170
+ compareStyles ( values [ 0 ] , expectedStyles ) ;
171
+ compareStyles ( values [ 1 ] , expectedShimStyles ) ;
172
+
170
173
async . done ( ) ;
171
174
} ) ;
172
175
} ) ;
@@ -177,10 +180,12 @@ export function main() {
177
180
178
181
it ( 'should allow to import rules with relative paths' ,
179
182
runTest ( `div {color: red}@import ${ IMPORT_REL_MODULE_NAME } ;` ,
180
- [ 'div {color: red}' , 'span {color: blue}' ] , [
183
+ [ 'div {color: red}' , 'span {color: blue}' ] ,
184
+ [
181
185
'div[_ngcontent-%COMP%] {\ncolor: red;\n}' ,
182
186
'span[_ngcontent-%COMP%] {\ncolor: blue;\n}'
183
- ] ) ) ;
187
+ ] ) ,
188
+ 1000 ) ;
184
189
} ) ;
185
190
} ) ;
186
191
}
@@ -196,3 +201,11 @@ function testableModule(sourceModule: string) {
196
201
` ;
197
202
}
198
203
}
204
+
205
+ // Needed for Android browsers which add an extra space at the end of some lines
206
+ function compareStyles ( styles : string [ ] , expectedStyles : string [ ] ) {
207
+ expect ( styles . length ) . toEqual ( expectedStyles . length ) ;
208
+ for ( var i = 0 ; i < styles . length ; i ++ ) {
209
+ expect ( StringWrapper . replaceAll ( styles [ i ] , / \s + \n / g, '\n' ) ) . toEqual ( expectedStyles [ i ] ) ;
210
+ }
211
+ }
0 commit comments