From 019dd091582532a8a33b139d3821abcb0a6cc830 Mon Sep 17 00:00:00 2001 From: domi41 Date: Tue, 11 Aug 2020 01:28:19 +0200 Subject: [PATCH] test: unit-test the MajorityJudgmentChatCommandJudgmentsProvider MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the type of thing that will benefit a lot from unit tests, bacause we'll be able to quickly experiment feeding it malicious data, since that data will come from userland and may not be trusted. We're going to start with the following syntax : such as A2 means give grade #2 (passable) to candidate A Grades (when there are 6): 0. TO_REJECT .0 1. POOR .1 2. PASSABLE .2 3. GOOD .3 4. VERY_GOOD .4 5. EXCELLENT .5 This will require showing ABC letters in the results guiā€¦ Hmmm. --- tests/commands.test.gd | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/commands.test.gd diff --git a/tests/commands.test.gd b/tests/commands.test.gd new file mode 100644 index 0000000..5c9a8a2 --- /dev/null +++ b/tests/commands.test.gd @@ -0,0 +1,40 @@ +extends WAT.Test + +var provider : MajorityJudgmentChatCommandJudgmentsProvider + + +func title(): + return "Test Command Provider" + + +func start(): + # Runs before all test related methods once + self.provider = MajorityJudgmentChatCommandJudgmentsProvider.new() + watch(self.provider, "judgment_emitted") + + +func pre(): + # Runs before each test method + pass + + +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]) + + +func do_test_single_command(command:String, expected:Array): + 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" + )