Skip to content

Commit

Permalink
test: add some test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Jul 28, 2022
1 parent 8432015 commit b4dd144
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ exports[`parse positives > alias path 1`] = `"__variableDynamicImportRuntimeHelp
exports[`parse positives > basic 1`] = `"__variableDynamicImportRuntimeHelper((import.meta.glob(\\"./mods/*.js\\")), \`./mods/\${base}.js\`)"`;
exports[`parse positives > with ../ and itself 1`] = `"__variableDynamicImportRuntimeHelper((import.meta.glob(\\"../dynamicImportVar/*.js\\")), \`./\${name}.js\`)"`;
exports[`parse positives > with multi ../ and itself 1`] = `"__variableDynamicImportRuntimeHelper((import.meta.glob(\\"../../plugins/dynamicImportVar/*.js\\")), \`./\${name}.js\`)"`;
exports[`parse positives > with query raw 1`] = `"__variableDynamicImportRuntimeHelper((import.meta.glob(\\"./mods/*.js\\", {\\"as\\":\\"raw\\",\\"import\\":\\"*\\"})), \`./mods/\${base}.js\`)"`;
exports[`parse positives > with query url 1`] = `"__variableDynamicImportRuntimeHelper((import.meta.glob(\\"./mods/*.js\\")), \`./mods/\${base}.js\`)"`;
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ const __dirname = resolve(fileURLToPath(import.meta.url), '..')

async function run(input: string) {
const { glob, rawPattern } =
(await transformDynamicImport(input, resolve(__dirname, 'index.js'), (id) =>
id.replace('@', resolve(__dirname, './mods/'))
(await transformDynamicImport(
input,
resolve(__dirname, 'index.js'),
(id) => id.replace('@', resolve(__dirname, './mods/')),
__dirname
)) || {}
return `__variableDynamicImportRuntimeHelper(${glob}, \`${rawPattern}\`)`
}
Expand Down Expand Up @@ -37,4 +40,14 @@ describe('parse positives', () => {
it('? in url', async () => {
expect(await run('`./mo?ds/${base ?? foo}.js?raw`')).toMatchSnapshot()
})

it('with ../ and itself', async () => {
expect(await run('`../dynamicImportVar/${name}.js`')).toMatchSnapshot()
})

it('with multi ../ and itself', async () => {
expect(
await run('`../../plugins/dynamicImportVar/${name}.js`')
).toMatchSnapshot()
})
})
1 change: 1 addition & 0 deletions playground/headless-ui-vite-disclosure-error
Submodule headless-ui-vite-disclosure-error added at ca709e
1 change: 1 addition & 0 deletions playground/vite-sentry-repro
Submodule vite-sentry-repro added at d4cff9

0 comments on commit b4dd144

Please sign in to comment.