first commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import { hasUploadedReceipt } from '../src/utils/order.mjs'
|
||||
|
||||
test('已取消订单没有回执地址时不视为已上传', () => {
|
||||
assert.equal(hasUploadedReceipt(''), false)
|
||||
assert.equal(hasUploadedReceipt(null), false)
|
||||
})
|
||||
|
||||
test('存在回执地址时视为已上传', () => {
|
||||
assert.equal(hasUploadedReceipt('https://example.com/receipt.jpg'), true)
|
||||
})
|
||||
@@ -0,0 +1,19 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import { normalizeRichTextImages } from '../src/utils/richText.mjs'
|
||||
|
||||
test('富文本图片移除固定尺寸并添加响应式内联样式', () => {
|
||||
const html = '<p>正文</p><img src="/a.png" width="800" height="1200" style="width:800px;height:1200px;border-radius:8px;">'
|
||||
const result = normalizeRichTextImages(html)
|
||||
|
||||
assert.doesNotMatch(result, /width="800"|height="1200"|width:800px|height:1200px/)
|
||||
assert.match(result, /width:100%;max-width:100%;height:auto;box-sizing:border-box;/)
|
||||
assert.match(result, /border-radius:8px;/)
|
||||
})
|
||||
|
||||
test('非图片富文本保持不变', () => {
|
||||
const html = '<p>普通正文</p>'
|
||||
|
||||
assert.equal(normalizeRichTextImages(html), html)
|
||||
})
|
||||
Reference in New Issue
Block a user