Skip to content

Commit

Permalink
Merge pull request #2087 from rappasoft/development
Browse files Browse the repository at this point in the history
Add Missing Tools Tests (#2086)
  • Loading branch information
lrljoe authored Nov 21, 2024
2 parents 09d3aac + ae28d03 commit 9c27700
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 40 deletions.
8 changes: 4 additions & 4 deletions tests/Unit/Features/AutoInjectRappasoftAssetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

final class AutoInjectRappasoftAssetsTest extends TestCase
{
public function test_shouldInjectRappasoftAndThirdParty()
public function test_should_inject_rappasoft_and_third_party()
{
config()->set('livewire-tables.inject_core_assets_enabled', true);
config()->set('livewire-tables.inject_third_party_assets_enabled', true);
Expand All @@ -20,7 +20,7 @@ public function test_shouldInjectRappasoftAndThirdParty()
$this->assertStringContainsStringIgnoringCase('<script src="/rappasoft/laravel-livewire-tables/thirdparty.min.js" ></script>', $injectionReturn);
}

public function test_shouldNotInjectRappasoftOrThirdParty()
public function test_should_not_inject_rappasoft_or_third_party()
{
config()->set('livewire-tables.inject_core_assets_enabled', false);
config()->set('livewire-tables.inject_third_party_assets_enabled', false);
Expand All @@ -30,7 +30,7 @@ public function test_shouldNotInjectRappasoftOrThirdParty()
$this->assertEquals('<html><head> </head><body></body></html>', AutoInjectRappasoftAssets::injectAssets('<html><head></head><body></body></html>'));
}

public function test_shouldOnlyInjectThirdParty()
public function test_should_only_inject_third_party()
{
config()->set('livewire-tables.inject_core_assets_enabled', false);
config()->set('livewire-tables.inject_third_party_assets_enabled', true);
Expand All @@ -41,7 +41,7 @@ public function test_shouldOnlyInjectThirdParty()
$this->assertStringContainsStringIgnoringCase('<script src="/rappasoft/laravel-livewire-tables/thirdparty.min.js" ></script>', $injectionReturn);
}

public function test_shouldOnlyInjectRappasoft()
public function test_should_only_inject_rappasoft()
{
config()->set('livewire-tables.inject_core_assets_enabled', true);
config()->set('livewire-tables.inject_third_party_assets_enabled', false);
Expand Down
52 changes: 26 additions & 26 deletions tests/Unit/Mechanisms/RappasoftFrontendAssetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class RappasoftFrontendAssetsTest extends TestCase
{
public function test_JsResponseSetupCacheEnabled(): array
public function test_js_response_setup_cache_enabled(): array
{
config()->set('livewire-tables.cache_assets', true);
$lastModified = \Carbon\Carbon::now()->timestamp;
Expand All @@ -22,7 +22,7 @@ public function test_JsResponseSetupCacheEnabled(): array
return ['lastModified' => $lastModified, 'responseHeaders' => $response->headers->all()];
}

public function test_JsResponseSetupCacheDisabled(): array
public function test_js_response_setup_cache_disabled(): array
{
config()->set('livewire-tables.cache_assets', false);
$date = date_create();
Expand All @@ -36,7 +36,7 @@ public function test_JsResponseSetupCacheDisabled(): array
return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()];
}

public function test_CssResponseSetupCacheEnabled(): array
public function test_css_response_setup_cache_enabled(): array
{
config()->set('livewire-tables.cache_assets', true);
$date = date_create();
Expand All @@ -50,7 +50,7 @@ public function test_CssResponseSetupCacheEnabled(): array
return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()];
}

public function test_CssResponseSetupCacheDisabled(): array
public function test_css_response_setup_cache_disabled(): array
{
config()->set('livewire-tables.cache_assets', false);

Expand All @@ -66,7 +66,7 @@ public function test_CssResponseSetupCacheDisabled(): array
return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()];
}

public function test_ThirdPartyCssResponseSetupCacheEnabled(): array
public function test_third_party_css_response_setup_cache_enabled(): array
{
config()->set('livewire-tables.cache_assets', true);

Expand All @@ -82,7 +82,7 @@ public function test_ThirdPartyCssResponseSetupCacheEnabled(): array
return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()];
}

public function test_ThirdPartyCssResponseSetupCacheDisabled(): array
public function test_third_party_css_response_setup_cache_disabled(): array
{
config()->set('livewire-tables.cache_assets', false);

Expand All @@ -98,7 +98,7 @@ public function test_ThirdPartyCssResponseSetupCacheDisabled(): array
return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()];
}

