-
Notifications
You must be signed in to change notification settings - Fork 1
/
svgx.spec.mjs
31 lines (23 loc) · 919 Bytes
/
svgx.spec.mjs
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
26
27
28
29
30
31
import assert from 'node:assert/strict';
import { pathToFileURL } from 'node:url';
import { describe, it } from 'node:test';
import { nextLoad } from './nextLoad.fixture.mjs';
import { load } from './svgx.mjs';
describe('SVGX loader', { concurrency: true }, () => {
describe('load', () => {
it('should ignore files that aren’t SVG', async () => {
const result = await load(pathToFileURL('./fixture.ext'), {}, nextLoad);
assert.deepEqual(result, {
format: 'unknown',
source: '',
});
});
it('should transpile the SVG to a JSX moduele', async () => {
const fileUrl = pathToFileURL('./fixture.svg');
const result = await load(fileUrl, { format: 'jsx' }, nextLoad);
const { source } = await nextLoad(fileUrl, { format: 'jsx' });
assert.equal(result.format, 'module');
assert.equal(result.source, `export default function Fixture() { return (\n${source}); }`);
});
});
});