-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstateful.spec.ts
112 lines (102 loc) · 3.24 KB
/
stateful.spec.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import * as fc from 'fast-check'
import { CLASS_SELECTORS } from './cons';
import {
WriteInputCommand,
MarkAllCompletedCommand,
ToggleItemCompletedCommand,
TriggerEditingCommand,
EditTodoCommand,
EditEmptyCommand,
EditCancelCommand,
ClearCompletedCommand,
AddToDosCommands,
GoToAllCommand,
GoToActiveCommand,
GoToCompletedCommand,
GoBackCommand,
EnterCommand,
} from './commands';
import {
validToDoArbitrary,
whitespaceToDoArbitrary,
trimToDoArbitrary,
emptyToDoArbitrary,
} from './arbitraties';
import { modelMachine } from './modelMachine';
import { interpret } from 'xstate';
describe('Index', () => {
it(
'stateful',
async () => {
// try {
await page.evaluateOnNewDocument(() => localStorage.clear());
await fc.assert(
fc.asyncProperty(
fc.commands(
[
validToDoArbitrary()
.map(toDo => new WriteInputCommand(toDo)),
whitespaceToDoArbitrary()
.map(toDo => new WriteInputCommand(toDo)),
trimToDoArbitrary()
.map(toDo => new WriteInputCommand(toDo)),
emptyToDoArbitrary()
.map(toDo => new WriteInputCommand(toDo)),
fc.constant(new EnterCommand()),
fc.array(validToDoArbitrary())
.map(toDos => new AddToDosCommands(toDos)),
fc.constant(new MarkAllCompletedCommand()),
fc.constant(new ToggleItemCompletedCommand()),
fc.nat().noShrink().map(number => new TriggerEditingCommand(number)),
fc.record({
toDo: validToDoArbitrary(),
number: fc.nat().noShrink()
})
.map(({ toDo, number }) => new EditTodoCommand(toDo, number)),
fc.record({
toDo: trimToDoArbitrary(),
number: fc.nat().noShrink()
})
.map(({ toDo, number }) => new EditTodoCommand(toDo, number)),
fc.nat().noShrink().map(number => new EditEmptyCommand(number)),
fc.record({
toDo: validToDoArbitrary(),
number: fc.nat().noShrink()
})
.map(({ toDo, number }) => new EditCancelCommand(toDo, number)),
fc.constant(new ClearCompletedCommand()),
fc.constant(new GoToAllCommand()),
fc.constant(new GoToActiveCommand()),
fc.constant(new GoToCompletedCommand()),
fc.constant(new GoBackCommand()),
],
// {
// replayPath: ""
// },
// 10,
),
async (commands) => {
await page.goto('http://todomvc.com/examples/react/', { waitUntil: 'networkidle2' });
await page.waitFor(CLASS_SELECTORS.NEW_TODO);
await fc.asyncModelRun(
() => ({
model: interpret(modelMachine).start(),
real: page
}),
commands
);
}),
{
// numRuns: 20,
numRuns: 100,
// verbose: true,
}
);
// } catch (e) {
// console.log(e)
// await page.waitFor(100000000)
// }
},
1000 * 60 * 10
)
})