Skip to content

Commit

Permalink
tests(entry): use extractSummary
Browse files Browse the repository at this point in the history
  • Loading branch information
hemal7735 committed Jan 21, 2019
1 parent b1abc3d commit af29665
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 27 deletions.
12 changes: 7 additions & 5 deletions test/binCases/entry/cli-override/cli-override.test.js
@@ -1,6 +1,6 @@
"use strict";

const { run } = require("../../../testUtils");
const { run, extractSummary } = require("../../../testUtils");

test("cli-override", () => {
const { code, stdout, stderr } = run(__dirname, [
Expand All @@ -14,10 +14,12 @@ test("cli-override", () => {
"[id].chunk.js"
]);

const summary = extractSummary(stdout);

expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout).toContain("cliEntry.js");
expect(stdout).toContain("index.js");
expect(summary).toEqual(expect.anything());
expect(summary).toContain("cliEntry.js");
expect(summary).toContain("index.js");
expect(stderr).toHaveLength(0);
expect(stdout).toMatchSnapshot();
expect(summary).toMatchSnapshot();
});
@@ -1,11 +1,13 @@
"use strict";

const { run } = require("../../../testUtils");
const { run, extractSummary } = require("../../../testUtils");

test("display-entrypoints", () => {
const { stdout, stderr } = run(__dirname, ["--display-entrypoints", "false"]);

expect(stdout).not.toContain("Entrypoint");
const summary = extractSummary(stdout);

expect(summary).not.toContain("Entrypoint");
expect(stderr).toHaveLength(0);
expect(stdout).toMatchSnapshot();
expect(summary).toMatchSnapshot();
});
16 changes: 9 additions & 7 deletions test/binCases/entry/multi-file/multi-file.test.js
@@ -1,6 +1,6 @@
"use strict";

const { run } = require("../../../testUtils");
const { run, extractSummary } = require("../../../testUtils");

test("multi-file", () => {
const { stdout, code, stderr } = run(__dirname, [
Expand All @@ -18,12 +18,14 @@ test("multi-file", () => {
"async-node"
]);

const summary = extractSummary(stdout);

expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout).toContain("null.js");
expect(stdout).toMatch(/multi.*index\.js.*a\.js/); // should have multi-file entry
expect(stdout).toMatch(/index\.js.*\{0\}/);
expect(stdout).toMatch(/a\.js.*\{0\}/);
expect(summary).toEqual(expect.anything());
expect(summary).toContain("null.js");
expect(summary).toMatch(/multi.*index\.js.*a\.js/); // should have multi-file entry
expect(summary).toMatch(/index\.js.*\{0\}/);
expect(summary).toMatch(/a\.js.*\{0\}/);
expect(stderr).toHaveLength(0);
expect(stdout).toMatchSnapshot();
expect(summary).toMatchSnapshot();
});
16 changes: 9 additions & 7 deletions test/binCases/entry/named-entry/named-entry.test.js
@@ -1,6 +1,6 @@
"use strict";

const { run } = require("../../../testUtils");
const { run, extractSummary } = require("../../../testUtils");

test("named-entry", () => {
const { stdout, code, stderr } = run(__dirname, [
Expand All @@ -20,12 +20,14 @@ test("named-entry", () => {
"production"
]);

const summary = extractSummary(stdout);

expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout).toContain("foo.js"); // named entry from --entry foo=./a.js
expect(stdout).toContain("null.js");
expect(stdout).toMatch(/a\.js.*\{0\}/);
expect(stdout).toMatch(/index\.js.*\{1\}/);
expect(summary).toEqual(expect.anything());
expect(summary).toContain("foo.js"); // named entry from --entry foo=./a.js
expect(summary).toContain("null.js");
expect(summary).toMatch(/a\.js.*\{0\}/);
expect(summary).toMatch(/index\.js.*\{1\}/);
expect(stderr).toHaveLength(0);
expect(stdout).toMatchSnapshot();
expect(summary).toMatchSnapshot();
});
@@ -1,6 +1,6 @@
"use strict";

const { run } = require("../../../testUtils");
const { run, extractSummary } = require("../../../testUtils");

test("non-hyphenated-args", () => {
const { stdout, code, stderr } = run(__dirname, [
Expand All @@ -15,10 +15,12 @@ test("non-hyphenated-args", () => {
"async-node"
]);

const summary = extractSummary(stdout);

expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout).toContain("main.js"); // non-hyphenated arg ./a.js should create chunk "main"
expect(stdout).toMatch(/a\.js.*\{0\}/); // a.js should be in chunk 0
expect(summary).toEqual(expect.anything());
expect(summary).toContain("main.js"); // non-hyphenated arg ./a.js should create chunk "main"
expect(summary).toMatch(/a\.js.*\{0\}/); // a.js should be in chunk 0
expect(stderr).toHaveLength(0);
expect(stdout).toMatchSnapshot();
expect(summary).toMatchSnapshot();
});

0 comments on commit af29665

Please sign in to comment.