38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
/** N1 (C40): the tab a version opens on. */
|
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
import { initialTab } from '@/editor/tabs'
|
|
import { emptyText } from '../helpers/editorFixtures'
|
|
import {
|
|
baseText,
|
|
openReady,
|
|
resetStore,
|
|
store,
|
|
} from '../helpers/editorHarness'
|
|
|
|
vi.mock('@/lib/supabase', () => ({ getSupabaseClient: () => ({}) }))
|
|
vi.mock('@faunosteo/supabase', async (orig) => ({
|
|
...(await orig<typeof import('@faunosteo/supabase')>()),
|
|
getSheetVersion: vi.fn(),
|
|
downloadSheetDrawing: vi.fn(),
|
|
saveSheetDraft: vi.fn(),
|
|
getOfficialSheetAdmin: vi.fn(),
|
|
submitSheetReview: vi.fn(),
|
|
}))
|
|
|
|
afterEach(resetStore)
|
|
|
|
async function stateOf(text: string) {
|
|
await openReady({ text })
|
|
return store.getState().previewState!
|
|
}
|
|
|
|
describe('initialTab', () => {
|
|
it('opens an empty new draft on Général', async () => {
|
|
expect(initialTab(await stateOf(emptyText()))).toBe('general')
|
|
})
|
|
|
|
it('opens a draft with a measured view on Annotations', async () => {
|
|
expect(initialTab(await stateOf(baseText()))).toBe('annotations')
|
|
})
|
|
})
|