Skip to content

Commit

Permalink
Move to microbundle (#11)
Browse files Browse the repository at this point in the history
* 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
jwo authored Jul 29, 2020
1 parent 9bcf09f commit 708773d
Show file tree
Hide file tree
Showing 12 changed files with 5,100 additions and 4,252 deletions.
11 changes: 6 additions & 5 deletions .babelrc
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"
// ]
}
3 changes: 2 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
exclude_paths:
exclude_patterns:
- "build/"
- "__tests__/"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
2 changes: 1 addition & 1 deletion .travis.yml
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"
58 changes: 0 additions & 58 deletions __tests__/HoverImage.test.js

This file was deleted.

77 changes: 77 additions & 0 deletions __tests__/HoverImage.test.jsx
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();
});
62 changes: 0 additions & 62 deletions __tests__/__snapshots__/HoverImage.test.js.snap

This file was deleted.

7 changes: 7 additions & 0 deletions __tests__/__snapshots__/HoverImage.test.jsx.snap
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,
}
`;
Loading

0 comments on commit 708773d

Please sign in to comment.