unmock-jest
Version:
Jest reporter for [Unmock](https://unmock.io).
46 lines (45 loc) • 2.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const os = require("os");
const React = require("react");
const test_suite_1 = require("./test-suite");
exports.testFileToId = (file) => file.replace(/(\/|\\(\\)?|:|\.)/g, "-");
const TestResults = ({ testSuites }) => {
const elementsAndCss = testSuites.map((testSuite, index) => {
const id = exports.testFileToId(testSuite.shortFilePath);
const elementCss = `#box-${id}:checked~.test-suite-label-${id} {
opacity: 1;
border-style: solid;
}
/* Display test suite when corresponding box is checked */
#box-${id}:checked~.test-suite-${id} {
display: block;
}
`;
const numPassingTests = testSuite.suiteResults.numPassingTests;
const numFailingTests = testSuite.suiteResults.numFailingTests;
const nSnapshots = testSuite.snapshots.length;
const testSuiteLabelColor = testSuite.suiteResults.numFailingTests > 0 ? `test-suite-label--failure` : `test-suite-label--success`;
return {
input: React.createElement("input", { type: "radio", id: `box-${id}`, className: "test-suite-input", name: "content", defaultChecked: index === 0, value: `box-${id}`, key: `input-${id}` }),
label: React.createElement("label", { htmlFor: `box-${id}`, className: `test-suite-label test-suite-label-${id} ${testSuiteLabelColor} btn`, id: "feature-label", key: `label-${id}` },
React.createElement("span", { className: "test-suite-label__filename" }, testSuite.shortFilePath),
React.createElement("span", { className: "test-suite-label__summary" }, `Passing: ${numPassingTests}, failing: ${numFailingTests}, HTTP calls: ${nSnapshots}`)),
testSuite: React.createElement("div", { className: `test-suite test-suite-${id}`, key: `div-${id}` },
React.createElement(test_suite_1.default, { testSuite: testSuite })),
css: elementCss
};
});
const inputs = elementsAndCss.map(val => val.input);
const labels = elementsAndCss.map(val => val.label);
const testSuiteComponents = elementsAndCss.map(val => val.testSuite);
const css = elementsAndCss.map(val => val.css);
const renderResult = () => (React.createElement("fieldset", null,
React.createElement("div", { className: "test-results-container" },
inputs,
labels,
testSuiteComponents)));
return [css.join(os.EOL), renderResult];
};
exports.default = TestResults;
//# sourceMappingURL=test-suites.js.map