mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 15:37:53 +00:00
chore: add tests
This commit is contained in:
parent
a80e24c8bd
commit
b4dfb1673f
2 changed files with 36 additions and 0 deletions
|
|
@ -34,6 +34,10 @@ This repo is maintained voluntarily by [@bnussbau](https://github.com/bnussbau).
|
||||||
|
|
||||||
Support the development of this package by purchasing a TRMNL device through the referral link: https://usetrmnl.com/?ref=laravel-trmnl. At checkout, use the code `laravel-trmnl` to receive a $15 discount on your purchase.
|
Support the development of this package by purchasing a TRMNL device through the referral link: https://usetrmnl.com/?ref=laravel-trmnl. At checkout, use the code `laravel-trmnl` to receive a $15 discount on your purchase.
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
[](https://www.buymeacoffee.com/bnussbau)
|
||||||
|
|
||||||
### Hosting
|
### Hosting
|
||||||
|
|
||||||
Run everywhere, where Docker is supported: Raspberry Pi, VPS, NAS, Container Cloud Service (Cloud Run, ...)
|
Run everywhere, where Docker is supported: Raspberry Pi, VPS, NAS, Container Cloud Service (Cloud Run, ...)
|
||||||
|
|
|
||||||
|
|
@ -351,3 +351,35 @@ test('device can mirror another device', function () {
|
||||||
->last_battery_voltage->toBe(3.8)
|
->last_battery_voltage->toBe(3.8)
|
||||||
->last_firmware_version->toBe('1.0.0');
|
->last_firmware_version->toBe('1.0.0');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('device can fetch current screen data', function () {
|
||||||
|
$device = Device::factory()->create([
|
||||||
|
'mac_address' => '00:11:22:33:44:55',
|
||||||
|
'api_key' => 'test-api-key',
|
||||||
|
'current_screen_image' => 'test-image',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'access-token' => $device->api_key,
|
||||||
|
])->get('/api/current_screen');
|
||||||
|
|
||||||
|
$response->assertOk()
|
||||||
|
->assertJson([
|
||||||
|
'status' => '0',
|
||||||
|
'filename' => 'test-image.bmp',
|
||||||
|
'refresh_rate' => 900,
|
||||||
|
'reset_firmware' => false,
|
||||||
|
'update_firmware' => false,
|
||||||
|
'firmware_url' => null,
|
||||||
|
'special_function' => 'sleep',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('current_screen endpoint requires valid device credentials', function () {
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'access-token' => 'invalid-token',
|
||||||
|
])->get('/api/current_screen');
|
||||||
|
|
||||||
|
$response->assertNotFound()
|
||||||
|
->assertJson(['message' => 'Device not found or invalid access token']);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue