Skip to content

Commit e92baf3

Browse files
DevipriyaS17Copilot
andcommitted
fix: fix for copilot comment
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 0c31c69 commit e92baf3

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

src/app/devices/device-toolbar/device-toolbar.component.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ describe('DeviceToolbarComponent', () => {
138138
expect(component.isLoading()()).toBeFalse()
139139
})
140140

141+
it('should fetch power state using cached API on initial load', () => {
142+
expect(devicesService.getPowerStateCached).toHaveBeenCalledWith('guid')
143+
expect(devicesService.getPowerState).not.toHaveBeenCalled()
144+
})
145+
141146
it('should fetch power state using non-cached API on refresh', () => {
142147
devicesService.getPowerState.calls.reset()
143148
devicesService.getPowerStateCached.calls.reset()

src/app/devices/device-toolbar/device-toolbar.component.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,17 @@ export class DeviceToolbarComponent implements OnInit {
218218
}
219219

220220
private setPowerStateLabel(powerstate: number): void {
221-
this.powerState.set(
222-
powerstate.toString() === '2'
223-
? 'deviceToolbar.power.on.value'
224-
: powerstate.toString() === '3' || powerstate.toString() === '4'
225-
? 'deviceToolbar.power.sleep.value'
226-
: 'deviceToolbar.power.off.value'
227-
)
221+
switch (powerstate) {
222+
case 2:
223+
this.powerState.set('deviceToolbar.power.on.value')
224+
break
225+
case 3:
226+
case 4:
227+
this.powerState.set('deviceToolbar.power.sleep.value')
228+
break
229+
default:
230+
this.powerState.set('deviceToolbar.power.off.value')
231+
}
228232
}
229233

230234
private loadPowerState(): void {

0 commit comments

Comments
 (0)