public function test_ThirdPartyJsResponseSetupCacheEnabled(): array
public function test_third_party_js_response_setup_cache_enabled(): array
{
config()->set('livewire-tables.cache_assets', true);
$lastModified = \Carbon\Carbon::now()->timestamp;
Expand All @@ -112,7 +112,7 @@ public function test_ThirdPartyJsResponseSetupCacheEnabled(): array
return ['lastModified' => $lastModified, 'responseHeaders' => $response->headers->all()];
}

public function test_ThirdPartyJsResponseSetupCacheDisabled(): array
public function test_third_party_js_response_setup_cache_disabled(): array
{
config()->set('livewire-tables.cache_assets', false);
$date = date_create();
Expand Down Expand Up @@ -148,7 +148,7 @@ public function test_scripts()
$this->assertTrue($assets->hasRenderedRappsoftTableScripts);
}

public function test_thirdPartystyles()
public function test_third_partystyles()
{
$assets = app(RappasoftFrontendAssets::class);

Expand All @@ -159,7 +159,7 @@ public function test_thirdPartystyles()
$this->assertTrue($assets->hasRenderedRappsoftTableThirdPartyStyles);
}

public function test_thirdPartyscripts()
public function test_third_partyscripts()
{
$assets = app(RappasoftFrontendAssets::class);

Expand All @@ -170,97 +170,97 @@ public function test_thirdPartyscripts()
$this->assertTrue($assets->hasRenderedRappsoftTableThirdPartyScripts);
}

#[Depends('test_JsResponseSetupCacheEnabled')]
#[Depends('test_js_response_setup_cache_enabled')]
public function test_check_pretend_response_is_js_returns_correct_cache_control_cache_enabled(array $jsResponseSetupCacheEnabled)
{
$this->assertSame('max-age=86400, public', $jsResponseSetupCacheEnabled['responseHeaders']['cache-control'][0]);
}

#[Depends('test_JsResponseSetupCacheEnabled')]
#[Depends('test_js_response_setup_cache_enabled')]
public function test_check_pretend_response_is_js_returns_correct_content_type_cache_enabled(array $jsResponseSetupCacheEnabled)
{
$this->assertSame('application/javascript; charset=utf-8', $jsResponseSetupCacheEnabled['responseHeaders']['content-type'][0]);
}

#[Depends('test_JsResponseSetupCacheDisabled')]
#[Depends('test_js_response_setup_cache_disabled')]
public function test_check_pretend_response_is_js_returns_correct_cache_control_cache_disabled(array $jsResponseSetupCacheDisabled)
{
$this->assertSame('max-age=1, public', $jsResponseSetupCacheDisabled['responseHeaders']['cache-control'][0]);
}

#[Depends('test_JsResponseSetupCacheDisabled')]
#[Depends('test_js_response_setup_cache_disabled')]
public function test_check_pretend_response_is_js_returns_correct_content_type_cache_disabled(array $jsResponseSetupCacheDisabled)
{
$this->assertSame('application/javascript; charset=utf-8', $jsResponseSetupCacheDisabled['responseHeaders']['content-type'][0]);
}

#[Depends('test_CssResponseSetupCacheEnabled')]
#[Depends('test_css_response_setup_cache_enabled')]
public function test_check_pretend_response_is_css_returns_correct_cache_control_caching_enabled(array $cssResponseSetupCacheEnabled)
{
$this->assertSame('max-age=86400, public', $cssResponseSetupCacheEnabled['responseHeaders']['cache-control'][0]);
}

#[Depends('test_CssResponseSetupCacheEnabled')]
#[Depends('test_css_response_setup_cache_enabled')]
public function test_check_pretend_response_is_css_returns_correct_content_type_caching_enabled(array $cssResponseSetupCacheEnabled)
{
$this->assertSame('text/css; charset=utf-8', $cssResponseSetupCacheEnabled['responseHeaders']['content-type'][0]);
}

#[Depends('test_CssResponseSetupCacheDisabled')]
#[Depends('test_css_response_setup_cache_disabled')]
public function test_check_pretend_response_is_css_returns_correct_cache_control_caching_disabled(array $cssResponseSetupCacheDisabled)
{
$this->assertSame('max-age=1, public', $cssResponseSetupCacheDisabled['responseHeaders']['cache-control'][0]);
}

