diff --git a/.eslintrc b/.eslintrc index 63892f8fa..ab9b87d3e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -27,7 +27,8 @@ "Media": true, "FormElement": true, "SyntheticInputEvent": true, - "React$Element": true + "React$Element": true, + "jest": true, }, "rules": { "arrow-parens": [2, "always"], diff --git a/__mocks__/victory.js b/__mocks__/victory.js new file mode 100644 index 000000000..85e20ce74 --- /dev/null +++ b/__mocks__/victory.js @@ -0,0 +1,14 @@ + +const VictoryChart = jest.fn(() => "VictoryChart"); +const VictoryAxis = jest.fn(() => "VictoryAxis"); +const VictoryLine = jest.fn(() => "VictoryLine"); +const VictoryScatter = jest.fn(() => "VictoryScatter"); +const VictoryArea = jest.fn(() => "VictoryArea"); + +export { + VictoryChart, + VictoryAxis, + VictoryLine, + VictoryScatter, + VictoryArea, +}; diff --git a/imports/__mocks__/victory.js b/imports/__mocks__/victory.js new file mode 100644 index 000000000..85e20ce74 --- /dev/null +++ b/imports/__mocks__/victory.js @@ -0,0 +1,14 @@ + +const VictoryChart = jest.fn(() => "VictoryChart"); +const VictoryAxis = jest.fn(() => "VictoryAxis"); +const VictoryLine = jest.fn(() => "VictoryLine"); +const VictoryScatter = jest.fn(() => "VictoryScatter"); +const VictoryArea = jest.fn(() => "VictoryArea"); + +export { + VictoryChart, + VictoryAxis, + VictoryLine, + VictoryScatter, + VictoryArea, +}; diff --git a/imports/components/graphs/lineGraph/__tests__/index.js b/imports/components/graphs/lineGraph/__tests__/index.js index 5b7d74b4c..2d3e4b3c8 100644 --- a/imports/components/graphs/lineGraph/__tests__/index.js +++ b/imports/components/graphs/lineGraph/__tests__/index.js @@ -2,20 +2,7 @@ import { mount, shallow } from "enzyme"; import { mountToJson, shallowToJson } from "enzyme-to-json"; import LineGraph from "../"; -jest.mock("victory", () => { - const VictoryChart = jest.fn(() => "VictoryChart"); - const VictoryAxis = jest.fn(() => "VictoryAxis"); - const VictoryLine = jest.fn(() => "VictoryLine"); - const VictoryScatter = jest.fn(() => "VictoryScatter"); - const VictoryArea = jest.fn(() => "VictoryArea"); - return { - VictoryChart: VictoryChart, - VictoryAxis: VictoryAxis, - VictoryLine: VictoryLine, - VictoryScatter: VictoryScatter, - VictoryArea: VictoryArea, - }; -}); +jest.mock("victory"); const generateComponent = (additionalProps = {}) => { const defaultProps = { diff --git a/package.json b/package.json index 2437e70d9..a55059f88 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "moduleNameMapper": { "^meteor/(.*)": "/.meteor/mocks/$1.js" }, + "mocksPattern": "(?:[\\/]|^)imports/__mocks__[\\/]", "setupFiles": [ "/.scripts/before_test.js" ]