import test from 'node:test'
import assert from 'node:assert/strict'

import { formatWechatPayAuthorizationHeader } from '../src/lite/wechat-pay.mjs'

test('wechat pay authorization header separates scheme and parameters with a space', () => {
  const header = formatWechatPayAuthorizationHeader({
    mchId: '1900000109',
    nonceStr: 'nonce-value',
    signature: 'signature-value',
    timestamp: '1710000000',
    serialNo: 'serial-value',
  })

  assert.equal(
    header,
    'WECHATPAY2-SHA256-RSA2048 mchid="1900000109",nonce_str="nonce-value",signature="signature-value",timestamp="1710000000",serial_no="serial-value"',
  )
  assert.doesNotMatch(header, /^WECHATPAY2-SHA256-RSA2048,/)
})
