extends WAT.Test var provider : MajorityJudgmentChatCommandJudgmentsProvider func title(): return "Test Command Provider" func start(): # Runs before all test related methods once pass func pre(): # Runs before each test method refresh_provider() func refresh_provider(): if self.provider: unwatch(self.provider, "judgment_emitted") self.provider = MajorityJudgmentChatCommandJudgmentsProvider.new() watch(self.provider, "judgment_emitted") func test_single_command(): do_test_single_command("A0", [0, 0]) do_test_single_command("B2", [1, 2]) do_test_single_command("e4", [4, 4]) do_test_single_command("E4", [4, 4]) func test_multi_command(): do_test_multi_command("A4 B3 C3", [[0, 4],[1, 3],[2, 3]]) do_test_multi_command("B4b1L0n3", [[1, 4],[1, 1],[11, 0],[13, 3]]) func do_test_single_command(command:String, expected:Array): refresh_provider() var author = "Tester" self.provider.process_chat_command(author, command) asserts.signal_was_emitted( self.provider, "judgment_emitted", "Signal was emitted" ) asserts.signal_was_emitted_with_arguments( self.provider, "judgment_emitted", [author, expected[0], expected[1]], "Signal was emitted with correct arguments" ) func do_test_multi_command(command:String, expecteds:Array): refresh_provider() var author = "Tester" self.provider.process_chat_command(author, command) asserts.signal_was_emitted_x_times( self.provider, "judgment_emitted", expecteds.size(), "Signal was emitted %d times" % expecteds.size() ) for expected in expecteds: asserts.signal_was_emitted_with_arguments( self.provider, "judgment_emitted", [author, expected[0], expected[1]], "Signal was emitted with correct arguments" )