Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dpikt committed Jun 22, 2017
1 parent 8df90f3 commit 06bc052
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/forms/inputs/file-input.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react'
import { mount } from 'enzyme'
import { FileInput } from '../../../src/'

const name = 'my.file.input'

test('Fileinput renders thumbnail with value as src', () => {
const value = 'foo'
const props = { input: { name, value }, meta: {} }
const wrapper = mount(<FileInput { ...props }/>)
expect(wrapper.find('img').props().src).toEqual(value)
})

test('Fileinput sets thumbnail placeholder', () => {
const thumbnail = 'thumb'
const props = { input: { name, value: '' }, meta: {}, thumbnail }
const wrapper = mount(<FileInput { ...props }/>)
expect(wrapper.find('img').props().src).toEqual(thumbnail)
})

test('Fileinput hides preview correctly', () => {
const props = { input: { name, value: '' }, meta: {}, hidePreview: true }
const wrapper = mount(<FileInput { ...props }/>)
expect(wrapper.find('img').exists()).toEqual(false)
})

test('Fileinput sets custom preview correctly', () => {
const Preview = () => <blink> My preview </blink>
const props = { input: { name, value: '' }, meta: {} }
const wrapper = mount(<FileInput { ...props }><Preview/></FileInput>)
expect(wrapper.find('blink').exists()).toEqual(true)
})

0 comments on commit 06bc052

Please sign in to comment.