#[Depends('test_CssResponseSetupCacheDisabled')]
#[Depends('test_css_response_setup_cache_disabled')]
public function test_check_pretend_response_is_css_returns_correct_content_type_caching_disabled(array $cssResponseSetupCacheDisabled)
{
$this->assertSame('text/css; charset=utf-8', $cssResponseSetupCacheDisabled['responseHeaders']['content-type'][0]);
}

#[Depends('test_ThirdPartyCssResponseSetupCacheEnabled')]
#[Depends('test_third_party_css_response_setup_cache_enabled')]
public function test_tp_check_pretend_response_is_css_returns_correct_cache_control_caching_enabled(array $thirdPartyCssResponseSetupCacheEnabled)
{
$this->assertSame('max-age=86400, public', $thirdPartyCssResponseSetupCacheEnabled['responseHeaders']['cache-control'][0]);
}

#[Depends('test_ThirdPartyCssResponseSetupCacheEnabled')]
#[Depends('test_third_party_css_response_setup_cache_enabled')]
public function test_tp_check_pretend_response_is_css_returns_correct_content_type_caching_enabled(array $thirdPartyCssResponseSetupCacheEnabled)
{
$this->assertSame('text/css; charset=utf-8', $thirdPartyCssResponseSetupCacheEnabled['responseHeaders']['content-type'][0]);
}

#[Depends('test_ThirdPartyCssResponseSetupCacheDisabled')]
#[Depends('test_third_party_css_response_setup_cache_disabled')]
public function test_tp_check_pretend_response_is_css_returns_correct_cache_control_caching_disabled(array $thirdPartyCssResponseSetupCacheDisabled)
{
$this->assertSame('max-age=1, public', $thirdPartyCssResponseSetupCacheDisabled['responseHeaders']['cache-control'][0]);
}

#[Depends('test_ThirdPartyCssResponseSetupCacheDisabled')]
#[Depends('test_third_party_css_response_setup_cache_disabled')]
public function test_tp_check_pretend_response_is_css_returns_correct_content_type_caching_disabled(array $thirdPartyCssResponseSetupCacheDisabled)
{
$this->assertSame('text/css; charset=utf-8', $thirdPartyCssResponseSetupCacheDisabled['responseHeaders']['content-type'][0]);
}

#[Depends('test_ThirdPartyJsResponseSetupCacheEnabled')]
#[Depends('test_third_party_js_response_setup_cache_enabled')]
public function test_tp_check_pretend_response_is_js_returns_correct_cache_control_cache_enabled(array $thirdPartyJsResponseSetupCacheEnabled)
{
$this->assertSame('max-age=86400, public', $thirdPartyJsResponseSetupCacheEnabled['responseHeaders']['cache-control'][0]);
}

#[Depends('test_ThirdPartyJsResponseSetupCacheEnabled')]
#[Depends('test_third_party_js_response_setup_cache_enabled')]
public function test_tp_check_pretend_response_is_js_returns_correct_content_type_cache_enabled(array $thirdPartyJsResponseSetupCacheEnabled)
{
$this->assertSame('application/javascript; charset=utf-8', $thirdPartyJsResponseSetupCacheEnabled['responseHeaders']['content-type'][0]);
}

#[Depends('test_ThirdPartyJsResponseSetupCacheDisabled')]
#[Depends('test_third_party_js_response_setup_cache_disabled')]
public function test_tp_check_pretend_response_is_js_returns_correct_cache_control_cache_disabled(array $thirdPartyJsResponseSetupCacheDisabled)
{
$this->assertSame('max-age=1, public', $thirdPartyJsResponseSetupCacheDisabled['responseHeaders']['cache-control'][0]);
}

