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

import { mapKuaishouCloudFulfillmentItemsToBindings } from './kuaishou-cloud-fulfillment-config-service.js'

test('mapKuaishouCloudFulfillmentItemsToBindings maps 91kaquan rules', () => {
  assert.deepEqual(
    mapKuaishouCloudFulfillmentItemsToBindings({
      items: [
        {
          enabled: true,
          provider: '91kaquan',
          platform: 'kuaishou',
          shopId: '91kaquan',
          internalSkuCode: 'sku-1',
          internalSkuName: '内部商品',
          externalSkuCode: '952',
          externalItemId: '952',
          externalSkuName: '测试2',
          cloudSkuId: 28,
        },
      ],
    }),
    [
      {
        provider: '91kaquan',
        platform: 'kuaishou',
        shopId: '91kaquan',
        skuCode: 'sku-1',
        skuName: '内部商品',
        profileKey: 'kuaishou_ct_assisted',
        enabled: true,
        priority: 100,
        config: {
          flowType: 'kuaishou_cloud_fulfillment',
          configId: '',
          cloudtentacles: {
            cloudSourceKey: 'default',
            cloudSourceKeyFallbacks: [],
            skuId: 28,
            skuName: '',
            vnKey: '1',
            autoBuyEnabled: true,
            minAssetReserve: 0,
            autoReturnNumberAfterDispatch: false,
          },
          kuaishouConsume: {
            shopId: '',
            shopName: '',
            autoConsumeAfterDispatch: false,
          },
          notes: '',
        },
        match: {
          externalSkuCode: '952',
          externalItemId: '952',
          externalSkuName: '测试2',
          config: {
            resolvedSkuName: '内部商品',
          },
        },
      },
    ],
  )
})
