diff --git a/tests/Pest.php b/tests/Pest.php index c4697db..1687b9f 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -34,10 +34,7 @@ function assertMatchesOsSafeSnapshot($data): void test()->expect($json)->toMatchJsonSnapshot(); } -function onlyIfContextSupported() +function contextSupported(): bool { - - if (!class_exists(Context::class)) { - test()->skip('Context is not supported for this Laravel version'); - } + return class_exists(Context::class); } diff --git a/tests/Unit/ContextTest.php b/tests/Unit/ContextTest.php index b724cd3..7c61878 100644 --- a/tests/Unit/ContextTest.php +++ b/tests/Unit/ContextTest.php @@ -5,6 +5,10 @@ use Illuminate\Support\Facades\Context; it('can send all context', function () { + if (! contextSupported()) { + return; + } + Context::add('key', 'value'); ray()->context(); @@ -16,10 +20,14 @@ $clipboardData = $requests[0]['payloads'][0]['content']['meta']['0']['clipboard_data']; expect($clipboardData)->toContain('key', 'value'); -})->onlyIfContextSupported(); +}); it('can send specific context keys variadic', function () { + if (! contextSupported()) { + return; + } + Context::add('key1', 'value1'); Context::add('key2', 'value2'); Context::add('key3', 'value3'); @@ -34,9 +42,13 @@ expect($clipboardData)->toContain('key1', 'key3'); expect($clipboardData)->not()->toContain('key2'); -})->onlyIfContextSupported(); +}); it('can send specific context keys using an array', function () { + if (! contextSupported()) { + return; + } + Context::add('key1', 'value1'); Context::add('key2', 'value2'); Context::add('key3', 'value3'); @@ -51,9 +63,13 @@ expect($clipboardData)->toContain('key1', 'key3'); expect($clipboardData)->not()->toContain('key2'); -})->onlyIfContextSupported(); +}); it('can send all hidden context', function () { + if (! contextSupported()) { + return; + } + Context::addHidden('hidden-key', 'hidden-value'); Context::add('visible-key', 'visible-value'); @@ -67,4 +83,4 @@ expect($clipboardData)->toContain('hidden-key'); expect($clipboardData)->not()->toContain('visible-key'); -})->onlyIfContextSupported(); +});