Skip to content

Commit

Permalink
refactor vite-plugin-astro/compile.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
koyopro committed Jan 5, 2025
1 parent 3d58791 commit 95cff9b
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions packages/astro/test/units/vite-plugin-astro/compile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import { init, parse } from 'es-module-lexer';
import { resolveConfig } from 'vite';
import { compileAstro } from '../../../dist/vite-plugin-astro/compile.js';

let inlineConfig;
/**
* @param {string} source
* @param {string} id
*/
async function compile(source, id) {
async function compile(source, id, inlineConfig = {}) {
const viteConfig = await resolveConfig({ configFile: false, ...inlineConfig }, 'serve');
return await compileAstro({
compileProps: {
Expand All @@ -24,10 +23,6 @@ async function compile(source, id) {
}

describe('astro full compile', () => {
before(() => {
inlineConfig = {};
})

it('should compile a single file', async () => {
const result = await compile(`<h1>Hello World</h1>`, '/src/components/index.astro');
assert.ok(result.code);
Expand Down Expand Up @@ -86,10 +81,9 @@ using x = {}
});

it('should transform the syntax by esbuild.target', async () => {
inlineConfig = {
const result = await compile(code, '/src/components/index.astro', {
esbuild: { target: 'es2018' },
}
const result = await compile(code, '/src/components/index.astro');
});
assert.equal(result.code.includes('using x = {}'), false);
});
});
Expand Down

0 comments on commit 95cff9b

Please sign in to comment.