initial commit

This commit is contained in:
Madison Grubb
2026-02-10 23:32:26 -05:00
commit b7046dc0e6
133 changed files with 26080 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import { describe, it, expect } from 'vitest'
import { mountSuspended, registerEndpoint } from '@nuxt/test-utils/runtime'
import { defineComponent, h } from 'vue'
import { useLiveSessions } from '../../app/composables/useLiveSessions.js'
describe('useLiveSessions', () => {
it('fetches sessions from API and returns sessions ref', async () => {
registerEndpoint('/api/live', () => [
{ id: 's1', label: 'Live 1', hasStream: true, lat: 37, lng: -122 },
])
registerEndpoint('/api/me', () => ({ id: '1', identifier: 'u', role: 'member' }), { method: 'GET' })
const TestComponent = defineComponent({
setup() {
const { sessions } = useLiveSessions()
return () => h('div', { 'data-sessions': JSON.stringify(sessions.value) })
},
})
const wrapper = await mountSuspended(TestComponent)
await new Promise(r => setTimeout(r, 100))
expect(wrapper.find('[data-sessions]').exists()).toBe(true)
})
it('returns empty array when fetch fails', async () => {
registerEndpoint('/api/live', () => {
throw new Error('fetch failed')
})
registerEndpoint('/api/me', () => ({ id: '1', identifier: 'u', role: 'member' }), { method: 'GET' })
const TestComponent = defineComponent({
setup() {
const { sessions } = useLiveSessions()
return () => h('div', { 'data-sessions': JSON.stringify(sessions.value) })
},
})
const wrapper = await mountSuspended(TestComponent)
await new Promise(r => setTimeout(r, 150))
const el = wrapper.find('[data-sessions]')
expect(el.exists()).toBe(true)
expect(JSON.parse(el.attributes('data-sessions'))).toEqual([])
})
})