#[Depends('test_ThirdPartyJsResponseSetupCacheDisabled')]
#[Depends('test_third_party_js_response_setup_cache_disabled')]
public function test_tp_check_pretend_response_is_js_returns_correct_content_type_cache_disabled(array $thirdPartyJsResponseSetupCacheDisabled)
{
$this->assertSame('application/javascript; charset=utf-8', $thirdPartyJsResponseSetupCacheDisabled['responseHeaders']['content-type'][0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function test_variables_are_correct_types(): void
$this->assertIsArray($this->basicTable->selectedColumns);
}

public function test_check_protected_fields_columnSelectStatus(): void
public function test_check_protected_fields_column_select_status(): void
{
$this->expectException(\Livewire\Exceptions\PropertyNotFoundException::class);
$this->assertIsBool($this->basicTable->columnSelectStatus);
Expand Down
25 changes: 25 additions & 0 deletions tests/Unit/Traits/Helpers/ToolsHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,29 @@ public function test_can_get_tools_display(): void
$this->assertFalse($this->basicTable->shouldShowTools());

}

public function test_can_get_tools_status_no_sortpills(): void
{
$this->assertTrue($this->basicTable->shouldShowTools());

$this->basicTable->setToolsEnabled();
$this->basicTable->setSortingDisabled();
$this->basicTable->setToolBarDisabled();
$this->assertFalse($this->basicTable->shouldShowTools());

$this->basicTable->setFiltersEnabled();
$this->basicTable->setFilter('pet_name_filter', 'Test');

$this->assertTrue($this->basicTable->shouldShowTools());

}

public function test_can_get_tools_status_toolbar_disabled(): void
{
$this->assertTrue($this->basicTable->shouldShowTools());
$this->basicTable->setToolsEnabled();
$this->basicTable->setToolBarDisabled();
$this->assertFalse($this->basicTable->shouldShowToolBar());

}
}
4 changes: 2 additions & 2 deletions tests/Unit/Traits/Visuals/FilterVisualsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public function test_filter_pills_show_when_enabled(): void
->assertSee('Applied Filters');
}

public function test_event_dispatched_when_filterComponents_set(): void
public function test_event_dispatched_when_filter_components_set(): void
{
Livewire::test(PetsTable::class)
->set('filterComponents.breed', [1])
->assertDispatched('filter-was-set');
}

public function test_event_dispatched_when_setFilter_dispatched(): void
public function test_event_dispatched_when_set_filter_dispatched(): void
{
Livewire::test(PetsTable::class)
->dispatch('setFilter', filterKey: 'breed', value: [1])
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Traits/Visuals/ReorderingVisualsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class ReorderingVisualsTest extends TestCase
{
public function test_FilterArraySetup(): array
public function test_filter_array_setup(): array
{
$filterDefaultArray = ['breed' => [], 'species' => [], 'breed_id_filter' => null, 'pet_name_filter' => null, 'last_visit_date_filter' => null, 'last_visit_datetime_filter' => null, 'breed_select_filter' => null];
$this->assertNotEmpty($filterDefaultArray);
Expand Down Expand Up @@ -95,7 +95,7 @@ public function test_sorting_pills_hide_on_reorder(): void
->assertSeeHtml('wire:key="table-sorting-pill-id"');
}

#[Depends('test_FilterArraySetup')]
#[Depends('test_filter_array_setup')]
public function test_sorting_is_disabled_on_reorder(array $filterDefaultArray): void
{
Livewire::test(PetsTable::class)
Expand Down Expand Up @@ -169,7 +169,7 @@ public function test_per_page_gets_set_on_reorder(): void
->assertSet('perPage', 10);
}

#[Depends('test_FilterArraySetup')]
#[Depends('test_filter_array_setup')]
public function test_search_hides_on_reorder(array $filterDefaultArray): void
{
Livewire::test(PetsTable::class)
Expand Down Expand Up @@ -267,7 +267,7 @@ public function test_bulk_actions_row_select_some_gets_hidden_on_reorder(): void
->assertDontSee('do you want to select all');
}

#[Depends('test_FilterArraySetup')]
#[Depends('test_filter_array_setup')]
public function test_filters_are_disabled_on_reorder(array $filterDefaultArray): void
{
$customisedFilterArray = $filterDefaultArray;
Expand All @@ -290,7 +290,7 @@ public function test_filters_are_disabled_on_reorder(array $filterDefaultArray):
->assertSeeHtml('Filters');
}

#[Depends('test_FilterArraySetup')]
#[Depends('test_filter_array_setup')]
public function test_filter_pills_hide_on_reorder(array $filterDefaultArray): void
{
$filterDefaultArray['breed'] = [1];
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Traits/WithSortingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

final class WithSortingTest extends TestCase
{
public function test_cannot_call_sortBy_if_sorting_is_disabled(): void
public function test_cannot_call_sort_by_if_sorting_is_disabled(): void
{
$this->assertSame($this->basicTable->sortBy('id'), 'asc');

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Views/Columns/DateColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class DateColumnTest extends TestCase
{
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
parent::setupPetOwnerTable();
Expand Down

0 comments on commit 9c27700

Please sign in to comment.