Skip to content

Commit

Permalink
pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmzb committed Jul 6, 2020
1 parent 7f6d58c commit 400a8f5
Show file tree
Hide file tree
Showing 6 changed files with 338 additions and 583 deletions.
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
"example/node_modules/react-native-gesture-handler/",
],
testPathIgnorePatterns: ["node_modules", "dist"],
setupFiles: ["<rootDir>/jest/setup.js"],
setupFilesAfterEnv: ["<rootDir>/jest/setupEnzymeAfterEnv.js"],
setupFilesAfterEnv: ["jest-enzyme", "<rootDir>/jest/setupEnzymeAfterEnv.js"],
testEnvironment: "enzyme",
cacheDirectory: ".jest/cache",
};
13 changes: 0 additions & 13 deletions jest/setup.js

This file was deleted.

24 changes: 1 addition & 23 deletions jest/setupEnzymeAfterEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,6 @@ import "jest-enzyme";
import Adapter from "enzyme-adapter-react-16";
import Enzyme from "enzyme";

/**
* Set up DOM in node.js environment for Enzyme to mount to
*/
const { JSDOM } = require("jsdom");

const jsdom = new JSDOM("<!doctype html><html><body></body></html>");
const { window } = jsdom;

function copyProps(src, target) {
Object.defineProperties(target, {
...Object.getOwnPropertyDescriptors(src),
...Object.getOwnPropertyDescriptors(target),
});
}

global.window = window;
global.document = window.document;
global.navigator = {
userAgent: "node.js",
};
copyProps(window, global);

/**
* Set up Enzyme to mount to DOM, simulate events,
* and inspect the DOM in tests.
Expand All @@ -39,7 +17,7 @@ Enzyme.configure({ adapter: new Adapter() });

const originalConsoleError = console.error; // eslint-disable-line
// eslint-disable-next-line
console.error = message => {
console.error = (message) => {
if (message.startsWith("Warning:")) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"jest-enzyme": "^7.1.1",
"react": ">=16.8.0",
"react-dom": "^16.9.0",
"react-native": "^0.60.5",
"react-native": "^0.62.2",
"react-native-gesture-handler": "^1.4.1",
"react-test-renderer": "^16.9.0",
"release-it": "^13.6.4",
Expand Down
8 changes: 7 additions & 1 deletion src/__tests__/useGestureStore.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import GesturePath from "../GesturePath";
describe("<GesturePath />", () => {
it("renders 3 coordinate points", () => {
const wrapper = mount(
<GesturePath path={[{ x: 0, y: 0 }, { x: 10, y: 0 }, { x: 20, y: 0 }]} />,
<GesturePath
path={[
{ x: 0, y: 0 },
{ x: 10, y: 0 },
{ x: 20, y: 0 },
]}
/>,
);
expect(wrapper.find(Animated.View)).toHaveLength(3);
});
Expand Down
Loading

0 comments on commit 400a8f5

Please sign in to comment.