Skip to content

Commit

Permalink
Test for additional search functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed May 12, 2021
1 parent daf6b4f commit 7d54c72
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/Unit/Helpers/SearchHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Tests\FeatureTestCase;
use App\Helpers\SearchHelper;
use App\Models\Contact\Contact;
use App\Models\Contact\Note;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class SearchHelperTest extends FeatureTestCase
Expand All @@ -27,6 +28,41 @@ public function searching_for_contacts_returns_a_collection_with_pagination()
$this->assertCount(1, $searchResults);
}

/** @test */
public function searching_with_notes()
{
$user = $this->signin();

$note = factory(Note::class)->create([
'account_id' => $user->account_id,
'body' => 'we met on github and talked about monica'
]);

$searchResults = SearchHelper::searchContacts('monica', 'created_at')
->paginate(1);

$this->assertNotNull($searchResults);
$this->assertInstanceOf('Illuminate\Pagination\LengthAwarePaginator', $searchResults);
$this->assertCount(1, $searchResults);
}

/** @test */
public function searching_with_introduction_information()
{
$user = $this->signin();

$contact = factory(Contact::class)->create([
'account_id' => $user->account_id,
'first_met_additional_info' => 'github'
]);
$searchResults = SearchHelper::searchContacts($contact->first_met_additional_info, 'created_at')
->paginate(1);

$this->assertNotNull($searchResults);
$this->assertInstanceOf('Illuminate\Pagination\LengthAwarePaginator', $searchResults);
$this->assertCount(1, $searchResults);
}

/** @test */
public function searching_with_wrong_search_field()
{
Expand Down

0 comments on commit 7d54c72

Please sign in to comment.