@@ -418,43 +418,37 @@ return function()
418418
419419 monarch .show (SCREEN1 )
420420 assert (wait_until_not_busy ())
421- assert (mock_msg .messages (URL1 )[1 ].message_id == monarch .SCREEN_TRANSITION_IN_STARTED )
422- assert (mock_msg .messages (URL1 )[1 ].message .screen == SCREEN1 )
423- assert (mock_msg .messages (URL2 )[1 ].message_id == monarch .SCREEN_TRANSITION_IN_STARTED )
424- assert (mock_msg .messages (URL2 )[1 ].message .screen == SCREEN1 )
425- assert (mock_msg .messages (URL1 )[2 ].message_id == monarch .SCREEN_TRANSITION_IN_FINISHED )
426- assert (mock_msg .messages (URL1 )[2 ].message .screen == SCREEN1 )
427- assert (mock_msg .messages (URL2 )[2 ].message_id == monarch .SCREEN_TRANSITION_IN_FINISHED )
428- assert (mock_msg .messages (URL2 )[2 ].message .screen == SCREEN1 )
429421
430422 monarch .remove_listener (URL2 )
431423 monarch .show (SCREEN2 )
432424 assert (wait_until_not_busy ())
433425
434- assert (# mock_msg .messages (URL1 ) == 6 )
435- assert (# mock_msg .messages (URL2 ) == 2 )
436- assert (mock_msg .messages (URL1 )[3 ].message_id == monarch .SCREEN_TRANSITION_IN_STARTED )
437- assert (mock_msg .messages (URL1 )[3 ].message .screen == SCREEN2 )
438- assert (mock_msg .messages (URL1 )[4 ].message_id == monarch .SCREEN_TRANSITION_OUT_STARTED )
439- assert (mock_msg .messages (URL1 )[4 ].message .screen == SCREEN1 )
440- assert (mock_msg .messages (URL1 )[5 ].message_id == monarch .SCREEN_TRANSITION_IN_FINISHED )
441- assert (mock_msg .messages (URL1 )[5 ].message .screen == SCREEN2 )
442- assert (mock_msg .messages (URL1 )[6 ].message_id == monarch .SCREEN_TRANSITION_OUT_FINISHED )
443- assert (mock_msg .messages (URL1 )[6 ].message .screen == SCREEN1 )
444-
445426 monarch .back ()
446427 assert (wait_until_not_busy ())
447428
448- assert (# mock_msg .messages (URL1 ) == 10 )
449- assert (# mock_msg .messages (URL2 ) == 2 )
450- assert (mock_msg .messages (URL1 )[7 ].message_id == monarch .SCREEN_TRANSITION_IN_STARTED )
451- assert (mock_msg .messages (URL1 )[7 ].message .screen == SCREEN1 )
452- assert (mock_msg .messages (URL1 )[8 ].message_id == monarch .SCREEN_TRANSITION_OUT_STARTED )
453- assert (mock_msg .messages (URL1 )[8 ].message .screen == SCREEN2 )
454- assert (mock_msg .messages (URL1 )[9 ].message_id == monarch .SCREEN_TRANSITION_IN_FINISHED )
455- assert (mock_msg .messages (URL1 )[9 ].message .screen == SCREEN1 )
456- assert (mock_msg .messages (URL1 )[10 ].message_id == monarch .SCREEN_TRANSITION_OUT_FINISHED )
457- assert (mock_msg .messages (URL1 )[10 ].message .screen == SCREEN2 )
429+ local messages = mock_msg .filter (URL1 , function (m )
430+ return m .message .screen == SCREEN1
431+ end )
432+ assert (messages [1 ].message_id == monarch .SCREEN_TRANSITION_IN_STARTED )
433+ assert (messages [2 ].message_id == monarch .SCREEN_TRANSITION_IN_FINISHED )
434+ assert (messages [3 ].message_id == monarch .SCREEN_TRANSITION_OUT_STARTED )
435+ assert (messages [4 ].message_id == monarch .SCREEN_TRANSITION_OUT_FINISHED )
436+ assert (messages [5 ].message_id == monarch .SCREEN_TRANSITION_IN_STARTED )
437+ assert (messages [6 ].message_id == monarch .SCREEN_TRANSITION_IN_FINISHED )
438+
439+ messages = mock_msg .filter (URL2 , function (m )
440+ return m .message .screen == SCREEN1
441+ end )
442+ assert (messages [1 ].message_id == monarch .SCREEN_TRANSITION_IN_STARTED )
443+ assert (messages [2 ].message_id == monarch .SCREEN_TRANSITION_IN_FINISHED )
444+
445+ messages = mock_msg .filter (URL1 , function (m )
446+ return m .message .screen == SCREEN2
447+ end )
448+ assert (messages [1 ].message_id == monarch .SCREEN_TRANSITION_IN_STARTED )
449+ assert (messages [2 ].message_id == monarch .SCREEN_TRANSITION_IN_FINISHED )
450+ assert (messages [3 ].message_id == monarch .SCREEN_TRANSITION_OUT_STARTED )
451+ assert (messages [4 ].message_id == monarch .SCREEN_TRANSITION_OUT_FINISHED )
458452 end )
459453
460454 it (" should be able to show a screen even while it is preloading" , function ()
0 commit comments