forked from neptunian/react-photo-gallery
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from amplexus/react-17-support
neptunian#205 support for react 17
- Loading branch information
Showing
7 changed files
with
32,423 additions
and
9,124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
import React from 'react'; | ||
import Gallery from '../src/Gallery'; | ||
import { photos } from './test-photo-data'; | ||
import { mount } from 'enzyme'; | ||
import React from "react"; | ||
import Gallery from "../src/Gallery"; | ||
import { photos } from "./test-photo-data"; | ||
import { mount } from "enzyme"; | ||
|
||
const handleClick = jest.fn(); | ||
|
||
describe('Gallery', () => { | ||
describe("Gallery", () => { | ||
let wrapper; | ||
afterEach(() => { | ||
if (wrapper && wrapper.length > 0) { | ||
wrapper.unmount(); | ||
} | ||
}); | ||
|
||
it('it matches correct snapshot', () => { | ||
wrapper = mount(<Gallery photos={photos} onClick={handleClick} />); | ||
it("it matches correct snapshot", () => { | ||
wrapper = mount(<Gallery photos={photos} onClick={handleClick} />, { attachTo: document.body }); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('calls onClick handler', () => { | ||
wrapper = mount(<Gallery photos={photos} onClick={handleClick} />); | ||
wrapper | ||
.find('img') | ||
.first() | ||
.simulate('click'); | ||
it("calls onClick handler", () => { | ||
wrapper = mount(<Gallery photos={photos} onClick={handleClick} />, { attachTo: document.body }); | ||
wrapper.find("img").first().simulate("click"); | ||
expect(handleClick).toHaveBeenCalled(); | ||
}); | ||
|
||
it('renders correctly with direction set to column', () => { | ||
wrapper = mount(<Gallery photos={photos} direction={'column'} />); | ||
it("renders correctly with direction set to column", () => { | ||
wrapper = mount(<Gallery photos={photos} direction={"column"} />, { attachTo: document.body }); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders correctly with a column function', () => { | ||
const columns = jest.fn(_ => 3); | ||
wrapper = mount(<Gallery photos={photos} onClick={handleClick} columns={columns} direction="column" />); | ||
it("renders correctly with a column function", () => { | ||
const columns = jest.fn((_) => 3); | ||
wrapper = mount(<Gallery photos={photos} onClick={handleClick} columns={columns} direction="column" />, { | ||
attachTo: document.body, | ||
}); | ||
expect(columns).toBeCalledWith(1140); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import { configure } from "enzyme"; | ||
import Adapter from "@wojtekmaj/enzyme-adapter-react-17"; | ||
|
||
configure({ adapter: new Adapter() }); | ||
configure({ adapter: new Adapter() }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
module.exports = { | ||
verbose: true, | ||
testEnvironment: "jsdom", | ||
collectCoverage: true, | ||
collectCoverageFrom: ['src/**/*.js'], | ||
setupFiles: ['./__test__/shims.js', './__test__/jestsetup.js'], | ||
snapshotSerializers: ['enzyme-to-json/serializer'], | ||
collectCoverageFrom: ["src/**/*.js"], | ||
setupFiles: ["./__test__/shims.js", "./__test__/jestsetup.js"], | ||
snapshotSerializers: ["enzyme-to-json/serializer"], | ||
}; |
Oops, something went wrong.