This repository has been archived by the owner on Apr 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
tests.js
75 lines (64 loc) · 1.72 KB
/
tests.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
import React from 'react'
import { render } from 'react-dom'
import { deepEqual } from 'assert'
import { compose, unnest, flip, keys, map, prop, values, pickBy } from 'ramda'
import { LIVE, LIVE_WIDE, MANUAL, TEMPLATE, SHOWCASE } from './Showroom/variationTypes'
import * as examples from './Showroom/examples'
import * as index from './index'
const container = document.createElement('div')
container.id = 'container'
document.body.appendChild(container)
const getEntries = compose(
unnest,
map(({type, example, examples}) => {
switch (type) {
case LIVE:
case LIVE_WIDE:
return compose(
map((key) => [key, examples[key]]),
keys
)(examples)
case MANUAL:
return compose(
map((key) => [key, examples[key].live]),
keys
)(examples)
case TEMPLATE:
return compose(
map((key) => [key, examples[key].inline]),
keys
)(examples)
case SHOWCASE:
return [['Main', example]]
}
}),
({examples, variations}) => variations || [examples]
)
const createTests = compose(
map((example) => {
describe(`loads ${example.title} examples`, () => {
compose(
map(([title, children]) => {
it(title, () => {
render(
<div>
{children}
</div>
, document.getElementById('container')
)
})
})
)(getEntries(example))
})
}),
values,
flip(prop)(examples)
)
describe('@klarna/ui', () => {
map(createTests, ['components', 'templates'])
describe('index', () => {
it('should not export undefined values', () => {
deepEqual({}, pickBy((x) => !x, index))
})
})
})