mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-03-14 20:33:40 +00:00
feat(#188): support battery-percent header
This commit is contained in:
parent
d9ab052cbc
commit
8400c1eaf1
2 changed files with 37 additions and 2 deletions
|
|
@ -725,6 +725,40 @@ test('display endpoint updates last_refreshed_at timestamp', function (): void {
|
|||
->and($device->last_refreshed_at->diffInSeconds(now()))->toBeLessThan(2);
|
||||
});
|
||||
|
||||
test('display endpoint accepts battery-percent header and updates device', function (): void {
|
||||
$device = Device::factory()->create([
|
||||
'mac_address' => '00:11:22:33:44:56',
|
||||
'api_key' => 'test-api-key-battery',
|
||||
'last_battery_voltage' => null,
|
||||
]);
|
||||
|
||||
$this->withHeaders([
|
||||
'id' => $device->mac_address,
|
||||
'access-token' => $device->api_key,
|
||||
'battery-percent' => '67',
|
||||
])->get('/api/display')->assertOk();
|
||||
|
||||
$device->refresh();
|
||||
expect($device->battery_percent)->toEqual(67);
|
||||
});
|
||||
|
||||
test('display endpoint accepts Percent-Charged header and updates device', function (): void {
|
||||
$device = Device::factory()->create([
|
||||
'mac_address' => '00:11:22:33:44:57',
|
||||
'api_key' => 'test-api-key-percent-charged',
|
||||
'last_battery_voltage' => null,
|
||||
]);
|
||||
|
||||
$this->withHeaders([
|
||||
'id' => $device->mac_address,
|
||||
'access-token' => $device->api_key,
|
||||
'Percent-Charged' => '51',
|
||||
])->get('/api/display')->assertOk();
|
||||
|
||||
$device->refresh();
|
||||
expect($device->battery_percent)->toEqual(51);
|
||||
});
|
||||
|
||||
test('display endpoint updates last_refreshed_at timestamp for mirrored devices', function (): void {
|
||||
// Create source device
|
||||
$sourceDevice = Device::factory()->create([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue