-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.skip.ts
62 lines (46 loc) · 1.33 KB
/
demo.skip.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
54
55
56
57
58
59
60
61
62
import { test } from 'uvu';
import * as assert from 'uvu/assert';
import { createEffect, createSignal, createRoot } from 'solid-js';
import { rootAndRun } from './helpers';
test('POC test', async () => {
const result = await new Promise<number | undefined>((resolve, _reject) => {
createRoot(withRxGraph);
function withRxGraph(dispose: () => void) {
const [count, setCount] = createSignal(0);
let result: number | undefined;
createEffect(() => {
console.log('running effect');
result = count();
});
setTimeout(() => {
console.log('incrementing');
setCount((n) => n + 1);
console.log('flushing');
dispose();
resolve(result);
});
console.log('end setup');
}
});
assert.equal(result, 1);
});
test('rootAndRun test', async () => {
const result = await rootAndRun(1000, function factory(done) {
const [count, setCount] = createSignal(0);
let result = -1;
createEffect(() => {
console.log('running effect');
result = count();
});
console.log('exiting setup');
return function task() {
console.log('incrementing');
setCount((n) => n + 1);
console.log('exiting task');
done(result);
};
});
console.log('comparing results');
assert.equal(result, 1);
});
test.run();