Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklafrance committed Feb 19, 2024
1 parent 8e537ed commit c7929e9
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/webpack-configs/tests/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ test("when optimize is false, minimize is set to false", () => {
expect(result.optimization?.minimize).toBeFalsy();
});

test("when optimize is \"readable\", minimize is set to true", () => {
const result = defineBuildConfig(SwcConfig, {
optimize: "readable"
});

expect(result.optimization?.minimize).toBeTruthy();
});

test("when optimize is false, chunkIds is set to \"named\"", () => {
const result = defineBuildConfig(SwcConfig, {
optimize: false
Expand All @@ -123,6 +131,22 @@ test("when optimize is false, moduleIds is set to \"named\"", () => {
expect(result.optimization?.chunkIds).toBe("named");
});

test("when optimize is \"readable\", chunkIds is set to \"named\"", () => {
const result = defineBuildConfig(SwcConfig, {
optimize: "readable"
});

expect(result.optimization?.chunkIds).toBe("named");
});

test("when optimize is \"readable\", moduleIds is set to \"named\"", () => {
const result = defineBuildConfig(SwcConfig, {
optimize: "readable"
});

expect(result.optimization?.chunkIds).toBe("named");
});

test("when optimize is true, include minify configuration", () => {
const result = defineBuildConfig(SwcConfig, {
optimize: true
Expand All @@ -139,6 +163,14 @@ test("when optimize is false, do not include minify configuration", () => {
expect(result.optimization?.minimizer).toBeUndefined();
});

test("when optimize is \"readable\", include minify configuration", () => {
const result = defineBuildConfig(SwcConfig, {
optimize: "readable"
});

expect(result.optimization?.minimizer).toBeDefined();
});

test("when cache is enabled, the cache configuration is included", () => {
const result = defineBuildConfig(SwcConfig, {
cache: true
Expand Down

0 comments on commit c7929e9

Please sign in to comment.