Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
vankop committed May 1, 2024
1 parent e11fb12 commit 8510a6d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/Compiler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ describe("Compiler", () => {
callback();
}
});
it("default platform info", done => {
const platform = compiler.getPlatformTargetInfo();
expect(platform.web).toBe(true);
expect(platform.node).toBe(false);
done();
});
describe("purgeInputFileSystem", () => {
it("invokes purge() if inputFileSystem.purge", done => {
const mockPurge = jest.fn();
Expand Down Expand Up @@ -287,6 +293,29 @@ describe("Compiler", () => {
});
});
});

it("PlatformPlugin", done => {
const webpack = require("..");
const compiler = webpack({
entry: "./c",
context: path.join(__dirname, "fixtures"),
output: {
path: "/directory"
},
plugins: [
new (require("../lib/PlatformPlugin"))({ node: true }),
compiler => {
compiler.hooks.afterEnvironment.tap("test", () => {
const platform = compiler.getPlatformTargetInfo();
expect(platform.node).toBe(true);
expect(platform.web).toBe(true);
});
}
]
});
compiler.close(done);
});

it("should not emit on errors", done => {
const webpack = require("..");
compiler = webpack({
Expand Down

0 comments on commit 8510a6d

Please sign in to comment.