UNPKG

1.2 kBJavaScriptView Raw
1import React from 'react'
2import 'jest-styled-components'
3
4import { QuickAddSize } from 'SRC'
5
6const { mountWithTheme } = global
7
8const defaultProps = {
9 children: '5',
10 input:{
11 name: '5-default',
12 onChange: () => { alert('Selecting a size!') }
13 }
14}
15describe('(Styled Component) QuickAddSize', () => {
16 const createQuickAddSize = (inProps) => {
17 const props = {
18 ...defaultProps,
19 ...inProps
20 }
21 return mountWithTheme(<QuickAddSize {...props} />)
22 }
23
24 test('matching the snapshot', () => {
25 expect(createQuickAddSize())
26 .toMatchSnapshot()
27 })
28
29 describe('the label', () => {
30 test('renders label normally if not OS', () => {
31 expect(
32 createQuickAddSize()
33 .find('label')
34 .text()
35 ).toEqual(defaultProps.children)
36 })
37
38 test('renders text "One Size" if children is "OS"', () => {
39 expect(
40 createQuickAddSize({...defaultProps, children: 'OS'})
41 .find('label')
42 .text()
43 ).toEqual('One Size')
44 })
45 })
46
47 test('input props are passed properly', () => {
48 expect(
49 createQuickAddSize()
50 .find('input')
51 .prop('name')
52 ).toEqual(defaultProps.input.name)
53 })
54})
55
\No newline at end of file