fix(web): await replacement refresh coverage
This commit is contained in:
29
apps/web_v1/scripts/recovery-refresh.test.mjs
Normal file
29
apps/web_v1/scripts/recovery-refresh.test.mjs
Normal file
@@ -0,0 +1,29 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import { runRecoveryRefresh } from '../src/app/recovery-refresh.ts'
|
||||
|
||||
test('a failed recovery never announces refreshed success', async () => {
|
||||
const events = []
|
||||
|
||||
await assert.rejects(() => runRecoveryRefresh(
|
||||
async () => {
|
||||
events.push('refresh')
|
||||
throw new Error('still stale')
|
||||
},
|
||||
() => events.push('success'),
|
||||
), /still stale/)
|
||||
|
||||
assert.deepEqual(events, ['refresh'])
|
||||
})
|
||||
|
||||
test('recovery announces success only after every requested refresh resolves', async () => {
|
||||
const events = []
|
||||
|
||||
await runRecoveryRefresh(
|
||||
async () => events.push('refresh'),
|
||||
() => events.push('success'),
|
||||
)
|
||||
|
||||
assert.deepEqual(events, ['refresh', 'success'])
|
||||
})
|
||||
Reference in New Issue
Block a user