forked from tannerhodges/gulp-zorrosvg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
37 lines (28 loc) · 921 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
30
31
32
33
34
35
36
37
import fs from 'fs';
import getStream from 'get-stream';
import gutil from 'gulp-util';
import path from 'path';
import pify from 'pify';
import test from 'ava';
import zorroSvg from './';
const fsPromise = pify(fs);
const createFixture = async () => {
const buffer = await fsPromise.readFile('test/water.png');
const stream = zorroSvg();
stream.end(new gutil.File({
path: path.join(__dirname, 'test/water.png'),
contents: buffer
}));
return {buffer, stream};
};
test('generate alpha masks', async (t) => {
const {buffer, stream} = await createFixture();
const file = await getStream.array(stream);
t.true(file[0].contents.length < buffer.length);
});
test('skip unsupported images', async (t) => {
const stream = zorroSvg();
stream.end(new gutil.File({path: path.join(__dirname, 'test/water.jpg')}));
const file = await getStream.array(stream);
t.is(file[0].contents, null);
});