forked from ngokevin/react-file-reader-input
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.es6
57 lines (44 loc) · 1.56 KB
/
test.es6
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
import assert from 'assert';
import React from 'react/addons';
import FileInput from './lib/index';
const test = React.addons.TestUtils;
describe('FileInput', () => {
let div;
beforeEach(() => {
div = document.createElement('div');
});
afterEach(() => {
React.unmountComponentAtNode(div);
});
it('renders', () => {
const fileInput = test.renderIntoDocument(
<FileInput className="input"/>, div);
const input = test.findRenderedDOMComponentWithTag(fileInput, 'input');
assert.ok(input);
assert.ok(!input.props.children);
assert.deepEqual(input.props.style, {});
assert.equal(input.props.type, 'file');
});
it('can hide input with children', () => {
const fileInput = test.renderIntoDocument(<FileInput className="input">
<p>Input</p>
</FileInput>, div);
const input = test.findRenderedDOMComponentWithTag(fileInput, 'input');
assert.ok(!input.props.children);
assert.ok(Object.keys(input.props.style).length);
assert.equal(input.props.type, 'file');
const p = test.findRenderedDOMComponentWithTag(fileInput, 'p');
assert.ok('p');
});
it('can hide input with children', () => {
const fileInput = test.renderIntoDocument(<FileInput className="input">
<p>Input</p>
</FileInput>, div);
const input = test.findRenderedDOMComponentWithTag(fileInput, 'input');
assert.ok(!input.props.children);
assert.ok(input.props.style);
assert.equal(input.props.type, 'file');
const p = test.findRenderedDOMComponentWithTag(fileInput, 'p');
assert.ok('p');
});
});