-
Notifications
You must be signed in to change notification settings - Fork 11
/
test.js
33 lines (25 loc) · 1.09 KB
/
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
import path from 'path';
import test from 'ava';
import execa from 'execa';
import tempy from 'tempy';
import pathExists from 'path-exists';
test.beforeEach(t => {
t.context.tmp = tempy.file();
});
test('error', async t => {
await t.throwsAsync(() => execa('./cli.js'), /Please provide an input file/);
await t.throwsAsync(() => execa('./cli.js', ['fixtures/icon.png']), /Please provide at least one platform/);
});
test('png input', async t => {
await execa('./cli.js', ['fixtures/icon.png', '-p', 'android', '-o', t.context.tmp]);
t.true(pathExists.sync(path.join(t.context.tmp, 'mipmap-hdpi/icon.png')));
});
test('svg input', async t => {
await execa('./cli.js', ['fixtures/icon.svg', '-p', 'android', '-o', t.context.tmp]);
t.true(pathExists.sync(path.join(t.context.tmp, 'mipmap-hdpi/icon.png')));
});
test('multi platform', async t => {
await execa('./cli.js', ['fixtures/icon.png', '-p', 'android', '-p', 'ios', '-o', t.context.tmp]);
t.true(pathExists.sync(path.join(t.context.tmp, 'ios/icon.png')));
t.true(pathExists.sync(path.join(t.context.tmp, 'android/mipmap-hdpi/icon.png')));
});