Skip to content

Commit

Permalink
test(@angular-devkit/build-angular): update tests to match critters 0…
Browse files Browse the repository at this point in the history
….0.11 output
  • Loading branch information
alan-agius4 authored and clydin committed Oct 20, 2021
1 parent 94836e0 commit fc3780e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ describe('AppShell Builder', () => {
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));

expect(content).toContain('app-shell works!');
expect(content).toContain('p{color:#000;}');
expect(content).toContain('p{color:#000}');
expect(content).toMatch(
/<link rel="stylesheet" href="styles\.[a-z0-9]+\.css" media="print" onload="this\.media='all'">/,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
.content.toContain(
`<link rel="stylesheet" href="styles.css" media="print" onload="this.media='all'">`,
);
harness.expectFile('dist/index.html').content.toContain(`body{color:#000;}`);
harness.expectFile('dist/index.html').content.toContain(`body{color:#000}`);
});

it(`should extract critical css when 'optimization' is unset`, async () => {
Expand All @@ -55,7 +55,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
.content.toContain(
`<link rel="stylesheet" href="styles.css" media="print" onload="this.media='all'">`,
);
harness.expectFile('dist/index.html').content.toContain(`body{color:#000;}`);
harness.expectFile('dist/index.html').content.toContain(`body{color:#000}`);
});

it(`should extract critical css when 'optimization' is true`, async () => {
Expand All @@ -73,7 +73,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
.content.toContain(
`<link rel="stylesheet" href="styles.css" media="print" onload="this.media='all'">`,
);
harness.expectFile('dist/index.html').content.toContain(`body{color:#000;}`);
harness.expectFile('dist/index.html').content.toContain(`body{color:#000}`);
});

it(`should not extract critical css when 'optimization' is false`, async () => {
Expand Down Expand Up @@ -131,7 +131,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
.content.toContain(
`<link rel="stylesheet" href="http://cdn.com/styles.css" media="print" onload="this.media='all'">`,
);
harness.expectFile('dist/index.html').content.toContain(`body{color:#000;}`);
harness.expectFile('dist/index.html').content.toContain(`body{color:#000}`);
});

it(`should extract critical css when using '@media all {}' and 'minify' is set to true`, async () => {
Expand All @@ -157,7 +157,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
.content.toContain(
`<link rel="stylesheet" href="styles.css" media="print" onload="this.media='all'">`,
);
harness.expectFile('dist/index.html').content.toContain(`body{color:#000;}`);
harness.expectFile('dist/index.html').content.toContain(`body{color:#000}`);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describeBuilder(serveWebpackBrowser, DEV_SERVER_BUILDER_INFO, (harness) => {
const { result, response } = await executeOnceAndFetch(harness, '/');

expect(result?.success).toBeTrue();
expect(await response?.text()).toContain('body{color:#000;}');
expect(await response?.text()).toContain('body{color:#000}');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,10 @@ describe('InlineCriticalCssProcessor', () => {
);
expect(content).not.toContain('color: blue');
expect(tags.stripIndents`${content}`).toContain(tags.stripIndents`
<style>body {
margin: 0;
}
html {
color: white;
}</style>
`);
<style>
body { margin: 0; }
html { color: white; }
</style>`);
});

it('should inline critical css when using deployUrl', async () => {
Expand All @@ -85,14 +81,10 @@ describe('InlineCriticalCssProcessor', () => {
`<link href="http://cdn.com/theme.css" rel="stylesheet" media="print" onload="this.media='all'">`,
);
expect(tags.stripIndents`${content}`).toContain(tags.stripIndents`
<style>body {
margin: 0;
}
html {
color: white;
}</style>
`);
<style>
body { margin: 0; }
html { color: white; }
</style>`);
});

it('should compress inline critical css when minify is enabled', async () => {
Expand All @@ -111,6 +103,6 @@ describe('InlineCriticalCssProcessor', () => {
expect(content).toContain(
`<link href="theme.css" rel="stylesheet" media="print" onload="this.media='all'">`,
);
expect(content).toContain('<style>body{margin:0;}html{color:white;}</style>');
expect(content).toContain('<style>body{margin:0}html{color:white}</style>');
});
});

0 comments on commit fc3780e

Please sign in to comment.