Skip to content

Commit 90c9dd1

Browse files
committed
use extract-css flag instead of changing expectations
1 parent 7d846ba commit 90c9dd1

File tree

10 files changed

+76
-40
lines changed

10 files changed

+76
-40
lines changed

tests/e2e/tests/build/scripts-array.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,25 @@ export default function () {
2828
];
2929
app['styles'] = [{ input: 'common-entry-style.css', output: 'common-entry' }];
3030
}))
31-
.then(() => ng('build'))
31+
.then(() => ng('build', '--extract-css'))
3232
// files were created successfully
3333
.then(() => expectFileToMatch('dist/scripts.bundle.js', 'string-script'))
3434
.then(() => expectFileToMatch('dist/scripts.bundle.js', 'input-script'))
3535
.then(() => expectFileToMatch('dist/lazy-script.bundle.js', 'lazy-script'))
3636
.then(() => expectFileToMatch('dist/renamed-script.bundle.js', 'pre-rename-script'))
3737
.then(() => expectFileToMatch('dist/renamed-lazy-script.bundle.js', 'pre-rename-lazy-script'))
3838
.then(() => expectFileToMatch('dist/common-entry.bundle.js', 'common-entry-script'))
39-
.then(() => expectFileToMatch('dist/common-entry.bundle.js', '.common-entry-style'))
39+
.then(() => expectFileToMatch('dist/common-entry.bundle.css', '.common-entry-style'))
4040
// index.html lists the right bundles
41+
.then(() => expectFileToMatch('dist/index.html', oneLineTrim`
42+
<link href="common-entry.bundle.css" rel="stylesheet"/>
43+
`))
4144
.then(() => expectFileToMatch('dist/index.html', oneLineTrim`
4245
<script type="text/javascript" src="inline.bundle.js"></script>
4346
<script type="text/javascript" src="renamed-script.bundle.js"></script>
47+
<script type="text/javascript" src="common-entry.bundle.js"></script>
4448
<script type="text/javascript" src="scripts.bundle.js"></script>
4549
<script type="text/javascript" src="vendor.bundle.js"></script>
46-
<script type="text/javascript" src="common-entry.bundle.js"></script>
4750
<script type="text/javascript" src="main.bundle.js"></script>
4851
`));
4952
}

tests/e2e/tests/build/styles/css.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ export default function () {
2121
}
2222
}
2323
`})
24-
.then(() => ng('build'))
25-
.then(() => expectFileToMatch('dist/styles.bundle.js', /body.*{.*background-color: blue;.*}/))
26-
.then(() => expectFileToMatch('dist/styles.bundle.js', /p.*{.*background-color: red;.*}/))
27-
.then(() => expectFileToMatch('dist/main.bundle.js', /.outer.*.inner.*background:.*#[fF]+/));
24+
.then(() => ng('build', '--extract-css'))
25+
.then(() => expectFileToMatch('dist/styles.bundle.css',
26+
/body\s*{\s*background-color: blue;\s*}/))
27+
.then(() => expectFileToMatch('dist/styles.bundle.css',
28+
/p\s*{\s*background-color: red;\s*}/))
29+
.then(() => expectFileToMatch('dist/main.bundle.js', /.outer.*.inner.*background:\s*#[fF]+/));
2830
}

tests/e2e/tests/build/styles/extract-css.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,24 @@ export default function () {
5656
<script type="text/javascript" src="vendor.bundle.js"></script>
5757
<script type="text/javascript" src="common-entry.bundle.js"></script>
5858
<script type="text/javascript" src="main.bundle.js"></script>
59+
`))
60+
// also check when css isn't extracted
61+
.then(() => ng('build', '--no-extract-css'))
62+
// files were created successfully
63+
.then(() => expectFileToMatch('dist/styles.bundle.js', '.string-style'))
64+
.then(() => expectFileToMatch('dist/styles.bundle.js', '.input-style'))
65+
.then(() => expectFileToMatch('dist/lazy-style.bundle.js', '.lazy-style'))
66+
.then(() => expectFileToMatch('dist/renamed-style.bundle.js', '.pre-rename-style'))
67+
.then(() => expectFileToMatch('dist/renamed-lazy-style.bundle.js', '.pre-rename-lazy-style'))
68+
.then(() => expectFileToMatch('dist/common-entry.bundle.js', '.common-entry-style'))
69+
.then(() => expectFileToMatch('dist/common-entry.bundle.js', 'common-entry-script'))
70+
// index.html lists the right bundles
71+
.then(() => expectFileToMatch('dist/index.html', oneLineTrim`
72+
<script type="text/javascript" src="inline.bundle.js"></script>
73+
<script type="text/javascript" src="renamed-style.bundle.js"></script>
74+
<script type="text/javascript" src="styles.bundle.js"></script>
75+
<script type="text/javascript" src="vendor.bundle.js"></script>
76+
<script type="text/javascript" src="common-entry.bundle.js"></script>
77+
<script type="text/javascript" src="main.bundle.js"></script>
5978
`));
6079
}

