-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
68 lines (59 loc) · 2.06 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var path = require('path');
var assert = require('assert');
var concatStream = require('concat-stream');
var gulp = require('gulp');
var processIfModified = require('.');
var fs = require('fs')
describe('gulp-changed-in-place', function () {
if (fs.existsSync('./cache/.cache-default.json')) {
fs.unlinkSync('./cache/.cache-default.json');
}
describe('When comparing by sha1 hash', function () {
it('Should passthrough all files on first run (no cache)', function (done) {
gulp.src('test_assets/*')
.pipe(processIfModified())
.pipe(concatStream(function (buf) {
assert.equal(2, buf.length);
done();
}));
});
it('Should passthrough no files when no files changed', function (done) {
gulp.src('test_assets/*')
.pipe(processIfModified())
.pipe(concatStream(function (buf) {
assert.equal(0, buf.length);
done();
}));
});
it('Should passthrough all files when at least one changed', function (done) {
fs.appendFileSync('./test_assets/a', 'test');
gulp.src('test_assets/*')
.pipe(processIfModified())
.pipe(concatStream(function (buf) {
assert.equal(2, buf.length);
assert.equal('a', path.basename(buf[0].path));
assert.equal('b', path.basename(buf[1].path));
done();
}));
});
it('Should passthrough no files when no files changed #2', function (done) {
gulp.src('test_assets/*')
.pipe(processIfModified())
.pipe(concatStream(function (buf) {
assert.equal(0, buf.length);
done();
}));
});
it('Should passthrough all files when at least one changed #2', function (done) {
fs.writeFileSync('./test_assets/a', 'a');
gulp.src('test_assets/*')
.pipe(processIfModified())
.pipe(concatStream(function (buf) {
assert.equal(2, buf.length);
assert.equal('a', path.basename(buf[0].path));
assert.equal('b', path.basename(buf[1].path));
done();
}));
});
});
});