generated from spatie/package-skeleton-laravel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): add some ai generated tests
- Loading branch information
1 parent
bb0f19d
commit dedc8db
Showing
4 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Config; | ||
use Infernalmedia\ResponsiveImageCraft\Exceptions\InvalidDiskException; | ||
use Infernalmedia\ResponsiveImageCraft\ResponsiveImageCraft; | ||
|
||
test('it throws an exception if URL is missing', function () { | ||
Config::set('responsive-image-craft.use_responsive_images', true); | ||
Config::set('responsive-image-craft.source_disk', 'local'); | ||
Config::set('filesystems.disks.local.url', null); | ||
|
||
$responsiveImageCraft = new ResponsiveImageCraft(); | ||
|
||
$maxWidth = 800; | ||
$extensions = ['jpg', 'webp']; | ||
|
||
$this->expectException(InvalidDiskException::class); | ||
|
||
$responsiveImageCraft->getCssVariables('image.jpg', $maxWidth, $extensions); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
use Infernalmedia\ResponsiveImageCraft\View\Components\ResponsiveImg; | ||
|
||
it('can be created with minimum required attributes', function () { | ||
$component = new ResponsiveImg('image.jpg'); | ||
expect($component)->toBeInstanceOf(ResponsiveImg::class); | ||
}); | ||
|
||
it('can get the container CSS class', function () { | ||
$component = new ResponsiveImg(src: 'image.jpg'); | ||
|
||
$this->assertSame('img-container', $component->getContainerCssClass()); | ||
|
||
$component = new ResponsiveImg(src: 'image.jpg', containerClass: 'custom-class'); | ||
|
||
$this->assertSame('img-container custom-class', $component->getContainerCssClass()); | ||
}); | ||
|
||
it('can get the image type', function () { | ||
$component = new ResponsiveImg('image.jpg'); | ||
|
||
$this->assertSame('image/jpeg', $component->getImageType('jpg')); | ||
$this->assertSame('', $component->getImageType('invalid-extension')); | ||
}); | ||
|
||
it('jpg returns an array of filtered extensions without png', function () { | ||
$component = new ResponsiveImg( | ||
src: 'image.jpg', | ||
); | ||
|
||
$filteredExtensions = $component->getFilteredExtensions(); | ||
|
||
expect($filteredExtensions)->toContain('webp'); | ||
expect($filteredExtensions)->not->toContain('png'); | ||
}); | ||
|
||
it('png returns an array of filtered extensions without jpg', function () { | ||
$component = new ResponsiveImg( | ||
src: 'image.png', | ||
); | ||
|
||
$filteredExtensions = $component->getFilteredExtensions(); | ||
|
||
expect($filteredExtensions)->toContain('webp'); | ||
expect($filteredExtensions)->not->toContain('jpg'); | ||
}); |