34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { createBuilderStore, type Section } from '@/lib/state/store'
|
|
|
|
describe('builder store (zustand)', () => {
|
|
it('섹션 추가/이동/삭제와 로케일 변경을 지원한다', () => {
|
|
const useStore = createBuilderStore()
|
|
const s1: Section = { type: 'hero', props: { heading: 'H1' } }
|
|
const s2: Section = { type: 'faq', props: { items: [] } }
|
|
const s3: Section = { type: 'cta', props: { text: 'Go' } }
|
|
|
|
// 초기 상태
|
|
expect(useStore.getState().locale).toBe('en')
|
|
expect(useStore.getState().sections.length).toBe(0)
|
|
|
|
// 추가
|
|
useStore.getState().addSection(s1)
|
|
useStore.getState().addSection(s2)
|
|
useStore.getState().addSection(s3)
|
|
expect(useStore.getState().sections.map(s => s.type)).toEqual(['hero','faq','cta'])
|
|
|
|
// 이동 (index 0 -> 2)
|
|
useStore.getState().moveSection(0, 2)
|
|
expect(useStore.getState().sections.map(s => s.type)).toEqual(['faq','cta','hero'])
|
|
|
|
// 삭제 (index 1: 'cta')
|
|
useStore.getState().removeSection(1)
|
|
expect(useStore.getState().sections.map(s => s.type)).toEqual(['faq','hero'])
|
|
|
|
// 로케일 변경
|
|
useStore.getState().setLocale('ko')
|
|
expect(useStore.getState().locale).toBe('ko')
|
|
})
|
|
})
|