-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathtest.js
71 lines (62 loc) · 2.15 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
var test = require('tape')
var control = require('./index')
function assertSelector (t, selector) {
var el = document.querySelector(selector)
t.notEqual(el, null, 'element ' + selector + ' is present')
}
function assertId (t, id) {
var el = document.getElementById(id)
t.notEqual(el, null, 'element #' + id + ' is present')
}
test('construction', function (t) {
control([{type: 'range', label: 'range label', min: 0, max: 100, initial: 20}])
assertId(t, 'control-panel-range-label')
assertSelector(t, '[class^=control-panel-range-]')
t.end()
})
test('range', function (t) {
control([{type: 'range', label: 'range label', min: 0, max: 100, initial: 20}])
assertId(t, 'control-panel-range-label')
assertSelector(t, '[class^=control-panel-range-]')
t.end()
})
test('color', function (t) {
control([{type: 'color', label: 'color label', min: 0, max: 100, initial: 20}])
assertId(t, 'control-panel-color-label')
assertSelector(t, '[class^=control-panel-color-]')
t.end()
})
test('text', function (t) {
control([{type: 'text', label: 'text label', min: 0, max: 100, initial: 20}])
assertId(t, 'control-panel-text-label')
assertSelector(t, '[class^=control-panel-text]')
t.end()
})
test('checkbox', function (t) {
control([{type: 'checkbox', label: 'checkbox label', initial: false}])
assertId(t, 'control-panel-checkbox-label')
assertSelector(t, '[class^=control-panel-checkbox-]')
t.end()
window.close()
})
test('interval', function (t) {
control([{type: 'interval', label: 'interval label', min: 0, max: 100, initial: [20, 40]}])
assertId(t, 'control-panel-interval-label')
assertSelector(t, '[class^=control-panel-interval-]')
t.end()
window.close()
})
test('button', function (t) {
control([{type: 'button', label: 'button label', action: function () { }}])
assertId(t, 'control-panel-button-label')
assertSelector(t, '[class^=control-panel-button-]')
t.end()
window.close()
})
test('select', function (t) {
control([{type: 'select', label: 'select label', options: ['option 1', 'option 2']}])
assertId(t, 'control-panel-select-label')
assertSelector(t, '[class^=control-panel-select-]')
t.end()
window.close()
})