Files
floci-ui/packages/api/src/azure.test.ts
T
Zakaria 91ce11274d
CI / checks (pull_request) Successful in 25m47s
chore: show TheCloud instead of Floci in console text and messages
Labels, empty states, error messages and defaults the console shows now name
TheCloud or its runtimes. Identifiers that must match the emulator (FLOCI_*
settings, the X-Floci-CSRF header, emulator-returned host names) are unchanged.
2026-10-24 14:30:44 -04:00

39 lines
1.4 KiB
TypeScript

import {afterEach, describe, expect, test} from 'bun:test'
import {AzureRestRuntimeClient} from './azure'
const originalFetch = globalThis.fetch
afterEach(() => {
globalThis.fetch = originalFetch
})
describe('AzureRestRuntimeClient', () => {
test('can omit the Blob Storage API version header', async () => {
let requestHeaders: HeadersInit | undefined
globalThis.fetch = (async (_url: RequestInfo | URL, init?: RequestInit) => {
requestHeaders = init?.headers
return new Response('{}')
}) as unknown as typeof fetch
const client = new AzureRestRuntimeClient('http://localhost:4577', 'devstoreaccount1')
await client.fetch('/devstoreaccount1-keyvault/secrets', {method: 'GET'}, {
includeStorageApiVersion: false,
})
expect(new Headers(requestHeaders).has('x-ms-version')).toBe(false)
})
test('adds endpoint context to network failures', async () => {
globalThis.fetch = (async () => {
throw new Error('connection refused')
}) as unknown as typeof fetch
const client = new AzureRestRuntimeClient('http://localhost:4577', 'devstoreaccount1')
await expect(client.fetch('/container?restype=container', {method: 'PUT'})).rejects.toThrow(
"Cannot reach TheCloud's Azure runtime at http://localhost:4577: connection refused",
)
})
})