forked from nitin42/animate-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge.test.js
73 lines (57 loc) · 1.87 KB
/
merge.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import React from "react";
import renderer from "react-test-renderer";
import "jest-styled-components";
import { shallow } from "enzyme";
import Merge from "../src/containers/merge";
import { left, bounce } from "../index";
let App = () => {
return (
<div>
<p>Hello Clay Jansen!</p>
</div>
);
}
const renderh1 = (
<Merge one={{ name: left }} two={{ name: bounce }} as="h1">
Hello
</Merge>
);
const defaultRender = (
<Merge one={{ name: left }} two={{ name: bounce }} className="main">
<p>Hello</p>
</Merge>
);
describe('Merge Component', () => {
it("animates the children and render the h1 element", () => {
const tree = renderer.create(renderh1).toJSON;
expect(tree).toMatchSnapshot();
});
it("animates the children and render the div (default) element", () => {
const tree = renderer.create(defaultRender).toJSON;
expect(tree).toMatchSnapshot();
});
it("matches the keyframes created by styled-components and default props", () => {
const tree = renderer.create(defaultRender).toJSON();
expect(tree).toMatchStyledComponentsSnapshot();
});
it('renders the Component passed through the component prop', () => {
const tree = renderer.create(
<Merge one={{ name: left }} two={{ name: bounce }} component={App} />
).toJSON();
expect(tree).toMatchSnapshot();
})
it("calls componentDidMount lifecycle method", () => {
const wrapper = shallow(defaultRender);
wrapper.instance().componentDidMount();
// Also calls store() method when component mounts.
});
it("updates the styles when the component mounts", () => {
const wrapper = shallow(renderh1);
wrapper.instance().componentDidMount();
// Implicitly calls the returnAnimation()
expect(wrapper.state("styles")).toEqual({
animation: "fRXJaB 1s ease, bGJZDZ 1s ease",
backfaceVisibility: "visible"
});
});
})