-
Notifications
You must be signed in to change notification settings - Fork 0
/
lights.test.js
96 lines (77 loc) · 2.59 KB
/
lights.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import lights from './lights.js'
const high = 200
const low = 10
const light = 15 //honeycomb sconce
const highHue = 8417
const lowHue = 1000
const highSaturation = 140
const lowSaturation = 0
test('setting the light high should work', async()=>{
const result = await lights.brightness(light, 'set', high)
expect(result).toEqual(high)
})
test('light status should be returned high', async ()=>{
const result = await lights.brightness(light)
expect(result).toEqual(high)
})
test('setting the light low should work', async()=>{
const result = await lights.brightness(light, 'set', low)
expect(result).toEqual(low)
})
test('light status should be returned as low', async()=>{
const result = await lights.brightness(light)
expect(result).toEqual(low)
})
test('light should turn off', async()=>{
const result = await lights.off(light)
const expectedKey = `/lights/${light}/state/on`
const resultValue = result[0].success[expectedKey]
const expectedValue = false
expect(resultValue).toEqual(expectedValue)
})
test('light should turn on', async()=>{
const result = await lights.on(light)
const expectedKey = `/lights/${light}/state/on`
const resultValue = result[0].success[expectedKey]
const expectedValue = true
expect(resultValue).toEqual(expectedValue)
})
test('setting the light high should work', async()=>{
const result = await lights.brightness(light, 'set', high)
expect(result).toEqual(high)
})
test('light should return a color value', async()=>{
const result = await lights.hue(light)
expect(result).toEqual(highHue)
})
test(`light should be able to have its hue set to ${lowHue}`, async()=>{
const result = await lights.hue(light, lowHue)
expect(result).toEqual(lowHue)
})
test(`light should be able to have its hue reset to ${highHue}`, async()=>{
const result = await lights.hue(light, highHue)
expect(result).toEqual(highHue)
})
test('light should return a saturation value', async()=>{
const result = await lights.saturation(light)
expect(result).toEqual(140)
})
test('light should be able to have its saturation set to 0', async()=>{
const result = await lights.saturation(light, 0)
expect(result).toEqual(0)
})
test('light should be able to have its saturation reset to 140', async()=>{
const result = await lights.saturation(light, 140)
expect(result).toEqual(140)
})
/*
test('rooms should load correctly', () => {
expect(rooms.length).toBeGreaterThan(0);
});
test('oficina should exist', () => {
expect(rooms[0].name).toEqual('Oficina');
});
test(`requesting room('oficina') should work`, () => {
expect(room('oficina').name).toEqual('Oficina');
});
*/