|
|
@@ -1,6 +1,5 @@
|
|
1
|
1
|
import { expect, test } from 'vitest'
|
|
2
|
2
|
import { System, makeContainerT } from '../src/system.js'
|
|
3
|
|
-import { Reading } from '../src/channel.js'
|
|
4
|
3
|
import { Container } from '../src/container.js'
|
|
5
|
4
|
import { controllerTypes } from '../src/controller.js'
|
|
6
|
5
|
import { InputConf } from '../src/index.js'
|
|
|
@@ -18,11 +17,14 @@ test('system - instantiates and stores inventory correctly', () => {
|
|
18
|
17
|
const outputs = testSystem.outputsFor({ id: 'aaa' })
|
|
19
|
18
|
expect(outputs).toStrictEqual(['output_test'])
|
|
20
|
19
|
|
|
|
20
|
+ testSystem.replaceContainer({ id: 'aaa' })
|
|
|
21
|
+ expect(testSystem.containers[0].id).toStrictEqual('aaa')
|
|
|
22
|
+
|
|
21
|
23
|
testSystem.remove('aaa')
|
|
22
|
24
|
expect(testSystem.inventory).toStrictEqual({})
|
|
23
|
25
|
})
|
|
24
|
26
|
|
|
25
|
|
-test('system - instiantes channels with readers correctly', () => {
|
|
|
27
|
+test('system - update channels with readers correctly', () => {
|
|
26
|
28
|
let testSystem = new System()
|
|
27
|
29
|
let testContainer = new Container({ l: 10, w: 10, h: 10 })
|
|
28
|
30
|
let mockTemp = 70
|
|
|
@@ -30,10 +32,7 @@ test('system - instiantes channels with readers correctly', () => {
|
|
30
|
32
|
controllerTypes.temp,
|
|
31
|
33
|
() => mockTemp,
|
|
32
|
34
|
0.1,
|
|
33
|
|
- () => {
|
|
34
|
|
- console.log('tick')
|
|
35
|
|
- return 'tick'
|
|
36
|
|
- }
|
|
|
35
|
+ () => 'tick'
|
|
37
|
36
|
)
|
|
38
|
37
|
const cT = makeContainerT([testInConf], [], testContainer)
|
|
39
|
38
|
testSystem.add('aaa', cT)
|
|
|
@@ -42,14 +41,5 @@ test('system - instiantes channels with readers correctly', () => {
|
|
42
|
41
|
|
|
43
|
42
|
let chan = testSystem.inputs[0].channel
|
|
44
|
43
|
expect(chan.interval).toStrictEqual(0.1)
|
|
45
|
|
-
|
|
46
|
|
- // Test that the channel and channel.reader are working
|
|
47
|
|
- expect(chan.val).toStrictEqual(70)
|
|
48
|
|
- expect(chan.unit).toStrictEqual('F')
|
|
49
|
|
- expect(chan.inRange).toStrictEqual(false)
|
|
50
|
44
|
expect(testSystem.inputs[0].onUpdate()).toStrictEqual('tick')
|
|
51
|
|
-
|
|
52
|
|
- mockTemp = 79
|
|
53
|
|
- chan = chan.update()
|
|
54
|
|
- expect(chan.val).toStrictEqual(79)
|
|
55
|
45
|
})
|