This repository was archived by the owner on May 14, 2020. It is now read-only.
forked from B-Galati/gh-archive-keyword
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add E2E tests for the new /api/search/stats route and fix typos
- Loading branch information
1 parent
e5e2749
commit 608b716
Showing
2 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Tests\Feature; | ||
|
||
use Tests\TestCase; | ||
|
||
final class ApiTest extends TestCase | ||
{ | ||
/** | ||
* Test that the search API works | ||
* | ||
* @return void | ||
*/ | ||
public function testSearchApiInvalid(): void | ||
{ | ||
$response = $this->getJson('/api/search/stats'); | ||
$response->assertStatus(422); | ||
} | ||
|
||
/** | ||
* Test that the search API works with query params | ||
* | ||
* @return void | ||
*/ | ||
public function testSearchApiParam(): void | ||
{ | ||
$response = $this->getJson('/api/search/stats?searchDate=2030-04-26'); | ||
$response->assertStatus(200); | ||
$response->assertExactJson([ | ||
'commentsPoints' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
'commitsPoints' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
'pullsPoints' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | ||
]); | ||
} | ||
|
||
/** | ||
* Test that the search API works with query params | ||
* | ||
* @return void | ||
*/ | ||
public function testSearchApiParams(): void | ||
{ | ||
$response = $this->getJson('/api/search/stats?searchDate=2030-04-26&searchTerm=l'); | ||
$response->assertStatus(200); | ||
$response->assertExactJson([ | ||
'commentsPoints' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
'commitsPoints' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
'pullsPoints' => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters