@@ -568,7 +568,7 @@ describe("Wrapping AbortController as a state machine", () => {
568
568
} ) ;
569
569
570
570
describe ( "AbortOwner" , ( ) => {
571
- it ( "aborts" , async ( ) => {
571
+ it . skip ( "aborts" , async ( ) => {
572
572
const machine = start ( AbortOwner ) ;
573
573
574
574
expect ( machine . current ) . toEqual ( "initial" ) ;
@@ -587,6 +587,34 @@ describe("Wrapping AbortController as a state machine", () => {
587
587
} ) ;
588
588
} ) ;
589
589
590
+ describe ( "Button click" , ( ) => {
591
+ function ButtonClickListener ( button : HTMLButtonElement ) {
592
+ function * initial ( ) {
593
+ yield on ( "click" , clicked ) ;
594
+ yield listenTo ( button , "click" ) ;
595
+ }
596
+ function * clicked ( ) { }
597
+
598
+ return initial ;
599
+ }
600
+
601
+ it ( "listens when button clicks" , ( ) => {
602
+ const button = document . createElement ( 'button' ) ;
603
+ const machine = start ( ButtonClickListener . bind ( null , button ) ) ;
604
+
605
+ expect ( machine . current ) . toEqual ( "initial" ) ;
606
+ expect ( machine . changeCount ) . toEqual ( 0 ) ;
607
+
608
+ button . click ( ) ;
609
+ expect ( machine . current ) . toEqual ( "clicked" ) ;
610
+ expect ( machine . changeCount ) . toEqual ( 1 ) ;
611
+
612
+ button . click ( ) ;
613
+ expect ( machine . current ) . toEqual ( "clicked" ) ;
614
+ expect ( machine . changeCount ) . toEqual ( 1 ) ;
615
+ } ) ;
616
+ } ) ;
617
+
590
618
/*describe("Counter", () => {
591
619
function* Counter() {
592
620
function* initial() {
0 commit comments