feat(pl): 吨千克克和升毫升按固定比例折算用证量。
同质量或体积单位不再要求手填系数,普通 http 页面也能生成幂等操作号。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
e7f942b399
commit
da3ec62719
21 files changed
+277
-43
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { randomOperationId } from '../src/utils/random-id'
|
||||
|
||||
const uuidV4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/
|
||||
|
||||
test('secure context keeps the native randomUUID value', () => {
|
||||
assert.equal(
|
||||
randomOperationId({ randomUUID: () => 'native-operation-id' }),
|
||||
'native-operation-id'
|
||||
)
|
||||
})
|
||||
|
||||
test('insecure context still returns a uuid from getRandomValues', () => {
|
||||
const insecure = {
|
||||
getRandomValues(bytes: Uint8Array) {
|
||||
crypto.getRandomValues(bytes)
|
||||
return bytes
|
||||
}
|
||||
}
|
||||
const first = randomOperationId(insecure)
|
||||
const second = randomOperationId(insecure)
|
||||
assert.match(first, uuidV4)
|
||||
assert.match(second, uuidV4)
|
||||
assert.notEqual(first, second)
|
||||
assert.ok(first.length <= 64)
|
||||
})
|
||||
|
||||
test('missing web crypto still returns a bounded operation id', () => {
|
||||
const id = randomOperationId({})
|
||||
assert.match(id, uuidV4)
|
||||
assert.ok(id.length <= 64)
|
||||
})
|
||||
Reference in new issue
Block a user