/
test.js
57 lines (47 loc) · 1.26 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
'use strict';
const test = require('ava');
const React = require('react');
const ReactTestRenderer = require('react-test-renderer');
const PropMatrix = require('./');
const h = React.createElement;
function render(el) {
return ReactTestRenderer.create(el).toJSON();
}
test('<PropMatrix/>', t => {
let options = {
background: ['red', 'green', 'blue'],
children: ['Hello', 'World'],
};
let tree = render(
h(PropMatrix, { options }, props => (
h('button', props)
)),
);
t.deepEqual(tree, [
h('button', { background: 'red' }, 'Hello'),
h('button', { background: 'green' }, 'Hello'),
h('button', { background: 'blue' }, 'Hello'),
h('button', { background: 'red' }, 'World'),
h('button', { background: 'green' }, 'World'),
h('button', { background: 'blue' }, 'World'),
]);
});
test('<PropMatrix/>', t => {
let options = {
background: ['red', 'green', 'blue'],
children: ['Hello', 'World'],
};
let filters = {
background: ['red', 'green'],
children: ['Hello'],
};
let tree = render(
h(PropMatrix, { options, filters }, props => (
h('button', props)
)),
);
t.deepEqual(tree, [
h('button', { background: 'red' }, 'Hello'),
h('button', { background: 'green' }, 'Hello'),
]);
});