Skip to content

Commit

Permalink
Move postcss test over to static build
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed Feb 28, 2022
1 parent ee214d2 commit 86f382e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 6 additions & 1 deletion packages/astro/test/fixtures/postcss/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import JSX from '../components/Solid.jsx';
import Svelte from '../components/Svelte.svelte';
import Vue from '../components/Vue.vue';
---
<html>
<head>
<link rel="stylesheet" type="text/css" href="/global.css">
<link rel="stylesheet" type="text/css" href={Astro.resolve('../styles/linked.css')}>
<style>
@import '../styles/linked.css';
</style>
<style>
.astro-page {
appearance: none;
Expand All @@ -22,3 +25,5 @@ import Vue from '../components/Vue.vue';
<Vue />
</div>
</body>

</html>
7 changes: 1 addition & 6 deletions packages/astro/test/postcss.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ describe('PostCSS', () => {
fixture = await loadFixture({
projectRoot: './fixtures/postcss',
renderers: ['@astrojs/renderer-solid', '@astrojs/renderer-svelte', '@astrojs/renderer-vue'],
buildOptions: { legacyBuild: true } // TODO make this test work without legacyBuild
});
await fixture.build();

// get bundled CSS (will be hashed, hence DOM query)
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
const bundledCSSHREF = $('link[rel=stylesheet][href^=./assets/]').attr('href');
const bundledCSSHREF = $('link[rel=stylesheet][href^=/assets/]').attr('href');
bundledCSS = await fixture.readFile(bundledCSSHREF.replace(/^\/?/, '/'));
});

Expand All @@ -31,10 +30,6 @@ describe('PostCSS', () => {
expect(bundledCSS).to.match(new RegExp(`.astro-component.astro-[^{]+${PREFIXED_CSS}`));
});

it('works in <link>', () => {
expect(bundledCSS).to.match(new RegExp(`.a-n${PREFIXED_CSS}`));
});

it('works in JSX', () => {
expect(bundledCSS).to.match(new RegExp(`.solid${PREFIXED_CSS}`));
});
Expand Down

0 comments on commit 86f382e

Please sign in to comment.