-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove build from git * Move to microbundle, on way to typescript * Update node to 12, from 8, for travis-ci * Extract expected for code-climate * Code climate on tests are low-value, so ignoring * Update for code-climate
- Loading branch information
Showing
12 changed files
with
5,100 additions
and
4,252 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,7 +1,8 @@ | ||
{ | ||
"presets": ["env", "stage-0", "react"], | ||
"plugins": [ | ||
"transform-object-rest-spread", | ||
"transform-react-jsx" | ||
] | ||
"presets": ["@babel/preset-env", "@babel/preset-react"], | ||
"plugins": ["@babel/plugin-proposal-class-properties"] | ||
// "plugins": [ | ||
// "transform-object-rest-spread", | ||
// "transform-react-jsx" | ||
// ] | ||
} |
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,2 +1,3 @@ | ||
exclude_paths: | ||
exclude_patterns: | ||
- "build/" | ||
- "__tests__/" |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
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,5 +1,5 @@ | ||
language: node_js | ||
node_js: | ||
- '8' | ||
- "12" | ||
cache: yarn | ||
script: "yarn test-ci" |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React from "react"; | ||
import Enzyme, { shallow, mount, render } from "enzyme"; | ||
import Adapter from "enzyme-adapter-react-16"; | ||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
import HoverImage from "../src"; | ||
|
||
test("Displays initial src image", () => { | ||
const wrapper = mount( | ||
<HoverImage src={"/img/first.png"} hoverSrc={"/img/first-hover.png"} /> | ||
); | ||
expect(wrapper.state().src).toBe("/img/first.png"); | ||
}); | ||
|
||
test("Changes to hoverSrc on mouseOver", () => { | ||
const wrapper = mount( | ||
<HoverImage src={"/img/first.png"} hoverSrc={"/img/first-hover.png"} /> | ||
); | ||
wrapper.find("img").simulate("mouseover"); | ||
expect(wrapper.state().src).toBe("/img/first-hover.png"); | ||
}); | ||
|
||
test("When given an onClick, it gets called when clicked", () => { | ||
const doneChange = jest.fn(); | ||
|
||
const wrapper = shallow( | ||
<HoverImage | ||
onClick={doneChange} | ||
src={"/img/first.png"} | ||
hoverSrc={"/img/first-hover.png"} | ||
/> | ||
); | ||
wrapper.find("img").simulate("click"); | ||
expect(doneChange).toBeCalled(); | ||
}); | ||
|
||
test("When given an onClick, it does not get called when disabled", () => { | ||
const doneChange = jest.fn(); | ||
const disabled = true; | ||
|
||
const wrapper = shallow( | ||
<HoverImage | ||
disabled={disabled} | ||
onClick={doneChange} | ||
src={"/img/first.png"} | ||
hoverSrc={"/img/first-hover.png"} | ||
/> | ||
); | ||
wrapper.find("img").simulate("click"); | ||
|
||
expect(doneChange).not.toBeCalled(); | ||
}); | ||
|
||
test("No errors if click, but no onClick provided", () => { | ||
const wrapper = shallow( | ||
<HoverImage src={"/img/first.png"} hoverSrc={"/img/first-hover.png"} /> | ||
); | ||
expect(() => { | ||
wrapper.find("img").simulate("click"); | ||
}).not.toThrowError(); | ||
}); | ||
|
||
test("Matches snapshot", () => { | ||
const doneChange = jest.fn(); | ||
const disabled = false; | ||
|
||
const wrapper = shallow( | ||
<HoverImage | ||
disabled={disabled} | ||
onClick={doneChange} | ||
src={"/img/first.png"} | ||
hoverSrc={"/img/first-hover.png"} | ||
/> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Matches snapshot 1`] = ` | ||
ShallowWrapper { | ||
"length": 1, | ||
} | ||
`; |
Oops, something went wrong.