popupBehavior.test.mjs 1.12 KB
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import {
  getPopupSlotClass,
  shouldShowCloseIcon,
  shouldShowFooter,
  shouldShowTips
} from '../components/Popup/popup.helpers.js'

describe('popupBehavior', () => {
  it('POP-01 default 模式有 footer', () => {
    assert.equal(shouldShowFooter('default'), true)
  })

  it('POP-02 none 模式无 footer', () => {
    assert.equal(shouldShowFooter('none'), false)
  })

  it('POP-03 tips 模式有 footer', () => {
    assert.equal(shouldShowFooter('tips'), true)
  })

  it('POP-04 none 模式有关闭图标', () => {
    assert.equal(shouldShowCloseIcon('none', false), true)
  })

  it('POP-05 showCloseIcon 显式开启', () => {
    assert.equal(shouldShowCloseIcon('default', true), true)
  })

  it('POP-06 tips 模式显示 tips 文案', () => {
    assert.equal(shouldShowTips('tips', '提示'), true)
    assert.equal(shouldShowTips('tips', ''), false)
  })

  it('POP-07 tips 模式 slot class', () => {
    assert.equal(getPopupSlotClass('tips', true), 'popup-slot-other')
    assert.equal(getPopupSlotClass('default', false), 'popup-slot')
  })
})