-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.ts
25 lines (25 loc) · 1020 Bytes
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { build } from 'esbuild'
import { dirname, join } from 'node:path'
import { test } from 'uvu'
import { equal } from 'uvu/assert'
import esmfile_ from './index.js'
test('esmfile', async ()=>{
// stdin config does not with onLoad
// see https://github.com/evanw/esbuild/issues/720
const dir = dirname(new URL(import.meta.url).pathname)
const no_color_svg = await build({
entryPoints: [join(dir, './_fixtures/index.svg.file.ts')],
plugins: [esmfile_()],
write: false,
}).then(result=>new TextDecoder().decode(result.outputFiles[0].contents))
const green_svg = await build({
entryPoints: [join(dir, './_fixtures/index.svg.file.ts?stroke=green')],
plugins: [esmfile_()],
write: false,
}).then(result=>new TextDecoder().decode(result.outputFiles[0].contents))
equal(no_color_svg.includes('stroke="currentColor"'), true)
equal(no_color_svg.includes('stroke="green"'), false)
equal(green_svg.includes('stroke="currentColor"'), false)
equal(green_svg.includes('stroke="green"'), true)
})
test.run()