-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.js
29 lines (23 loc) · 790 Bytes
/
test.js
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
import {Buffer} from 'node:buffer';
import test from 'ava';
import Vinyl from 'vinyl';
import {pEvent} from 'p-event';
import gulpJsvalidate from './index.js';
test('main', async t => {
const stream = gulpJsvalidate({module: false});
const errorPromise = pEvent(stream);
stream.end(new Vinyl({
path: import.meta.url,
contents: Buffer.from('const foo = \'bar;\nlet undefinedVariable;undefinedVariable ??= \'Hello\';'),
}));
await t.throwsAsync(errorPromise, {message: /Unterminated string constant/});
});
test('supports `import`', async t => {
const stream = gulpJsvalidate();
const errorPromise = pEvent(stream, 'data');
stream.end(new Vinyl({
path: import.meta.url,
contents: Buffer.from('import foo from \'foo\';'),
}));
await t.notThrowsAsync(errorPromise);
});