Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to microbundle #11

Merged
merged 6 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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