Files
prompt-optimizer/packages/ui/tests/unit/utils/external-data-loading.spec.ts
linshen f034bde2d4 feat(ui): enhance favorites with example editing, media management, and workspace apply
- Add reproducibility example editing with media support in favorite editor
- Add example apply to workspace sessions (pro-variable, image modes)
- Harden favorites page routing, guards, and garden deduplication
- Consolidate FavoriteCard into editor form with full test coverage
2026-04-27 21:28:00 +08:00

35 lines
938 B
TypeScript

import { describe, expect, it } from 'vitest'
import { createExternalDataLoadingGate } from '../../../src/utils/external-data-loading'
describe('createExternalDataLoadingGate', () => {
it('keeps loading true until every concurrent owner leaves', () => {
const gate = createExternalDataLoadingGate()
gate.isLoading.value = true
gate.isLoading.value = true
expect(gate.isLoading.value).toBe(true)
expect(gate.depth.value).toBe(2)
gate.isLoading.value = false
expect(gate.isLoading.value).toBe(true)
expect(gate.depth.value).toBe(1)
gate.isLoading.value = false
expect(gate.isLoading.value).toBe(false)
expect(gate.depth.value).toBe(0)
})
it('does not underflow when a caller leaves too many times', () => {
const gate = createExternalDataLoadingGate()
gate.isLoading.value = false
expect(gate.isLoading.value).toBe(false)
expect(gate.depth.value).toBe(0)
})
})