mirror of
https://github.com/linshenkx/prompt-optimizer.git
synced 2026-07-02 11:24:45 +08:00
- 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
35 lines
938 B
TypeScript
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)
|
|
})
|
|
})
|