initial commit
This commit is contained in:
26
test/nuxt/useWebRTCFailureReason.spec.js
Normal file
26
test/nuxt/useWebRTCFailureReason.spec.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { registerEndpoint } from '@nuxt/test-utils/runtime'
|
||||
import { getWebRTCFailureReason } from '../../app/composables/useWebRTCFailureReason.js'
|
||||
|
||||
describe('useWebRTCFailureReason', () => {
|
||||
it('returns wrongHost null when server and client hostname match', async () => {
|
||||
registerEndpoint('/api/live/debug-request-host', () => ({ hostname: 'localhost' }))
|
||||
const result = await getWebRTCFailureReason()
|
||||
expect(result).toEqual({ wrongHost: null })
|
||||
})
|
||||
|
||||
it('returns wrongHost when server and client hostname differ', async () => {
|
||||
registerEndpoint('/api/live/debug-request-host', () => ({ hostname: 'server.example.com' }))
|
||||
const result = await getWebRTCFailureReason()
|
||||
expect(result.wrongHost).toBeDefined()
|
||||
expect(result.wrongHost?.serverHostname).toBe('server.example.com')
|
||||
})
|
||||
|
||||
it('returns wrongHost null when fetch fails', async () => {
|
||||
registerEndpoint('/api/live/debug-request-host', () => {
|
||||
throw new Error('network')
|
||||
})
|
||||
const result = await getWebRTCFailureReason()
|
||||
expect(result).toEqual({ wrongHost: null })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user