Skip to content

Commit

Permalink
Add Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe authored Nov 1, 2023
1 parent 32cdcd4 commit b715f2e
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/Views/Filters/DateFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,14 @@ public function test_can_check_if_can_set_default_values(): void

$this->assertSame('2023-03-01', self::$filterInstance->getFilterDefaultValue());
}

/**
* @test
*/
public function can_set_custom_filter_view(): void
{
$this->assertSame('livewire-tables::components.tools.filters.date', self::$filterInstance->getViewPath());
self::$filterInstance->setCustomView('test-custom-filter-view');
$this->assertSame('test-custom-filter-view', self::$filterInstance->getViewPath());
}
}
11 changes: 11 additions & 0 deletions tests/Views/Filters/DateRangeFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,17 @@ public function can_get_datestring(): void
$this->assertSame('2020-01-01 to 2020-02-02', $filter->getDateString(['2020-02-02', '2020-01-01']));
$this->assertSame('2021-03-03 to 2021-04-04', $filter->getDateString(['minDate' => '2021-03-03', 'maxDate' => '2021-04-04']));
$this->assertSame('2022-05-05 to 2022-06-06', $filter->getDateString('2022-05-05,to,2022-06-06'));
}

/**
* @test
*/
public function can_set_custom_filter_view(): void
{
$filter = DateRangeFilter::make('Active');
$this->assertSame('livewire-tables::components.tools.filters.date-range', $filter->getViewPath());
$filter->setCustomView('test-custom-filter-view');
$this->assertSame('test-custom-filter-view', $filter->getViewPath());
}

}
11 changes: 11 additions & 0 deletions tests/Views/Filters/DateTimeFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,15 @@ public function test_can_check_if_can_set_default_values(): void

$this->assertSame('2023-01-01T10:00', self::$filterInstance->getFilterDefaultValue());
}

/**
* @test
*/
public function can_set_custom_filter_view(): void
{
$this->assertSame('livewire-tables::components.tools.filters.datetime', self::$filterInstance->getViewPath());
self::$filterInstance->setCustomView('test-custom-filter-view');
$this->assertSame('test-custom-filter-view', self::$filterInstance->getViewPath());
}

}
10 changes: 10 additions & 0 deletions tests/Views/Filters/FilterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,14 @@ public function can_check_if_filter_is_reset_by_clear_button(): void

$this->assertFalse(self::$filterInstance->isResetByClearButton());
}

/**
* @test
*/
public function can_set_custom_filter_view(): void
{
$this->assertSame('livewire-tables::components.tools.filters.date', self::$filterInstance->getViewPath());
self::$filterInstance->setCustomView('test-custom-filter-view');
$this->assertSame('test-custom-filter-view', self::$filterInstance->getViewPath());
}
}
13 changes: 13 additions & 0 deletions tests/Views/Filters/MultiSelectDropdownFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,17 @@ public function test_can_check_if_can_set_default_value(array $optionsArray): vo

$this->assertSame(['1', '3'], $filter->getFilterDefaultValue());
}

/**
* @test
*
* @depends testArraySetup
*/
public function can_set_custom_filter_view(array $optionsArray): void
{
$filter = MultiSelectDropdownFilter::make('BreedID')->options($optionsArray);
$this->assertSame('livewire-tables::components.tools.filters.multi-select-dropdown', $filter->getViewPath());
$filter->setCustomView('test-custom-filter-view');
$this->assertSame('test-custom-filter-view', $filter->getViewPath());
}
}
11 changes: 11 additions & 0 deletions tests/Views/Filters/MultiSelectFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,15 @@ public function can_get_if_filter_empty(): void
$this->assertTrue($filter->isEmpty('test'));
$this->assertFalse($filter->isEmpty([1]));
}

/**
* @test
*/
public function can_set_custom_filter_view(): void
{
$filter = MultiSelectFilter::make('Active');
$this->assertSame('livewire-tables::components.tools.filters.multi-select', $filter->getViewPath());
$filter->setCustomView('test-custom-filter-view');
$this->assertSame('test-custom-filter-view', $filter->getViewPath());
}
}
11 changes: 11 additions & 0 deletions tests/Views/Filters/NumberFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,15 @@ public function test_can_check_if_can_set_default_value(): void

$this->assertSame('123', $filter->getFilterDefaultValue());
}

/**
* @test
*/
public function can_set_custom_filter_view(): void
{
$filter = NumberFilter::make('Active');
$this->assertSame('livewire-tables::components.tools.filters.number', $filter->getViewPath());
$filter->setCustomView('test-custom-filter-view');
$this->assertSame('test-custom-filter-view', $filter->getViewPath());
}
}
11 changes: 11 additions & 0 deletions tests/Views/Filters/NumberRangeFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,15 @@ public function can_check_if_filter_is_reset_by_clear_button(): void

$this->assertFalse($filter->isResetByClearButton());
}

/**
* @test
*/
public function can_set_custom_filter_view(): void
{
$filter = NumberRangeFilter::make('Active');
$this->assertSame('livewire-tables::components.tools.filters.number-range', $filter->getViewPath());
$filter->setCustomView('test-custom-filter-view');
$this->assertSame('test-custom-filter-view', $filter->getViewPath());
}
}
10 changes: 10 additions & 0 deletions tests/Views/Filters/SelectFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,14 @@ public function test_can_check_if_can_set_default_value(): void

$this->assertSame('1', self::$filterInstance->getFilterDefaultValue());
}

/**
* @test
*/
public function can_set_custom_filter_view(): void
{
$this->assertSame('livewire-tables::components.tools.filters.select', self::$filterInstance->getViewPath());
self::$filterInstance->setCustomView('test-custom-filter-view');
$this->assertSame('test-custom-filter-view', self::$filterInstance->getViewPath());
}
}
12 changes: 12 additions & 0 deletions tests/Views/Filters/TextFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,16 @@ public function can_get_if_text_filter_empty(): void
$this->assertFalse($filter->isEmpty('123'));
$this->assertFalse($filter->isEmpty('test'));
}

/**
* @test
*/
public function can_set_custom_filter_view(): void
{
$filter = TextFilter::make('Active');

$this->assertSame('livewire-tables::components.tools.filters.text-field', $filter->getViewPath());
$filter->setCustomView('test-custom-filter-view');
$this->assertSame('test-custom-filter-view', $filter->getViewPath());
}
}

0 comments on commit b715f2e

Please sign in to comment.