Skip to content

Commit 9c97690

Browse files
committed
fix(test): StyleCompiler tests failing in Android browsers
Closes angular#4351
1 parent 5f640c7 commit 9c97690

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

modules/angular2/test/compiler/style_compiler_spec.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export function main() {
120120
it('should compile plain css rules', inject([AsyncTestCompleter], (async) => {
121121
compile(['div {\ncolor: red;\n}', 'span {\ncolor: blue;\n}'], [], encapsulation)
122122
.then(styles => {
123-
expect(styles).toEqual([
123+
compareStyles(styles, [
124124
'div[_ngcontent-23] {\ncolor: red;\n}',
125125
'span[_ngcontent-23] {\ncolor: blue;\n}'
126126
]);
@@ -131,7 +131,7 @@ export function main() {
131131
it('should allow to import rules', inject([AsyncTestCompleter], (async) => {
132132
compile(['div {\ncolor: red;\n}'], [IMPORT_ABS_MODULE_NAME], encapsulation)
133133
.then(styles => {
134-
expect(styles).toEqual([
134+
compareStyles(styles, [
135135
'div[_ngcontent-23] {\ncolor: red;\n}',
136136
'span[_ngcontent-23] {\ncolor: blue;\n}'
137137
]);
@@ -142,7 +142,7 @@ export function main() {
142142
it('should allow to import rules transitively', inject([AsyncTestCompleter], (async) => {
143143
compile(['div {\ncolor: red;\n}'], [IMPORT_ABS_MODULE_NAME_WITH_IMPORT], encapsulation)
144144
.then(styles => {
145-
expect(styles).toEqual([
145+
compareStyles(styles, [
146146
'div[_ngcontent-23] {\ncolor: red;\n}',
147147
'a[_ngcontent-23] {\ncolor: green;\n}',
148148
'span[_ngcontent-23] {\ncolor: blue;\n}'
@@ -230,7 +230,7 @@ export function main() {
230230
expect(styles).toEqual(['div {color: red}', 'span {color: blue}']);
231231
async.done();
232232
});
233-
}));
233+
}), 1000);
234234
});
235235

236236
describe('with shim', () => {
@@ -239,7 +239,7 @@ export function main() {
239239
it('should compile plain css ruless', inject([AsyncTestCompleter], (async) => {
240240
compile(['div {\ncolor: red;\n}', 'span {\ncolor: blue;\n}'], [], encapsulation)
241241
.then(styles => {
242-
expect(styles).toEqual([
242+
compareStyles(styles, [
243243
'div[_ngcontent-23] {\ncolor: red;\n}',
244244
'span[_ngcontent-23] {\ncolor: blue;\n}'
245245
]);
@@ -250,18 +250,18 @@ export function main() {
250250
it('should allow to import rules', inject([AsyncTestCompleter], (async) => {
251251
compile(['div {color: red}'], [IMPORT_ABS_MODULE_NAME], encapsulation)
252252
.then(styles => {
253-
expect(styles).toEqual([
253+
compareStyles(styles, [
254254
'div[_ngcontent-23] {\ncolor: red;\n}',
255255
'span[_ngcontent-23] {\ncolor: blue;\n}'
256256
]);
257257
async.done();
258258
});
259-
}));
259+
}), 1000);
260260
});
261261
});
262262

263263
describe('compileStylesheetCodeGen', () => {
264-
function compile(style: string): Promise<string[]> {
264+
function compile(style: string): Promise<string[][]> {
265265
var sourceModules = compiler.compileStylesheetCodeGen(MODULE_NAME, style);
266266
return PromiseWrapper.all(sourceModules.map(sourceModule => {
267267
var sourceWithImports = testableModule(sourceModule).getSourceWithImports();
@@ -272,9 +272,10 @@ export function main() {
272272
it('should compile plain css rules', inject([AsyncTestCompleter], (async) => {
273273
compile('div {color: red;}')
274274
.then(stylesAndShimStyles => {
275-
expect(stylesAndShimStyles)
276-
.toEqual(
277-
[['div {color: red;}'], ['div[_ngcontent-%COMP%] {\ncolor: red;\n}']]);
275+
var expected =
276+
[['div {color: red;}'], ['div[_ngcontent-%COMP%] {\ncolor: red;\n}']];
277+
compareStyles(stylesAndShimStyles[0], expected[0]);
278+
compareStyles(stylesAndShimStyles[1], expected[1]);
278279
async.done();
279280
});
280281
}));
@@ -283,14 +284,15 @@ export function main() {
283284
inject([AsyncTestCompleter], (async) => {
284285
compile(`div {color: red}@import ${IMPORT_REL_MODULE_NAME};`)
285286
.then(stylesAndShimStyles => {
286-
expect(stylesAndShimStyles)
287-
.toEqual([
288-
['div {color: red}', 'span {color: blue}'],
289-
[
290-
'div[_ngcontent-%COMP%] {\ncolor: red;\n}',
291-
'span[_ngcontent-%COMP%] {\ncolor: blue;\n}'
292-
]
293-
]);
287+
var expected = [
288+
['div {color: red}', 'span {color: blue}'],
289+
[
290+
'div[_ngcontent-%COMP%] {\ncolor: red;\n}',
291+
'span[_ngcontent-%COMP%] {\ncolor: blue;\n}'
292+
]
293+
];
294+
compareStyles(stylesAndShimStyles[0], expected[0]);
295+
compareStyles(stylesAndShimStyles[1], expected[1]);
294296
async.done();
295297
});
296298
}));

0 commit comments

Comments
 (0)