Skip to content

Commit

Permalink
Moves asset tests to the static build
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed Feb 28, 2022
1 parent d19a370 commit ee214d2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
12 changes: 8 additions & 4 deletions packages/astro/test/astro-scripts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ describe('Scripts (hoisted and not)', () => {
before(async () => {
fixture = await loadFixture({
projectRoot: './fixtures/astro-scripts/',
buildOptions: { legacyBuild: true } // TODO make this test work without legacyBuild
vite: {
build: {
assetsInlineLimit: 0
}
}
});
await fixture.build();
});
Expand Down Expand Up @@ -41,8 +45,8 @@ describe('Scripts (hoisted and not)', () => {
// test 2: attr removed
expect($('script').attr('data-astro')).to.equal(undefined);

let entryURL = path.join('inline', $('script').attr('src'));
let inlineEntryJS = await fixture.readFile(entryURL);
const entryURL = $('script').attr('src');
const inlineEntryJS = await fixture.readFile(entryURL);

// test 3: the JS exists
expect(inlineEntryJS).to.be.ok;
Expand All @@ -56,7 +60,7 @@ describe('Scripts (hoisted and not)', () => {
expect($('script')).to.have.lengthOf(2);

let el = $('script').get(1);
let entryURL = path.join('external', $(el).attr('src'));
let entryURL = $(el).attr('src');
let externalEntryJS = await fixture.readFile(entryURL);

// test 2: the JS exists
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<script src={Astro.resolve("../scripts/no_hoist_nonmodule.js")}></script>
---
import url from "../scripts/no_hoist_nonmodule.js?url"
---
<script src={url}></script>
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<script type="module" src={Astro.resolve("../scripts/no_hoist_module.js")}></script>
---
import url from '../scripts/no_hoist_module.js?url';
---
<script type="module" src={url}></script>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<script hoist type="module" src={Astro.resolve("../scripts/something.js")}></script>
<script hoist type="module" src="../scripts/something.js"></script>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<script hoist type="module" src={Astro.resolve("../scripts/another_external.js")}></script>
<script hoist type="module" src="../scripts/another_external.js"></script>

0 comments on commit ee214d2

Please sign in to comment.