webpack/test/NullDependency.unittest.js

50 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-02-18 02:39:13 +08:00
"use strict";
2017-02-18 02:02:19 +08:00
const NullDependency = require("../lib/dependencies/NullDependency");
2017-01-17 06:19:11 +08:00
2017-02-18 02:02:19 +08:00
describe("NullDependency", () => {
let env;
2017-01-17 06:19:11 +08:00
2018-02-25 09:00:20 +08:00
beforeEach(() => (env = {}));
2017-01-17 06:19:11 +08:00
it("is a function", () => {
expect(NullDependency).toBeTypeOf("function");
});
2017-01-17 06:19:11 +08:00
2017-02-18 02:02:19 +08:00
describe("when created", () => {
2018-02-25 09:00:20 +08:00
beforeEach(() => (env.nullDependency = new NullDependency()));
2017-01-17 06:19:11 +08:00
2018-01-24 20:17:21 +08:00
it("has a null type", () => {
expect(env.nullDependency.type).toBe("null");
});
2017-01-17 06:19:11 +08:00
it("has update hash function", () => {
expect(env.nullDependency.updateHash).toBeTypeOf("function");
});
2017-01-17 06:19:11 +08:00
2017-02-18 02:02:19 +08:00
it("does not update hash", () => {
2017-01-17 06:19:11 +08:00
const hash = {
update: jest.fn()
2017-01-17 06:19:11 +08:00
};
env.nullDependency.updateHash(hash);
expect(hash.update).not.toHaveBeenCalled();
2017-01-17 06:19:11 +08:00
});
});
2017-02-18 02:02:19 +08:00
describe("Template", () => {
it("is a function", () => {
expect(NullDependency.Template).toBeTypeOf("function");
});
2017-01-17 06:19:11 +08:00
2017-02-18 02:02:19 +08:00
describe("when created", () => {
beforeEach(() => {
env.nullDependencyTemplate = new NullDependency.Template();
});
2017-01-17 06:19:11 +08:00
it("has apply function", () => {
expect(env.nullDependencyTemplate.apply).toBeTypeOf("function");
});
2017-01-17 06:19:11 +08:00
});
});
});