-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
90 lines (74 loc) · 2.01 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
"use strict";
const humanstxt = require("./"),
util = require("gulp-util"),
moment = require("moment"),
chai = require("chai"),
assert = chai.assert;
describe("gulp-update-humanstxt-date tests", () => {
it("should update the date", () => {
const stream = humanstxt();
stream.on("data", file => {
assert.equal(file.contents.toString(), "Last updated: " + moment().format("YYYY/MM/DD"));
});
stream.write(new util.File({
contents: new Buffer("Last updated: 0000/00/00")
}));
});
it("should not modify the file when no pattern is found", () => {
const stream = humanstxt();
stream.on("data", file => {
assert.equal(file.contents.toString(), "blah blah blah");
});
stream.write(new util.File({
contents: new Buffer("blah blah blah")
}));
});
it("should update multiline files", () => {
const stream = humanstxt();
stream.on("data", file => {
assert.equal(
file.contents.toString(),
`The first line
Last updated: ${moment().format("YYYY/MM/DD")}
The last line`
);
});
stream.write(new util.File({
contents: new Buffer(
`The first line
Last updated: 0000/00/00
The last line`
)
}));
});
it("should only update the first instance", () => {
const stream = humanstxt();
stream.on("data", file => {
assert.equal(
file.contents.toString(),
`Last updated: ${moment().format("YYYY/MM/DD")}
Last updated: 0000/00/00`
);
});
stream.write(new util.File({
contents: new Buffer(
`Last updated: 0000/00/00
Last updated: 0000/00/00`
)
}));
});
it("should leave unicode unmodified", () => {
const stream = humanstxt();
stream.on("data", file => {
assert.equal(
file.contents.toString(),
`🤘™`
);
});
stream.write(new util.File({
contents: new Buffer(
`🤘™`
)
}));
});
});