forked from ngokevin/react-file-reader-input
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
77 lines (60 loc) · 2.37 KB
/
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
74
75
76
77
'use strict';
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _assert = require('assert');
var _assert2 = _interopRequireDefault(_assert);
var _reactAddons = require('react/addons');
var _reactAddons2 = _interopRequireDefault(_reactAddons);
var _libIndex = require('./lib/index');
var _libIndex2 = _interopRequireDefault(_libIndex);
var test = _reactAddons2['default'].addons.TestUtils;
describe('FileInput', function () {
var div = undefined;
beforeEach(function () {
div = document.createElement('div');
});
afterEach(function () {
_reactAddons2['default'].unmountComponentAtNode(div);
});
it('renders', function () {
var fileInput = test.renderIntoDocument(_reactAddons2['default'].createElement(_libIndex2['default'], { className: 'input' }), div);
var input = test.findRenderedDOMComponentWithTag(fileInput, 'input');
_assert2['default'].ok(input);
_assert2['default'].ok(!input.props.children);
_assert2['default'].deepEqual(input.props.style, {});
_assert2['default'].equal(input.props.type, 'file');
});
it('can hide input with children', function () {
var fileInput = test.renderIntoDocument(_reactAddons2['default'].createElement(
_libIndex2['default'],
{ className: 'input' },
_reactAddons2['default'].createElement(
'p',
null,
'Input'
)
), div);
var input = test.findRenderedDOMComponentWithTag(fileInput, 'input');
_assert2['default'].ok(!input.props.children);
_assert2['default'].ok(Object.keys(input.props.style).length);
_assert2['default'].equal(input.props.type, 'file');
var p = test.findRenderedDOMComponentWithTag(fileInput, 'p');
_assert2['default'].ok('p');
});
it('can hide input with children', function () {
var fileInput = test.renderIntoDocument(_reactAddons2['default'].createElement(
_libIndex2['default'],
{ className: 'input' },
_reactAddons2['default'].createElement(
'p',
null,
'Input'
)
), div);
var input = test.findRenderedDOMComponentWithTag(fileInput, 'input');
_assert2['default'].ok(!input.props.children);
_assert2['default'].ok(input.props.style);
_assert2['default'].equal(input.props.type, 'file');
var p = test.findRenderedDOMComponentWithTag(fileInput, 'p');
_assert2['default'].ok('p');
});
});