From ce1dd21d3a732c1511c2a3391fcb50ae8bf85afe Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Fri, 12 Jan 2024 16:42:01 +0700 Subject: [PATCH] fix: clean code for tests --- tests/ConfigTest.php | 13 +++++++------ tests/NotifierTest.php | 19 +++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 3c14054..dd0ea7a 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -22,20 +22,21 @@ it('platform can be set for event with platform file', function () { $this->bot->setPlatFormForEvent('gitlab', 'storage/json/tgn/gitlab-events.json'); - expect($this->bot->event->platform)->toBe('gitlab'); - expect($this->bot->event->getPlatformFile())->toBe('storage/json/tgn/gitlab-events.json'); + expect($this->bot->event->platform)->toBe('gitlab') + ->and($this->bot->event->getPlatformFile()) + ->toBe('storage/json/tgn/gitlab-events.json'); }); it('can get json config for event - github', function () { $this->bot->setPlatFormForEvent(); - expect($this->bot->event->getEventConfig())->toBeArray(); - expect($this->bot->event->getEventConfig())->toHaveKey('issue_comment'); + expect($this->bot->event->getEventConfig())->toBeArray() + ->and($this->bot->event->getEventConfig())->toHaveKey('issue_comment'); }); it('can get json config for event - gitlab', function () { $this->bot->setPlatFormForEvent('gitlab', 'storage/json/tgn/gitlab-events.json'); - expect($this->bot->event->getEventConfig())->toBeArray(); - expect($this->bot->event->getEventConfig())->toHaveKey('tag_push'); + expect($this->bot->event->getEventConfig())->toBeArray() + ->and($this->bot->event->getEventConfig())->toHaveKey('tag_push'); }); it('setting file is valid', function () { diff --git a/tests/NotifierTest.php b/tests/NotifierTest.php index cfeb682..83f8f0f 100644 --- a/tests/NotifierTest.php +++ b/tests/NotifierTest.php @@ -8,18 +8,21 @@ it('validates that the event files exist', function () { $this->nofitier->setPlatFormForEvent('gitlab', 'storage/json/tgn/gitlab-events.json'); - expect($this->nofitier->event->getEventConfig())->toBeArray(); - expect($this->nofitier->event->getEventConfig())->toHaveKey('tag_push'); + expect($this->nofitier->event->getEventConfig())->toBeArray() + ->and($this->nofitier->event->getEventConfig())->toHaveKey('tag_push'); $this->nofitier->setPlatFormForEvent('github', 'storage/json/tgn/github-events.json'); - expect($this->nofitier->event->getEventConfig())->toBeArray(); - expect($this->nofitier->event->getEventConfig())->toHaveKey('issue_comment'); + expect($this->nofitier->event->getEventConfig())->toBeArray() + ->and($this->nofitier->event->getEventConfig()) + ->toHaveKey('issue_comment'); }); it('can parse notification chat IDs', function () { $chatThreadMapping = $this->nofitier->parseNotifyChatIds('-1201937489183;-1008168942527:46,2'); - expect($chatThreadMapping)->toBeArray(); - expect($chatThreadMapping)->toHaveKey('-1008168942527'); - expect($chatThreadMapping['-1008168942527'])->toBeArray(); - expect($chatThreadMapping['-1008168942527'])->toBe([0 => '46', 1 => '2']); + expect($chatThreadMapping)->toBeArray() + ->and($chatThreadMapping)->toHaveKey('-1008168942527') + ->and($chatThreadMapping['-1008168942527'])->toBeArray() + ->and($chatThreadMapping['-1008168942527'])->toBe([ + 0 => '46', 1 => '2' + ]); });