-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompradprogvm.test.ts
53 lines (49 loc) · 1.5 KB
/
compradprogvm.test.ts
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
import { deepEqual, ok } from 'node:assert/strict'
import { describe, it } from 'node:test'
import { firstValueFrom, take, toArray } from 'rxjs'
import { TestScheduler } from 'rxjs/testing'
import { CompRadProgVm } from './compradprogvm.js'
describe('CompRadProgVm', () => {
it('adds items', () => {
const vm = new CompRadProgVm()
const startlength = vm.progressCount
vm.addItem()
ok(vm.progressCount > startlength)
})
it('pauses all', async () => {
const vm = new CompRadProgVm()
vm.addItem()
vm.addItem()
vm.pauseAll()
const paused = await firstValueFrom(vm.pausedStatus)
ok(paused.every((paused) => paused))
})
it('unpauses all', async () => {
const vm = new CompRadProgVm()
vm.addItem()
vm.addItem()
vm.pauseAll()
vm.unpauseAll()
const paused = await firstValueFrom(vm.pausedStatus)
ok(paused.every((paused) => !paused))
})
it.skip('ticks forward', async () => {
// Test doesn't work because tick operations have embedded promises to update ProgVm ticks
const testScheduler = new TestScheduler((actual, expected) =>
deepEqual(actual, expected),
)
testScheduler.run(({ cold, expectObservable }) => {
const ticks = cold('--x--x')
const expected = ' a-b--c'
const expectedValues = {
a: 0,
b: 1,
c: 1,
}
const vm = new CompRadProgVm(undefined, ticks)
vm.addItem()
vm.addItem()
expectObservable(vm.currentVal).toBe(expected, expectedValues)
})
})
})