Apply item 0x4ac69e55 for issue #10
Squash of the patch of item 0x4ac69e554cfa29c1fb7819e9835c17153233e73e72ecb0b821628233c820eb3c, final in the elffuss ledger. Solver 0xdd8075ba73c2173b9f05957b5f1a7561600e5494; 2 approvals of round 0. T2T-Item: 0x4ac69e554cfa29c1fb7819e9835c17153233e73e72ecb0b821628233c820eb3c T2T-Issue: 0xb8d7c6d9815eb6af5efae391d136467cda8c028200c2b5ec5a36fa6620196c53 T2T-Event: 0x96cb4689693dca2b068c24579b325bee24f431c0e6c31a1d7f0b39f8810f534f
This commit is contained in:
18
tests/acceptance/10/CRITERIA.json
Normal file
18
tests/acceptance/10/CRITERIA.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"schema": "elffuss-t2t/criteria@2",
|
||||
"issue": 10,
|
||||
"criteria": [
|
||||
{
|
||||
"index": 1,
|
||||
"tests": [
|
||||
"tests/acceptance/10/criteria.test.js::criterion 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"index": 2,
|
||||
"tests": [
|
||||
"tests/acceptance/10/criteria.test.js::criterion 2"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
31
tests/acceptance/10/criteria.test.js
Normal file
31
tests/acceptance/10/criteria.test.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
const mod = await import('../../../web/js/model-cache.js')
|
||||
|
||||
function setNavigator(value) {
|
||||
Object.defineProperty(globalThis, 'navigator', { value, configurable: true, writable: true })
|
||||
}
|
||||
|
||||
test('criterion 1', async () => {
|
||||
const removed = []
|
||||
const deletedCaches = []
|
||||
const root = {
|
||||
async removeEntry(name, opts) { removed.push([name, opts]) },
|
||||
}
|
||||
setNavigator({ storage: { getDirectory: async () => root } })
|
||||
globalThis.caches = { delete: async (n) => { deletedCaches.push(n); return true } }
|
||||
|
||||
await mod.clearModelCache()
|
||||
|
||||
assert.ok(removed.some(([n]) => n === 'elffuss-models'))
|
||||
assert.deepEqual(deletedCaches, ['elffuss-models-v1'])
|
||||
})
|
||||
|
||||
test('criterion 2', async () => {
|
||||
let calls = 0
|
||||
setNavigator({ storage: { getDirectory: async () => { calls++; throw new Error('sin OPFS') } } })
|
||||
globalThis.caches = { delete: async () => true }
|
||||
|
||||
await assert.doesNotReject(mod.clearModelCache())
|
||||
assert.equal(calls, 1)
|
||||
})
|
||||
Reference in New Issue
Block a user