chore: add tests

This commit is contained in:
Benjamin Nussbaum 2025-05-08 22:28:30 +02:00
parent a80e24c8bd
commit b4dfb1673f
2 changed files with 36 additions and 0 deletions

View file

@ -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.
or
[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/bnussbau)
### Hosting
Run everywhere, where Docker is supported: Raspberry Pi, VPS, NAS, Container Cloud Service (Cloud Run, ...)

View file

@ -351,3 +351,35 @@ test('device can mirror another device', function () {
->last_battery_voltage->toBe(3.8)
->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']);
});