Skip to content

Commit 041eb54

Browse files
committed
Add Missing Tests
1 parent aeaf20e commit 041eb54

File tree

3 files changed

+105
-6
lines changed

3 files changed

+105
-6
lines changed

tests/Unit/Traits/Configuration/SearchConfigurationTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public function test_cant_set_search_debounce_with_other_search_modifiers(): voi
7474
{
7575
$this->expectException(DataTableConfigurationException::class);
7676

77-
$this->basicTable->setSearchDebounce(1000);
7877
$this->basicTable->setSearchDefer();
78+
$this->basicTable->setSearchDebounce(1000);
7979
}
8080

8181
public function test_can_set_search_defer(): void
@@ -92,8 +92,8 @@ public function test_cant_set_search_defer_with_other_search_modifiers(): void
9292
{
9393
$this->expectException(DataTableConfigurationException::class);
9494

95-
$this->basicTable->setSearchDefer();
9695
$this->basicTable->setSearchDebounce(1000);
96+
$this->basicTable->setSearchDefer();
9797
}
9898

9999
public function test_can_set_search_lazy(): void
@@ -110,8 +110,8 @@ public function test_cant_set_search_lazy_with_other_search_modifiers(): void
110110
{
111111
$this->expectException(DataTableConfigurationException::class);
112112

113-
$this->basicTable->setSearchLazy();
114113
$this->basicTable->setSearchDebounce(1000);
114+
$this->basicTable->setSearchLazy();
115115
}
116116

117117
public function test_can_set_search_live(): void
@@ -128,8 +128,8 @@ public function test_cant_set_search_live_with_other_search_modifiers(): void
128128
{
129129
$this->expectException(DataTableConfigurationException::class);
130130

131-
$this->basicTable->setSearchLive();
132131
$this->basicTable->setSearchDebounce(1000);
132+
$this->basicTable->setSearchLive();
133133
}
134134

135135
public function test_can_set_search_blur(): void
@@ -146,8 +146,8 @@ public function test_cant_set_search_blur_with_other_search_modifiers(): void
146146
{
147147
$this->expectException(DataTableConfigurationException::class);
148148

149-
$this->basicTable->setSearchBlur();
150149
$this->basicTable->setSearchDefer();
150+
$this->basicTable->setSearchBlur();
151151
}
152152

153153
public function test_can_set_search_throttle(): void
@@ -165,8 +165,8 @@ public function test_cant_set_search_throttle_with_other_search_modifiers(): voi
165165
{
166166
$this->expectException(DataTableConfigurationException::class);
167167

168-
$this->basicTable->setSearchThrottle(1000);
169168
$this->basicTable->setSearchDefer();
169+
$this->basicTable->setSearchThrottle(1000);
170170
}
171171

172172
public function test_can_set_search_placeholder(): void
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits\Helpers;
4+
5+
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
6+
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
7+
8+
final class QueryStringHelpersTest extends TestCase
9+
{
10+
public function test_check_querystring_returns_empty_if_disabled(): void
11+
{
12+
13+
$testTableQueryString = new class extends PetsTable
14+
{
15+
public function configure(): void
16+
{
17+
parent::configure();
18+
$this->setQueryStringDisabled();
19+
}
20+
21+
public function getCurrentQueryStringBinding(): array
22+
{
23+
return $this->queryStringWithQueryString();
24+
}
25+
};
26+
27+
$testTableQueryString->mountManagesFilters();
28+
$testTableQueryString->configure();
29+
$testTableQueryString->boot();
30+
$testTableQueryString->bootedComponentUtilities();
31+
$testTableQueryString->bootedManagesFilters();
32+
$testTableQueryString->bootedWithColumns();
33+
$testTableQueryString->bootedWithColumnSelect();
34+
$testTableQueryString->bootedWithSecondaryHeader();
35+
$testTableQueryString->booted();
36+
37+
$this->assertSame([], $testTableQueryString->getCurrentQueryStringBinding());
38+
39+
40+
}
41+
42+
public function test_check_querystring_returns_default_if_enabled(): void
43+
{
44+
45+
$testTableQueryString = new class extends PetsTable
46+
{
47+
public function configure(): void
48+
{
49+
parent::configure();
50+
$this->setQueryStringEnabled();
51+
}
52+
53+
public function getCurrentQueryStringBinding(): array
54+
{
55+
return $this->queryStringWithQueryString();
56+
}
57+
};
58+
59+
$testTableQueryString->mountManagesFilters();
60+
$testTableQueryString->configure();
61+
$testTableQueryString->boot();
62+
$testTableQueryString->bootedComponentUtilities();
63+
$testTableQueryString->bootedManagesFilters();
64+
$testTableQueryString->bootedWithColumns();
65+
$testTableQueryString->bootedWithColumnSelect();
66+
$testTableQueryString->bootedWithSecondaryHeader();
67+
$testTableQueryString->booted();
68+
69+
$this->assertSame(['table' => ['except' => null, 'history' => false, 'keep' => false, 'as' => 'table']], $testTableQueryString->getCurrentQueryStringBinding());
70+
71+
72+
}
73+
74+
75+
}

tests/Unit/Traits/Helpers/SearchHelpersTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,28 @@ public function resetSearchConfiguration(): self
194194
$this->assertSame('.live.throttle.599ms', $temp->getSearchOptions());
195195

196196
}
197+
198+
199+
public function test_can_get_search_term_with_trim(): void
200+
{
201+
$this->basicTable->setTrimSearchStringEnabled();
202+
$this->basicTable->setSearch('Anthony');
203+
$this->assertSame('Anthony', $this->basicTable->getSearch());
204+
$this->basicTable->setSearch('Bob ');
205+
$this->assertSame('Bob', $this->basicTable->getSearch());
206+
$this->basicTable->setSearch(' Bill ');
207+
$this->assertSame('Bill', $this->basicTable->getSearch());
208+
209+
}
210+
211+
public function test_can_get_search_term_without_trim(): void
212+
{
213+
$this->basicTable->setTrimSearchStringDisabled();
214+
$this->basicTable->setSearch('Ben ');
215+
$this->assertSame('Ben ', $this->basicTable->getSearch());
216+
$this->basicTable->setSearch(' Baz ');
217+
$this->assertSame(' Baz ', $this->basicTable->getSearch());
218+
219+
}
220+
197221
}

0 commit comments

Comments
 (0)