Skip to content
This repository was archived by the owner on May 14, 2020. It is now read-only.

Commit

Permalink
tests: Add E2E tests for the new /api/search/stats route and fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Apr 27, 2020
1 parent e5e2749 commit 608b716
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
51 changes: 51 additions & 0 deletions tests/Feature/ApiTest.php
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]
]);
}
}
6 changes: 3 additions & 3 deletions tests/Feature/FrontTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
final class FrontTest extends TestCase
{
/**
* Test the the welcome page works
* Test that the welcome page works
*
* @return void
*/
Expand All @@ -19,7 +19,7 @@ public function testWelcomePage(): void
}

/**
* Test the the search page works
* Test that the search page works
*
* @return void
*/
Expand All @@ -31,7 +31,7 @@ public function testSearchPage(): void
}

/**
* Test the the search page works with query params
* Test that the search page works with query params
*
* @return void
*/
Expand Down

0 comments on commit 608b716

Please sign in to comment.