mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 23:18:10 +00:00
test: use faker for GenerateDefaultImagesTest, TransformDefaultImagesTest
Some checks are pending
tests / ci (push) Waiting to run
Some checks are pending
tests / ci (push) Waiting to run
This commit is contained in:
parent
50318b8b9d
commit
e812f56c11
2 changed files with 39 additions and 17 deletions
|
|
@ -3,8 +3,20 @@
|
|||
use App\Models\Device;
|
||||
use App\Models\DeviceModel;
|
||||
use App\Services\ImageGenerationService;
|
||||
use Bnussbau\TrmnlPipeline\TrmnlPipeline;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
beforeEach(function (): void {
|
||||
TrmnlPipeline::fake();
|
||||
Storage::fake('public');
|
||||
Storage::disk('public')->makeDirectory('/images/default-screens');
|
||||
Storage::disk('public')->makeDirectory('/images/generated');
|
||||
|
||||
// Create fallback image files that the service expects
|
||||
Storage::disk('public')->put('/images/setup-logo.bmp', 'fake-bmp-content');
|
||||
Storage::disk('public')->put('/images/sleep.bmp', 'fake-bmp-content');
|
||||
});
|
||||
|
||||
test('command transforms default images for all device models', function () {
|
||||
// Ensure we have device models
|
||||
$deviceModels = DeviceModel::all();
|
||||
|
|
@ -30,20 +42,6 @@ test('command transforms default images for all device models', function () {
|
|||
}
|
||||
});
|
||||
|
||||
test('getDeviceSpecificDefaultImage returns correct path for device with model', function () {
|
||||
$deviceModel = DeviceModel::first();
|
||||
expect($deviceModel)->not->toBeNull();
|
||||
|
||||
$device = new Device();
|
||||
$device->deviceModel = $deviceModel;
|
||||
|
||||
$setupImage = ImageGenerationService::getDeviceSpecificDefaultImage($device, 'setup-logo');
|
||||
$sleepImage = ImageGenerationService::getDeviceSpecificDefaultImage($device, 'sleep');
|
||||
|
||||
expect($setupImage)->toContain('images/default-screens/setup-logo_');
|
||||
expect($sleepImage)->toContain('images/default-screens/sleep_');
|
||||
});
|
||||
|
||||
test('getDeviceSpecificDefaultImage falls back to original images for device without model', function () {
|
||||
$device = new Device();
|
||||
$device->deviceModel = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue