gongxiangp2/lib/__tests__/material-cleanup-display-images.test.ts
2026-03-06 14:14:50 +08:00

19 lines
748 B
TypeScript

import { normalizeDisplayImages } from '../material-cleanup'
describe('displayImages 清理兼容性测试', () => {
test('支持 String[] 格式', () => {
const result = normalizeDisplayImages([' https://a.com/1.webp ', '', 'https://a.com/2.webp'])
expect(result).toEqual([' https://a.com/1.webp ', 'https://a.com/2.webp'])
})
test('支持 JSON 字符串格式', () => {
const result = normalizeDisplayImages('["https://a.com/1.webp","https://a.com/2.webp"]')
expect(result).toEqual(['https://a.com/1.webp', 'https://a.com/2.webp'])
})
test('支持单个 URL 字符串格式', () => {
const result = normalizeDisplayImages('https://a.com/only.webp')
expect(result).toEqual(['https://a.com/only.webp'])
})
})