webpack/test/CachePlugin.unittest.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-01-17 22:31:48 +08:00
"use strict";
2017-01-08 10:11:53 +08:00
2017-01-17 22:31:48 +08:00
const should = require("should");
const sinon = require("sinon");
const CachePlugin = require("../lib/CachePlugin");
const applyPluginWithOptions = require("./helpers/applyPluginWithOptions");
2017-01-08 10:11:53 +08:00
2017-01-17 22:31:48 +08:00
describe("CachePlugin", () => {
let env;
beforeEach(() => {
2017-01-08 10:11:53 +08:00
env = {
compilation: {
compiler: {},
warnings: []
}
};
});
2017-01-17 22:31:48 +08:00
it("has apply ", () => {
2017-01-08 10:11:53 +08:00
(new CachePlugin()).apply.should.be.a.Function();
});
2017-01-17 22:31:48 +08:00
describe("applyMtime", () => {
beforeEach(() => env.plugin = new CachePlugin());
2017-01-08 10:11:53 +08:00
2017-01-17 22:31:48 +08:00
it("sets file system accuracy to 1 for granular modification timestamp", () => {
env.plugin.applyMtime(1483819067001);
2017-01-08 10:11:53 +08:00
env.plugin.FS_ACCURENCY.should.be.exactly(1);
});
2017-01-17 22:31:48 +08:00
it("sets file system accuracy to 10 for moderately granular modification timestamp", () => {
env.plugin.applyMtime(1483819067004);
2017-01-08 10:11:53 +08:00
env.plugin.FS_ACCURENCY.should.be.exactly(10);
});
2017-01-17 22:31:48 +08:00
it("sets file system accuracy to 100 for moderately coarse modification timestamp", () => {
env.plugin.applyMtime(1483819067040);
2017-01-08 10:11:53 +08:00
env.plugin.FS_ACCURENCY.should.be.exactly(100);
});
2017-01-17 22:31:48 +08:00
it("sets file system accuracy to 1000 for coarse modification timestamp", () => {
env.plugin.applyMtime(1483819067400);
2017-01-08 10:11:53 +08:00
env.plugin.FS_ACCURENCY.should.be.exactly(1000);
});
});
});