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

import { resolveKuaishouFeifeiProductByName } from './product-rule-service.js'

test('resolveKuaishouFeifeiProductByName matches generated name-code mapping by normalized name', () => {
  const match = resolveKuaishouFeifeiProductByName('【自动发货】套装-Alan Walker', {
    rules: [
      {
        productName: '套装-Alan Walker',
        normalizedProductName: '套装 alan walker',
        productCode: '10000013',
        skuName: '套装-Alan Walker',
      },
    ],
  })

  assert.equal(match?.productCode, '10000013')
  assert.equal(match?.matchMode, 'kuaishou_feifei_name')
  assert.equal(match?.skuName, '套装-Alan Walker')
  assert.equal(match?.normalizedProductName, '套装 alan walker')
})
