This commit is contained in:
Gauthier Roebroeck 2025-06-13 10:46:34 +08:00
parent 20e75b8987
commit 7576df903c

View file

@ -2,8 +2,8 @@ import { afterAll, afterEach, beforeAll, beforeEach, expect, test } from 'vitest
import { server } from '@/mocks/api/node'
import { useActuatorInfo } from '@/colada/queries/actuator-info'
import { createMockColada } from '@/mocks/pinia-colada'
import { http, HttpResponse } from 'msw'
import { baseUrl } from '@/mocks/api/handlers/base'
import { http } from 'msw'
import { baseUrl, response401Unauthorized } from '@/mocks/api/handlers/base'
import { VueWrapper } from '@vue/test-utils'
let mock: VueWrapper
@ -26,15 +26,12 @@ test('when getting actuator-info then values are correct', async () => {
})
test('when failing to get actuator-info then values are undefined', async () => {
server.use(
http.get(baseUrl + 'actuator/info', () => {
return HttpResponse.json({ error: 'Unauthorized' }, { status: 401 })
}),
)
server.use(http.get(baseUrl + 'actuator/info', response401Unauthorized))
const { buildVersion, commitId, refresh } = useActuatorInfo()
const { buildVersion, commitId, refresh, error } = useActuatorInfo()
await refresh()
expect(buildVersion.value).toBeUndefined()
expect(commitId.value).toBeUndefined()
expect(error.value).not.toBeUndefined()
})