-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
53 lines (42 loc) · 1.22 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
/*global describe, it*/
"use strict";
var fs = require("fs");
var es = require("event-stream");
var should = require("should");
require("mocha");
delete require.cache[require.resolve("./")];
var Vinyl = require("vinyl");
var cachebust = require("./");
describe("gulp-wp-cache-bust", function () {
var expectedFile = new Vinyl({
path: "test-files/expected/scripts.php",
cwd: "test-files/",
base: "test-files/expected",
contents: fs.readFileSync("test-files/expected/scripts.php"),
});
it("should produce expected file", function (done) {
var srcFile = new Vinyl({
path: "test-files/raw/default_options.html",
cwd: "test-files/",
base: "test-files/raw",
contents: fs.readFileSync("test-files/raw/scripts.php"),
});
var stream = cachebust({
themeFolder: "test-files/raw",
});
stream.on("error", function (err) {
should.exist(err);
done(err);
});
stream.on("data", function (newFile) {
should.exist(newFile);
should.exist(newFile.contents);
String(newFile.contents).should.equal(String(expectedFile.contents));
});
stream.on("end", function () {
done();
});
stream.write(srcFile);
stream.end();
});
});