feat: publish CodexPi contest snapshot
Some checks are pending
Qualité / tests (push) Waiting to run
Some checks are pending
Qualité / tests (push) Waiting to run
This commit is contained in:
22
frontend/tests/conversationRequests.test.ts
Normal file
22
frontend/tests/conversationRequests.test.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import {isCurrentConversationResponse,reuseInFlightRequest} from '../src/conversationRequests.ts'
|
||||
|
||||
test('a late response from the previously selected conversation is ignored', () => {
|
||||
assert.equal(isCurrentConversationResponse('gameflix','codexpi-self'),false)
|
||||
assert.equal(isCurrentConversationResponse('gameflix','gameflix'),true)
|
||||
})
|
||||
|
||||
test('simultaneous refreshes reuse one request and release it after completion', async () => {
|
||||
const requests=new Map<string,Promise<number>>()
|
||||
let calls=0
|
||||
const load=()=>reuseInFlightRequest(requests,'conversation',async()=>++calls)
|
||||
|
||||
const first=load()
|
||||
const second=load()
|
||||
|
||||
assert.equal(first,second)
|
||||
assert.equal(await first,1)
|
||||
assert.equal(await load(),2)
|
||||
})
|
||||
Reference in New Issue
Block a user