Skip to content

Commit

Permalink
fix: clean code for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhongit committed Jan 12, 2024
1 parent d4a4164 commit ce1dd21
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
13 changes: 7 additions & 6 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
19 changes: 11 additions & 8 deletions tests/NotifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]);
});

0 comments on commit ce1dd21

Please sign in to comment.