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

import { mapKuaishouEticketStableInfoResult } from './info-service.js'

test('mapKuaishouEticketStableInfoResult extracts shop info from payload', () => {
  const result = mapKuaishouEticketStableInfoResult({
    result: 1,
    error_msg: '成功',
    requestId: '777795601162094230',
    data: {
      userInfo: {
        userId: 4269276762,
        userName: '稚嫩游戏交易店',
        userAvatar: 'https://example.com/avatar.jpg',
      },
      bizStatus: {
        settleStatus: 200,
      },
    },
  }, {
    baseUrl: 'https://s.kwaixiaodian.com',
    cookie: 'sid=abc',
  })

  assert.equal(result.ok, true)
  assert.equal(result.shop.shopId, '4269276762')
  assert.equal(result.shop.kshopName, '稚嫩游戏交易店')
  assert.equal(result.shop.userAvatar, 'https://example.com/avatar.jpg')
  assert.equal(result.shop.settleStatus, 200)
  assert.equal(result.shop.hasCookie, true)
})
