1 | import React from 'react'
|
2 | import 'jest-styled-components'
|
3 | import { ProductInformation, H1, H2, H3, P } from 'SRC'
|
4 |
|
5 | const { mountWithTheme } = global
|
6 |
|
7 | const defaultProps = {
|
8 | subheader: "The Trend: Sparkly Rainbow",
|
9 | header: "Weekends Are For Fun Outfit",
|
10 | price: "$55",
|
11 | description: "Cheesecake bocconcini red leicester. Melted cheese when the cheese comes out everybody's happy."
|
12 | }
|
13 |
|
14 | describe('() ProductInformation', () => {
|
15 | const createProductInformation = (inProps) => {
|
16 | const props = {
|
17 | ...defaultProps,
|
18 | ...inProps
|
19 | }
|
20 | return mountWithTheme(<ProductInformation {...props} />)
|
21 | }
|
22 |
|
23 | test('matching the snapshot', () => {
|
24 | expect(createProductInformation())
|
25 | .toMatchSnapshot()
|
26 | })
|
27 |
|
28 | test('header should always render', () => {
|
29 | expect(createProductInformation().find(H1).text()).toMatch(defaultProps.header)
|
30 | })
|
31 |
|
32 | test('price should always render', () => {
|
33 | expect(createProductInformation().find(H2).text()).toMatch(defaultProps.price)
|
34 | })
|
35 |
|
36 | describe('subheader', () => {
|
37 | test("shouldn't render if missing prop", () => {
|
38 | const props = {
|
39 | subheader: undefined
|
40 | }
|
41 | expect(createProductInformation(props).find(H3).length).toEqual(0)
|
42 | })
|
43 |
|
44 | test('should render if provided', () => {
|
45 | expect(createProductInformation().find(H3).text()).toMatch(defaultProps.subheader)
|
46 | })
|
47 | })
|
48 |
|
49 | describe('description', () => {
|
50 | test("shouldn't render if missing prop", () => {
|
51 | const props = {
|
52 | description: undefined
|
53 | }
|
54 | expect(createProductInformation(props).find(P).length).toEqual(0)
|
55 | })
|
56 |
|
57 | test('should render if provided', () => {
|
58 | expect(createProductInformation().find(P).text()).toMatch(defaultProps.description)
|
59 | })
|
60 | })
|
61 | }) |
\ | No newline at end of file |