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 e2ff572
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions packages/astro/test/units/vite-plugin-astro/compile.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import * as assert from 'node:assert/strict';
import { describe, it, before } from 'node:test';
import { describe, it } from 'node:test';
import { pathToFileURL } from 'node:url';
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 e2ff572

Please sign in to comment.