test: format port schedule fixtures in Shanghai local time
This commit is contained in:
@@ -7,7 +7,15 @@ const OUTBOUND = '/api/platform/v1/first-leg/outbound-dispatches'
|
||||
function id(value) { return value == null ? '' : String(value) }
|
||||
function codeOf(response) { return response?.body?.code == null ? 'missing' : String(response.body.code) }
|
||||
function data(response) { return codeOf(response) === '200' ? response.body.data : null }
|
||||
function localIso(value) { return value.toISOString().slice(0, 19) }
|
||||
const SHANGHAI_TIME = new Intl.DateTimeFormat('en-CA', {
|
||||
timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit', day: '2-digit',
|
||||
hour: '2-digit', minute: '2-digit', second: '2-digit', hourCycle: 'h23',
|
||||
})
|
||||
function localIso(value) {
|
||||
const parts = Object.fromEntries(SHANGHAI_TIME.formatToParts(value)
|
||||
.filter((part) => part.type !== 'literal').map((part) => [part.type, part.value]))
|
||||
return `${parts.year}-${parts.month}-${parts.day}T${parts.hour}:${parts.minute}:${parts.second}`
|
||||
}
|
||||
function at(offsetMinutes) { return localIso(new Date(Date.now() + offsetMinutes * 60_000)) }
|
||||
function step(context, name, response, passed, evidence) {
|
||||
context.addStep(MODULE, name, response, passed, evidence, { ...OPTIONS, deploymentBlocker: !passed })
|
||||
|
||||
Reference in New Issue
Block a user