ray-template/__test__/hooks/useWatermark.spec.ts
XiaoDaiGua-Ray 39d2e82439 feat: enhance template layouts, hooks, and icon workflow
Add interactive hook examples, shared Pinia runtime state, and configurable layouts.
Generate typed namespaced icons during development, HMR, and builds.
Refine the UI and establish project comment and design conventions.

Validation: typecheck, ESLint, 181 tests, and production build passed.
2026-11-03 13:17:58 +08:00

40 lines
1.1 KiB
TypeScript

import { useWatermark } from '../../src/hooks/template/useWatermark'
import { useSettingGetters } from '../../src/store'
import setupMiniApp from '../utils/setupMiniApp'
describe('useWatermark', async () => {
await setupMiniApp()
const { setWatermarkContent, showWatermark, hiddenWatermark } = useWatermark()
it('should set watermark content', () => {
const { getWatermarkConfig } = useSettingGetters()
const content = 'Ray Template Yes!'
setWatermarkContent(content)
expect(getWatermarkConfig.value.content).toBe(content)
})
it('should update watermark', () => {
showWatermark()
const { getWatermarkSwitch: show } = useSettingGetters()
expect(show.value).toBe(true)
hiddenWatermark()
const { getWatermarkSwitch: hidden } = useSettingGetters()
expect(hidden.value).toBe(false)
})
it('keeps the previous text when an empty string is supplied', () => {
setWatermarkContent('Keep this')
setWatermarkContent('')
expect(useSettingGetters().getWatermarkConfig.value.content).toBe(
'Keep this',
)
})
})