-
Notifications
You must be signed in to change notification settings - Fork 14
/
test.js
45 lines (37 loc) · 1.32 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
34
35
36
37
38
39
40
41
42
43
44
45
import path from 'path';
import del from 'del';
import nock from 'nock';
import pathExists from 'path-exists';
import tempfile from 'tempfile';
import test from 'ava';
import m from '.';
test.beforeEach(t => {
t.context.tmp = tempfile();
});
test.afterEach(async t => {
await del(t.context.tmp, {force: true});
});
test('download and build source', async t => {
nock('http://foo.com')
.get('/gifsicle.tar.gz')
.replyWithFile(200, path.join(__dirname, 'fixtures', 'test.tar.gz'));
await m.url('http://foo.com/gifsicle.tar.gz', [
'autoreconf -ivf',
`./configure --disable-gifview --disable-gifdiff --prefix="${t.context.tmp}" --bindir="${t.context.tmp}"`,
'make install'
]);
t.true(await pathExists(path.join(t.context.tmp, 'gifsicle')));
});
test('build source from existing archive', async t => {
await m.file(path.join(__dirname, 'fixtures', 'test.tar.gz'), [
'autoreconf -ivf',
`./configure --disable-gifview --disable-gifdiff --prefix="${t.context.tmp}" --bindir="${t.context.tmp}"`,
'make install'
]);
t.true(await pathExists(path.join(t.context.tmp, 'gifsicle')));
});
test('accepts a string', async t => {
await t.throws(m.directory([]), 'Expected a `string`, got `object`');
await t.throws(m.file([]), 'Expected a `string`, got `object`');
await t.throws(m.url([]), 'Expected a `string`, got `object`');
});