forked from sindresorhus/gulp-zip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
51 lines (42 loc) · 1.08 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
46
47
48
49
50
51
'use strict';
var path = require('path');
var assert = require('assert');
var gutil = require('gulp-util');
var zip = require('./index');
it('should zip files', function (cb) {
var stream = zip('test.zip');
stream.on('data', function (file) {
assert.equal(path.normalize(file.path), path.join(__dirname, './fixture/test.zip'));
assert.equal(file.relative, 'test.zip');
assert(file.contents.length > 0);
cb();
});
stream.write(new gutil.File({
cwd: __dirname,
base: __dirname + '/fixture',
path: __dirname + '/fixture/fixture.txt',
contents: new Buffer('hello world'),
stat: {
mtime: new Date()
}
}));
stream.write(new gutil.File({
cwd: __dirname,
base: __dirname + '/fixture',
path: __dirname + '/fixture/fixture2.txt',
contents: new Buffer('hello world 2'),
stat: {
mtime: new Date()
}
}));
stream.end();
});
it('should not push empty files', function (cb) {
var stream = zip('test.zip');
stream.on('data', assert.bind(null, false));
stream.on('end', cb);
stream.write(new gutil.File({
path: __dirname + 'fixture.txt'
}));
stream.end();
});