17 lines
968 B
JavaScript
17 lines
968 B
JavaScript
import assert from 'node:assert/strict'
|
|
import test from 'node:test'
|
|
import { selectSessionPdaOperator } from './domestic-pda-operator.mjs'
|
|
|
|
const subject = '2103886047128588290'
|
|
const token = `header.${Buffer.from(JSON.stringify({ sub: subject })).toString('base64url')}.signature`
|
|
test('task assignee matches authenticated user even when another operator is first', () => {
|
|
const current = { userId: subject, membershipId: '2103886047128588291' }
|
|
const operators = [{ userId: '194000000000000101' }, current]
|
|
assert.equal(selectSessionPdaOperator(operators, token), current)
|
|
assert.equal(selectSessionPdaOperator({ records: operators }, token), current)
|
|
})
|
|
test('missing warehouse candidate does not fall back to another operator or membership ID', () => {
|
|
assert.throws(() => selectSessionPdaOperator([{ userId: '2103886047128588291' }], token), /不在目标仓库候选/)
|
|
assert.throws(() => selectSessionPdaOperator([], ''), /有效登录身份/)
|
|
})
|