-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathcivet.test.ts
53 lines (40 loc) · 1.58 KB
/
civet.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { civet } from '../../src';
import { getFixtureContent, preprocess } from '../utils';
const EXPECTED_SCRIPT = getFixtureContent('script.js');
describe(`processor - civet`, () => {
it('should ignore other languages', async () => {
const template = `<script lang="potato">🥔</script>`;
const options = {};
const preprocessed = await preprocess(template, [civet(options)]);
expect(preprocessed.toString?.()).toBe(template);
});
it('should leave other languages untouched', async () => {
const template = `<script lang="potato">🥔</script>`;
const options = {
stripIndent: true,
prependData: '/* potato */',
};
const preprocessed = await preprocess(template, [civet(options)]);
expect(preprocessed.toString?.()).toBe(template);
});
it('should support external src files', async () => {
const template = `<script src="./fixtures/script.civet"></script>`;
const options = {
tsconfigFile: false,
compilerOptions: { module: 'es2015' },
prependData: '// potato',
};
const preprocessed = await preprocess(template, [civet(options)]);
expect(preprocessed.toString?.()).toContain(EXPECTED_SCRIPT);
});
it('should support prepended data', async () => {
const template = `<script src="./fixtures/script.civet"></script>`;
const options = {
tsconfigFile: false,
compilerOptions: { module: 'es2015' },
prependData: '### potato ###',
};
const preprocessed = await preprocess(template, [civet(options)]);
expect(preprocessed.toString?.()).toContain('/* potato */');
});
});