tests/e2e/tests/build/styles/include-paths.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ export default function () {
4747
};
4848
}))
4949
// files were created successfully
50-
.then(() => ng('build'))
51-
.then(() => expectFileToMatch('dist/styles.bundle.js', /h1.*{.*color: red;.*}/))
50+
.then(() => ng('build', '--extract-css'))
51+
.then(() => expectFileToMatch('dist/styles.bundle.css', /h1\s*{\s*color: red;\s*}/))
5252
.then(() => expectFileToMatch('dist/main.bundle.js', /h2.*{.*color: red;.*}/))
53-
.then(() => expectFileToMatch('dist/styles.bundle.js', /h3.*{.*color: #008000;.*}/))
53+
.then(() => expectFileToMatch('dist/styles.bundle.css', /h3\s*{\s*color: #008000;\s*}/))
5454
.then(() => expectFileToMatch('dist/main.bundle.js', /h4.*{.*color: #008000;.*}/))
55-
.then(() => ng('build', '--aot'))
56-
.then(() => expectFileToMatch('dist/styles.bundle.js', /h1.*{.*color: red;.*}/))
55+
.then(() => ng('build', '--extract-css', '--aot'))
56+
.then(() => expectFileToMatch('dist/styles.bundle.css', /h1\s*{\s*color: red;\s*}/))
5757
.then(() => expectFileToMatch('dist/main.bundle.js', /h2.*{.*color: red;.*}/))
58-
.then(() => expectFileToMatch('dist/styles.bundle.js', /h3.*{.*color: #008000;.*}/))
58+
.then(() => expectFileToMatch('dist/styles.bundle.css', /h3\s*{\s*color: #008000;\s*}/))
5959
.then(() => expectFileToMatch('dist/main.bundle.js', /h4.*{.*color: #008000;.*}/));
6060
}

tests/e2e/tests/build/styles/less.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ export default function () {
3131
}))
3232
.then(() => replaceInFile('src/app/app.component.ts',
3333
'./app.component.css', './app.component.less'))
34-
.then(() => ng('build'))
35-
.then(() => expectFileToMatch('dist/styles.bundle.js', /body.*{.*background-color: blue;.*}/))
36-
.then(() => expectFileToMatch('dist/styles.bundle.js', /p.*{.*background-color: red;.*}/))
37-
.then(() => expectFileToMatch('dist/main.bundle.js', /.outer.*.inner.*background:.*#[fF]+/));
34+
.then(() => ng('build', '--extract-css'))
35+
.then(() => expectFileToMatch('dist/styles.bundle.css',
36+
/body\s*{\s*background-color: blue;\s*}/))
37+
.then(() => expectFileToMatch('dist/styles.bundle.css',
38+
/p\s*{\s*background-color: red;\s*}/))
39+
.then(() => expectFileToMatch('dist/main.bundle.js', /.outer.*.inner.*background:\s*#[fF]+/));
3840
}

tests/e2e/tests/build/styles/loaders.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export default function () {
3232
}))
3333
.then(() => replaceInFile('src/app/app.component.ts',
3434
'./app.component.css', './app.component.scss'))
35-
.then(() => ng('build', '--extract-css'))
36-
.then(() => expectToFail(() => expectFileToMatch('dist/styles.bundle.js', /exports/)))
35+
.then(() => ng('build'))
36+
.then(() => expectToFail(() => expectFileToMatch('dist/styles.bundle.css', /exports/)))
3737
.then(() => expectToFail(() => expectFileToMatch('dist/main.bundle.js',
3838
/".*module\.exports.*\.outer.*background:/)));
3939
}

tests/e2e/tests/build/styles/scss.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ export default function () {
3131
}))
3232
.then(() => replaceInFile('src/app/app.component.ts',
3333
'./app.component.css', './app.component.scss'))
34-
.then(() => ng('build'))
35-
.then(() => expectFileToMatch('dist/styles.bundle.js', /body.*{.*background-color: blue;.*}/))
36-
.then(() => expectFileToMatch('dist/styles.bundle.js', /p.*{.*background-color: red;.*}/))
37-
.then(() => expectFileToMatch('dist/main.bundle.js', /.outer.*.inner.*background:.*#[fF]+/));
34+
.then(() => ng('build', '--extract-css'))
35+
.then(() => expectFileToMatch('dist/styles.bundle.css',
36+
/body\s*{\s*background-color: blue;\s*}/))
37+
.then(() => expectFileToMatch('dist/styles.bundle.css',
38+
/p\s*{\s*background-color: red;\s*}/))
39+
.then(() => expectFileToMatch('dist/main.bundle.js', /.outer.*.inner.*background:\s*#[fF]+/));
3840
}

tests/e2e/tests/build/styles/styles-array.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { writeMultipleFiles, expectFileToMatch } from '../../../utils/fs';
1+
import {
2+
writeMultipleFiles,
3+
expectFileToMatch
4+
} from '../../../utils/fs';
25
import { ng } from '../../../utils/process';
36
import { updateJsonFile } from '../../../utils/project';
7+
import { expectToFail } from '../../../utils/utils';
48
import { oneLineTrim } from 'common-tags';
59

610
export default function () {
@@ -25,20 +29,23 @@ export default function () {
2529
];
2630
app['scripts'] = [{ input: 'common-entry-script.js', output: 'common-entry' }];
2731
}))
28-
.then(() => ng('build'))
32+
.then(() => ng('build', '--extract-css'))
2933
// files were created successfully
30-
.then(() => expectFileToMatch('dist/styles.bundle.js', '.string-style'))
31-
.then(() => expectFileToMatch('dist/styles.bundle.js', '.input-style'))
32-
.then(() => expectFileToMatch('dist/lazy-style.bundle.js', '.lazy-style'))
33-
.then(() => expectFileToMatch('dist/renamed-style.bundle.js', '.pre-rename-style'))
34-
.then(() => expectFileToMatch('dist/renamed-lazy-style.bundle.js', '.pre-rename-lazy-style'))
35-
.then(() => expectFileToMatch('dist/common-entry.bundle.js', '.common-entry-style'))
34+
.then(() => expectFileToMatch('dist/styles.bundle.css', '.string-style'))
35+
.then(() => expectFileToMatch('dist/styles.bundle.css', '.input-style'))
36+
.then(() => expectFileToMatch('dist/lazy-style.bundle.css', '.lazy-style'))
37+
.then(() => expectFileToMatch('dist/renamed-style.bundle.css', '.pre-rename-style'))
38+
.then(() => expectFileToMatch('dist/renamed-lazy-style.bundle.css', '.pre-rename-lazy-style'))
39+
.then(() => expectFileToMatch('dist/common-entry.bundle.css', '.common-entry-style'))
3640
.then(() => expectFileToMatch('dist/common-entry.bundle.js', 'common-entry-script'))
3741
// index.html lists the right bundles
42+
.then(() => expectFileToMatch('dist/index.html', oneLineTrim`
43+
<link href="renamed-style.bundle.css" rel="stylesheet"/>
44+
<link href="styles.bundle.css" rel="stylesheet"/>
45+
<link href="common-entry.bundle.css" rel="stylesheet"/>
46+
`))
3847
.then(() => expectFileToMatch('dist/index.html', oneLineTrim`
3948
<script type="text/javascript" src="inline.bundle.js"></script>
40-
<script type="text/javascript" src="renamed-style.bundle.js"></script>
41-
<script type="text/javascript" src="styles.bundle.js"></script>
4249
<script type="text/javascript" src="vendor.bundle.js"></script>
4350
<script type="text/javascript" src="common-entry.bundle.js"></script>
4451
<script type="text/javascript" src="main.bundle.js"></script>

tests/e2e/tests/build/styles/stylus.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ export default function () {
3131
}))
3232
.then(() => replaceInFile('src/app/app.component.ts',
3333
'./app.component.css', './app.component.styl'))
34-
.then(() => ng('build'))
35-
.then(() => expectFileToMatch('dist/styles.bundle.js', /body.*{.*background-color: #00f;.*}/))
36-
.then(() => expectFileToMatch('dist/styles.bundle.js', /p.*{.*background-color: #f00;.*}/))
37-
.then(() => expectFileToMatch('dist/main.bundle.js', /.outer.*.inner.*background:.*#[fF]+/));
34+
.then(() => ng('build', '--extract-css'))
35+
.then(() => expectFileToMatch('dist/styles.bundle.css',
36+
/body\s*{\s*background-color: #00f;\s*}/))
37+
.then(() => expectFileToMatch('dist/styles.bundle.css',
38+
/p\s*{\s*background-color: #f00;\s*}/))
39+
.then(() => expectFileToMatch('dist/main.bundle.js', /.outer.*.inner.*background:\s*#[fF]+/));
3840
}

tests/e2e/tests/third-party/bootstrap.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ export default function() {
1616
'../node_modules/bootstrap/dist/js/bootstrap.js'
1717
);
1818
}))
19-
.then(() => ng('build'))
19+
.then(() => ng('build', '--extract-css'))
2020
.then(() => expectFileToMatch('dist/scripts.bundle.js', '* jQuery JavaScript'))
2121
.then(() => expectFileToMatch('dist/scripts.bundle.js', '/*! tether '))
2222
.then(() => expectFileToMatch('dist/scripts.bundle.js', '* Bootstrap'))
23-
.then(() => expectFileToMatch('dist/styles.bundle.js', '* Bootstrap'))
23+
.then(() => expectFileToMatch('dist/styles.bundle.css', '* Bootstrap'))
2424
.then(() => expectFileToMatch('dist/index.html', oneLineTrim`
2525
<script type="text/javascript" src="inline.bundle.js"></script>
26-
<script type="text/javascript" src="styles.bundle.js"></script>
2726
<script type="text/javascript" src="scripts.bundle.js"></script>
2827
<script type="text/javascript" src="vendor.bundle.js"></script>
2928
<script type="text/javascript" src="main.bundle.js"></script>

0 commit comments

Comments
 (0)