mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-11-29 16:13:41 +08:00
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.
40 lines
1.1 KiB
TypeScript
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',
|
|
)
|
|
})
|
|
})
|