@@ -673,8 +673,7 @@ class RealRenderTesterTest {
673673 }
674674 }
675675
676- @Suppress(" DEPRECATION" )
677- @Test fun `verifyAction and verifyActionResult pass when no action processed` () {
676+ @Test fun `verifyAction allows no action` () {
678677 val workflow = Workflow .stateless<Unit , Nothing , Sink <TestAction >> {
679678 actionSink.contraMap { it }
680679 }
@@ -690,74 +689,7 @@ class RealRenderTesterTest {
690689 }
691690 }
692691
693- @Suppress(" DEPRECATION" )
694- @Test fun `verifyActionResult works` () {
695- class TestAction : WorkflowAction <String , String > {
696- override fun Updater <String , String >.apply () {
697- state = " new state"
698- setOutput(" output" )
699- }
700- }
701-
702- val workflow = Workflow .stateful<Unit , String , String , Sink <TestAction >>(
703- initialState = { " initial" },
704- render = { _, _ -> actionSink.contraMap { it } }
705- )
706- val testResult = workflow.testRender(Unit )
707- .render { sink ->
708- sink.send(TestAction ())
709- }
710-
711- testResult.verifyActionResult { state, output ->
712- assertEquals(" new state" , state)
713- assertEquals(" output" , output)
714- }
715- }
716-
717- @Test fun `verifyActionState and verifyActionOutput chain` () {
718- class TestAction : WorkflowAction <String , String > {
719- override fun Updater <String , String >.apply () {
720- state = " new state"
721- setOutput(" output" )
722- }
723- }
724-
725- val workflow = Workflow .stateful<Unit , String , String , Sink <TestAction >>(
726- initialState = { " initial" },
727- render = { _, _ -> actionSink.contraMap { it } }
728- )
729- val testResult = workflow.testRender(Unit )
730- .render { sink ->
731- sink.send(TestAction ())
732- }
733-
734- testResult
735- .verifyActionState { assertEquals(" new state" , it) }
736- .verifyActionOutput { assertEquals(" output" , it) }
737- }
738-
739- @Test fun `verifyActionState and verifyNoActionOutput chain` () {
740- class TestAction : WorkflowAction <String , String > {
741- override fun Updater <String , String >.apply () {
742- state = " new state"
743- }
744- }
745-
746- val workflow = Workflow .stateful<Unit , String , String , Sink <TestAction >>(
747- initialState = { " initial" },
748- render = { _, _ -> actionSink.contraMap { it } }
749- )
750- val testResult = workflow.testRender(Unit )
751- .render { sink ->
752- sink.send(TestAction ())
753- }
754-
755- testResult
756- .verifyActionState { assertEquals(" new state" , it) }
757- .verifyNoActionOutput()
758- }
759-
760- @Test fun `verifyActionState allows no action` () {
692+ @Test fun `verifyActionResult allows no action` () {
761693 val workflow = Workflow .stateless<Unit , Nothing , Sink <TestAction >> {
762694 actionSink.contraMap { it }
763695 }
@@ -766,52 +698,16 @@ class RealRenderTesterTest {
766698 // Don't send to sink!
767699 }
768700
769- testResult.verifyAction { assertEquals(noAction(), it) }
770- testResult.verifyActionState { newState ->
701+ testResult.verifyActionResult { newState, output ->
771702 assertSame(Unit , newState)
703+ assertNull(output)
772704 }
773705 }
774706
775- @Test fun `verifyActionState handles new state` () {
707+ @Test fun `verifyActionResult handles new state and output ` () {
776708 class TestAction : WorkflowAction <String , String > {
777709 override fun Updater <String , String >.apply () {
778710 state = " new state"
779- }
780- }
781-
782- val workflow = Workflow .stateful<Unit , String , String , Sink <TestAction >>(
783- initialState = { " initial" },
784- render = { _, _ -> actionSink.contraMap { it } }
785- )
786- val testResult = workflow.testRender(Unit )
787- .render { sink ->
788- sink.send(TestAction ())
789- }
790-
791- testResult.verifyActionState { state ->
792- assertEquals(" new state" , state)
793- }
794- }
795-
796- @Test fun `verifyActionOutput allows no action` () {
797- val workflow = Workflow .stateless<Unit , Nothing , Sink <TestAction >> {
798- actionSink.contraMap { it }
799- }
800- val testResult = workflow.testRender(Unit )
801- .render {
802- // Don't send to sink!
803- }
804-
805- testResult.verifyAction { assertEquals(noAction(), it) }
806- val error = assertFailsWith<AssertionError > {
807- testResult.verifyActionOutput {}
808- }
809- assertEquals(" Expected action to set an output" , error.message)
810- }
811-
812- @Test fun `verifyActionOutput handles output` () {
813- class TestAction : WorkflowAction <String , String > {
814- override fun Updater <String , String >.apply () {
815711 setOutput(" output" )
816712 }
817713 }
@@ -825,44 +721,10 @@ class RealRenderTesterTest {
825721 sink.send(TestAction ())
826722 }
827723
828- testResult.verifyActionOutput { output ->
829- assertEquals(" output" , output)
830- }
831- }
832-
833- @Test fun `verifyNoActionOutput allows no action` () {
834- val workflow = Workflow .stateless<Unit , Nothing , Sink <TestAction >> {
835- actionSink.contraMap { it }
836- }
837- val testResult = workflow.testRender(Unit )
838- .render {
839- // Don't send to sink!
840- }
841-
842- testResult.verifyAction { assertEquals(noAction(), it) }
843- testResult.verifyNoActionOutput()
844- }
845-
846- @Test fun `verifyNoActionOutput fails when output is set` () {
847- class TestAction : WorkflowAction <String , String > {
848- override fun Updater <String , String >.apply () {
849- setOutput(" output" )
850- }
851- }
852-
853- val workflow = Workflow .stateful<Unit , String , String , Sink <TestAction >>(
854- initialState = { " initial" },
855- render = { _, _ -> actionSink.contraMap { it } }
856- )
857- val testResult = workflow.testRender(Unit )
858- .render { sink ->
859- sink.send(TestAction ())
860- }
861-
862- val error = assertFailsWith<AssertionError > {
863- testResult.verifyNoActionOutput()
724+ testResult.verifyActionResult { state, output ->
725+ assertEquals(" new state" , state)
726+ assertEquals(" output" , output?.value)
864727 }
865- assertEquals(" Expected no output, but action set output to: output" , error.message)
866728 }
867729
868730 @Test fun `render is executed multiple times` () {
0 commit comments