popupBehavior.test.mjs
1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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')
})
})