Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dogboydog committed Aug 25, 2018
1 parent 14dccf1 commit 595c00f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
17 changes: 16 additions & 1 deletion __tests__/processor/Processor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { inspect } from "util";
import { Logger } from "../../src/utils/Logger";
import { IResultsProcessorInput } from "../../src/processor/doc/jest/IResultsProcessorInput";
import { ISubstitute } from "../../src/processor/doc/ISubstitute";
import { Constants } from "../../src/processor/Constants";

const simplePassingTests: IResultsProcessorInput = require("../__resources__/simplePassingTests.json");

Expand All @@ -28,7 +29,7 @@ describe("Processor tests", () => {
});

(Processor as any).logger = log;
const processed = Processor.run(simplePassingTests, {log: false});
const processed = Processor.run(simplePassingTests, { log: false });
expect((log as any).writeStdout).not.toHaveBeenCalled();
expect((log as any).writeStderr).not.toHaveBeenCalled();
});
Expand Down Expand Up @@ -88,6 +89,20 @@ describe("Processor tests", () => {
expect(processed).toMatchSnapshot();
});


it("should create file names correctly when default 'resultDir' is used", async () => {
IO.mkdirsSync = jest.fn(
() => {
// do nothing
}
);
const processed = Processor.run(simplePassingTests, { resultDir: undefined }); // don't specify result dir
// old version left off the slash after the default result directory
expect(IO.mkdirsSync).toHaveBeenCalledWith(Constants.DEFAULT_RESULTS_DIR + "/css/");
expect(IO.mkdirsSync).toHaveBeenCalledWith(Constants.DEFAULT_RESULTS_DIR + "/js/");
});


it("should error when called without input", () => {
let error;
try {
Expand Down
8 changes: 4 additions & 4 deletions __tests__/processor/__snapshots__/Processor.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
exports[`Processor tests should accept override html and JSON file name 1`] = `
Object {
"jestStareConfig": Object {
"resultDir": "./jest-stare",
"resultDir": "./jest-stare/",
"resultHtml": "index.html",
"resultJson": "jest-results.json",
},
"rawJestStareConfig": "{
\\"resultDir\\": \\"./jest-stare\\",
\\"resultDir\\": \\"./jest-stare/\\",
\\"resultHtml\\": \\"index.html\\",
\\"resultJson\\": \\"jest-results.json\\"
}",
Expand Down Expand Up @@ -304,14 +304,14 @@ Object {
exports[`Processor tests should accept override html and JSON file name 2`] = `
Object {
"jestStareConfig": Object {
"resultDir": "./jest-stare",
"resultDir": "./jest-stare/",
"resultHtml": "test.html",
"resultJson": "test.json",
},
"rawJestStareConfig": "{
\\"resultHtml\\": \\"test.html\\",
\\"resultJson\\": \\"test.json\\",
\\"resultDir\\": \\"./jest-stare\\"
\\"resultDir\\": \\"./jest-stare/\\"
}",
"rawResults": "{
\\"numFailedTestSuites\\": \\"0\\",
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
"testResultsProcessor": "./"
},
"jest-stare": {
"resultDir": "results/jest-stare",
"additionalResultsProcessors": [
"jest-html-reporter",
"jest-junit"
Expand Down

0 comments on commit 595c00f

Please sign in to comment.