submitGoodsSnapshot.test.mjs 1.52 KB
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { buildSubmitGoodsSnapshot } from '../services/submitGoodsSnapshot.js'

describe('submitGoodsSnapshot', () => {
  it('maps goodsList approval and subOrder fields', () => {
    const snapshot = buildSubmitGoodsSnapshot(
      {
        goodsList: [
          {
            goodsFlag: 1,
            count: 2,
            marketingFlag: 1,
            activityId: 9,
            goods: {
              sellPrice: 100,
              activitySellPrice: 299,
              marketingFlag: 1,
              activityId: 9,
              validMinSellPrice: 'Y',
              minSellPrice: 200
            }
          }
        ],
        orderObj: {
          subOrderList: [
            {
              merchantGoodsId: 1,
              totalPrice: 100,
              finalPrice: 200,
              marketingFlag: 1,
              activityId: 9,
              modifyFlag: 1,
              number: 2
            }
          ]
        }
      },
      {
        approvalItems: [
          {
            type: 'single',
            name: '太阳膜',
            activityPrice: 299,
            totalPrice: 100,
            marketingFlag: 1
          }
        ]
      }
    )

    assert.equal(snapshot.goodsList.length, 1)
    assert.equal(snapshot.goodsList[0].goods.activitySellPrice, 299)
    assert.equal(snapshot.approvalItems[0].activityPrice, 299)
    assert.equal(snapshot.subOrderList[0].marketingFlag, 1)
    assert.equal(snapshot.subOrderList[0].activityId, 9)
  })
})