fix
This commit is contained in:
@@ -195,11 +195,13 @@ test('полный сценарий добавляет фон и введени
|
||||
const pkg = await prepareScreenPackage({ server, gameId: 7, token: 'SECRET', onIncomplete: () => { incomplete = true } }, async (input) => {
|
||||
const url = String(input)
|
||||
calls.push(url)
|
||||
return Response.json(url.endsWith('/scenarios/23') ? full : url.endsWith('/music') ? music : url.endsWith('/screen-plan') ? {} : game)
|
||||
if (url.endsWith('/scenarios/23')) return Response.json({ scenario: { ID: 23, image: 'cover.png' } })
|
||||
return Response.json(url.endsWith('/scenarios/23/full') ? full : url.endsWith('/music') ? music : url.endsWith('/screen-plan') ? {} : game)
|
||||
})
|
||||
assert.equal(pkg.assets.length, 16)
|
||||
assert.ok(pkg.media.background && pkg.media.intro)
|
||||
assert.ok(calls.includes(`${server}/api/scenarios/23`))
|
||||
assert.ok(calls.includes(`${server}/api/scenarios/23/full`))
|
||||
assert.ok(!calls.includes(`${server}/api/scenarios/23`))
|
||||
assert.equal(incomplete, false)
|
||||
assert.equal(JSON.stringify(pkg).includes('PRIVATE-ANSWER'), false)
|
||||
assert.deepEqual(parseScreenPackage(pkg), pkg)
|
||||
@@ -212,17 +214,17 @@ test('недоступный или неполный сценарий преду
|
||||
const failures: unknown[] = []
|
||||
const pkg = await prepareScreenPackage({ server, gameId: 7, token: 'SECRET', onIncomplete: () => { incomplete = true }, onRequestFailure: (failure) => failures.push(failure) }, async (input) => {
|
||||
const url = String(input)
|
||||
return url.endsWith('/scenarios/23') ? Response.json({ scenario: { ID: 23 } }, { status }) : Response.json(url.endsWith('/games/7') ? game : {})
|
||||
return url.endsWith('/scenarios/23/full') ? Response.json({ scenario: { ID: 23 } }, { status }) : Response.json(url.endsWith('/games/7') ? game : {})
|
||||
})
|
||||
assert.equal(incomplete, true)
|
||||
assert.equal(pkg.assets.length, 1)
|
||||
if (status !== 200) assert.deepEqual(failures, [{ path: '/api/scenarios/{id}', reason: status === 403 ? 'AUTH' : 'HTTP' }])
|
||||
if (status !== 200) assert.deepEqual(failures, [{ path: '/api/scenarios/{id}/full', reason: status === 403 ? 'AUTH' : 'HTTP' }])
|
||||
}
|
||||
await assert.rejects(prepareScreenPackage({ server, gameId: 7, token: 'SECRET' }, async (input) =>
|
||||
Response.json(String(input).endsWith('/scenarios/23') ? { scenario: { ID: 24 } } : String(input).endsWith('/games/7') ? game : {})),
|
||||
Response.json(String(input).endsWith('/scenarios/23/full') ? { scenario: { ID: 24 } } : String(input).endsWith('/games/7') ? game : {})),
|
||||
/Сценарий игры.*GET \/api\/scenarios\/23.*другой сценарий/)
|
||||
await assert.rejects(prepareScreenPackage({ server, gameId: 7, token: 'SECRET' }, async (input) =>
|
||||
Response.json(String(input).endsWith('/scenarios/23') ? null : String(input).endsWith('/games/7') ? game : {})),
|
||||
Response.json(String(input).endsWith('/scenarios/23/full') ? null : String(input).endsWith('/games/7') ? game : {})),
|
||||
/Сценарий игры.*scenarioResponse/)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user