拆分兑换凭证纯函数与结果写入
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import path from 'node:path'
|
||||
|
||||
import { shouldCaptureBeijingTimeProof } from './session-proof.js'
|
||||
import { resolveRedeemProofMode, shouldCaptureBeijingTimeProof } from './session-proof.js'
|
||||
import { buildArtifactPaths } from './session-proof-paths.js'
|
||||
|
||||
test('resolveRedeemProofMode normalizes configured modes and falls back to full', () => {
|
||||
assert.equal(resolveRedeemProofMode('basic'), 'basic')
|
||||
assert.equal(resolveRedeemProofMode(' OFF '), 'off')
|
||||
assert.equal(resolveRedeemProofMode('full'), 'full')
|
||||
assert.equal(resolveRedeemProofMode('unexpected'), 'full')
|
||||
assert.equal(resolveRedeemProofMode(''), 'full')
|
||||
})
|
||||
|
||||
test('shouldCaptureBeijingTimeProof only returns true for successful redeem results', () => {
|
||||
assert.equal(
|
||||
@@ -42,3 +52,13 @@ test('shouldCaptureBeijingTimeProof only returns true for successful redeem resu
|
||||
|
||||
assert.equal(shouldCaptureBeijingTimeProof(null), false)
|
||||
})
|
||||
|
||||
test('buildArtifactPaths keeps redeem proof artifact filenames stable', () => {
|
||||
const artifactPaths = buildArtifactPaths('/tmp/redeem-proof')
|
||||
|
||||
assert.equal(artifactPaths.redeemPageScreenshotPath, path.join('/tmp/redeem-proof', 'redeem-page.png'))
|
||||
assert.equal(artifactPaths.beijingTimeScreenshotPath, path.join('/tmp/redeem-proof', 'beijing-time.png'))
|
||||
assert.equal(artifactPaths.screenshotPath, path.join('/tmp/redeem-proof', 'redeem-result.png'))
|
||||
assert.equal(artifactPaths.htmlPath, path.join('/tmp/redeem-proof', 'page.html'))
|
||||
assert.equal(artifactPaths.resultPath, path.join('/tmp/redeem-proof', 'result.json'))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user