File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * @jest -environment jsdom
3
+ */
4
+
5
+ import { on , start } from "./index" ;
6
+
7
+ describe ( "Egghead" , ( ) => {
8
+ describe ( "Space heater" , ( ) => {
9
+ function SpaceHeater ( ) {
10
+ function * PoweredOff ( ) {
11
+ yield on ( "TOGGLE_POWER" , PoweredOn ) ;
12
+ }
13
+ function * PoweredOn ( ) {
14
+ yield on ( "TOGGLE_POWER" , PoweredOff ) ;
15
+
16
+ function * LowHeat ( ) {
17
+ yield on ( "TOGGLE_HEAT" , HighHeat ) ;
18
+ }
19
+ function * HighHeat ( ) {
20
+ yield on ( "TOGGLE_HEAT" , HighHeat ) ;
21
+ }
22
+
23
+ return LowHeat ;
24
+ }
25
+
26
+ return PoweredOff ;
27
+ }
28
+
29
+ it ( "works as expected" , ( ) => {
30
+ const heater = start ( SpaceHeater ) ;
31
+
32
+ expect ( heater . value . state ) . toEqual ( "PoweredOff" ) ;
33
+
34
+ heater . next ( "TOGGLE_POWER" ) ;
35
+ expect ( heater . value . state ) . toEqual ( { "PoweredOn" : "LowHeat" } ) ;
36
+
37
+ heater . next ( "TOGGLE_HEAT" ) ;
38
+ expect ( heater . value . state ) . toEqual ( { "PoweredOn" : "HighHeat" } ) ;
39
+
40
+ heater . next ( "TOGGLE_POWER" ) ;
41
+ expect ( heater . value . state ) . toEqual ( "PoweredOff" ) ;
42
+ } ) ;
43
+ } ) ;
44
+
45
+ } ) ;
Original file line number Diff line number Diff line change @@ -972,6 +972,24 @@ describe("accumulate()", () => {
972
972
} ) ;
973
973
} ) ;
974
974
975
+ // describe("Parallel", () => {
976
+ // // See: https://twitter.com/StateML_org/status/1445502469497188362
977
+
978
+ // function* FileManager() {
979
+ // function* upload() {
980
+ // function* idle() {}
981
+ // function* pending() {}
982
+ // function* playground() {}
983
+
984
+ // }
985
+ // }
986
+
987
+ // it("can run", () => {
988
+ // const machine = start(Example);
989
+ // expect(machine.value.state).toEqual({ tooling: { viz:} })
990
+ // })
991
+ // });
992
+
975
993
/*describe("Counter", () => {
976
994
function* Counter() {
977
995
function* initial() {
You can’t perform that action at this time.
0 commit comments