orderPromptConfirm.service.test.mjs 1.23 KB
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'

describe('orderPromptConfirm.helpers', async () => {
  const {
    resolveOrderPromptPaymentMethod,
    shouldOpenRecordingOrderPopup,
    isInvalidDjQrOnlySelection
  } = await import('../tabIndex/services/orderPromptConfirm.helpers.js')

  it('resolveOrderPromptPaymentMethod', () => {
    assert.equal(resolveOrderPromptPaymentMethod({ payFlag: 1 }), 1)
    assert.equal(
      resolveOrderPromptPaymentMethod({ payFlag: 2, payType: '5' }),
      '5'
    )
    assert.equal(
      resolveOrderPromptPaymentMethod({ payFlag: 2, payType: 3 }),
      3
    )
  })

  it('shouldOpenRecordingOrderPopup only for dj qr', () => {
    assert.equal(shouldOpenRecordingOrderPopup({ payFlag: 1 }), false)
    assert.equal(
      shouldOpenRecordingOrderPopup({ payFlag: 2, payType: 3 }),
      false
    )
    assert.equal(
      shouldOpenRecordingOrderPopup({ payFlag: 2, payType: '5' }),
      true
    )
  })

  it('isInvalidDjQrOnlySelection', () => {
    assert.equal(isInvalidDjQrOnlySelection({ payType: 3 }, true), true)
    assert.equal(isInvalidDjQrOnlySelection({ payType: '5' }, true), false)
    assert.equal(isInvalidDjQrOnlySelection({ payType: 3 }, false), false)
  })
})