-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
test.js
29 lines (23 loc) · 822 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 stripDebug from './index.js';
test('strips debugging statements', async t => {
const stream = stripDebug();
const promise = pEvent(stream, 'data');
stream.end(new Vinyl({
contents: Buffer.from('function test(){const x = a ?? b; debugger;}'),
}));
const file = await promise;
t.is(file.contents.toString(), 'function test() {\n const x = a ?? b;\n}');
});
test('strips `console.log()` statements', async t => {
const stream = stripDebug();
const promise = pEvent(stream, 'data');
stream.end(new Vinyl({
contents: Buffer.from('function test(){console.log(...colors);}'),
}));
const file = await promise;
t.is(file.contents.toString(), 'function test() {\n void 0;\n}');
});