Skip to content

Commit e379f5a

Browse files
committed
failing test for #808
1 parent 57efb03 commit e379f5a

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<p class="shouty">this component will never be rendered</p>
2+
3+
<style>
4+
p {
5+
color: goldenrod;
6+
}
7+
</style>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as assert from 'uvu/assert';
2+
3+
/** @type {import('test').TestMaker} */
4+
export default function (test, is_dev) {
5+
test('only includes CSS for rendered components', '/styles', async ({ page }) => {
6+
const style = await page.innerHTML('style[amp-custom]');
7+
8+
console.log(style);
9+
10+
assert.ok(style.includes('turquoise'), 'Rendered styles are included');
11+
assert.ok(style.includes('uppercase'), 'Imported styles are included');
12+
assert.ok(!style.includes('goldenrod'), 'Unrendered styles are omitted');
13+
});
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.shouty {
2+
text-transform: uppercase;
3+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script>
2+
import { amp } from '$app/env';
3+
import Unused from './Unused.svelte';
4+
import './imported.css';
5+
</script>
6+
7+
{#if amp}
8+
<p class="shouty">this text is rendered</p>
9+
{:else}
10+
<Unused/>
11+
{/if}
12+
13+
14+
<style>
15+
p {
16+
color: turquoise;
17+
}
18+
</style>

0 commit comments

Comments
 (0)