46 lines
2.6 KiB
JavaScript
46 lines
2.6 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { readFile } from 'node:fs/promises'
|
|
|
|
const root = new URL('../src/views/m/crm/product/', import.meta.url)
|
|
const util = await readFile(new URL('../src/utils/mp-crm-confirm.ts', import.meta.url), 'utf8')
|
|
const alias = await readFile(new URL('../src/utils/mp-crm-product-confirm.ts', import.meta.url), 'utf8')
|
|
const primitives = await readFile(new URL('../src/styles/mp-crm-primitives.scss', import.meta.url), 'utf8')
|
|
const list = await readFile(new URL('index.vue', root), 'utf8')
|
|
const detail = await readFile(new URL('detail.vue', root), 'utf8')
|
|
const categories = await readFile(new URL('categories.vue', root), 'utf8')
|
|
|
|
assert.match(util, /CrmConfirmKind\s*=\s*'default'\s*\|\s*'danger'/, 'helper 必须支持 danger kind')
|
|
assert.match(util, /kind\s*===\s*'danger'/, 'helper 必须分支处理 danger')
|
|
assert.match(util, /mp-crm-dialog--danger/, 'helper 必须带 danger className')
|
|
assert.match(util, /mp-crm-dialog__title/, '方案 B 标题须写入 HTML')
|
|
assert.match(util, /#dc2626/, '删除确认色必须为危险红')
|
|
assert.match(util, /#0a9f6d/, '普通确认色必须为三墙绿')
|
|
assert.doesNotMatch(util, /round-button/, '禁止 round-button 主题')
|
|
assert.doesNotMatch(util, /#10b981/, '禁止 Fresh Mint')
|
|
|
|
assert.match(alias, /showCrmConfirmDialog as showProductConfirmDialog/, '产品侧须转发共用 helper')
|
|
|
|
assert.match(primitives, /body \.van-dialog\.mp-crm-dialog/, 'primitives 必须限定 CRM Dialog')
|
|
assert.match(primitives, /mp-crm-dialog--danger/, 'primitives 必须覆盖危险确认键')
|
|
assert.match(primitives, /mp-crm-dialog__warn-icon/, 'primitives 必须有警示图标')
|
|
assert.match(primitives, /mp-crm-dialog__title/, 'primitives 必须有居中标题')
|
|
assert.doesNotMatch(primitives, /#10b981/, 'scss 禁止 Fresh Mint')
|
|
|
|
for (const [name, src] of [
|
|
['index', list],
|
|
['detail', detail],
|
|
['categories', categories]
|
|
]) {
|
|
assert.match(src, /showProductConfirmDialog/, `${name} 必须使用 showProductConfirmDialog`)
|
|
assert.doesNotMatch(src, /showConfirmDialog\s*\(/, `${name} 不得直接调用 showConfirmDialog`)
|
|
}
|
|
|
|
assert.match(list, /kind:\s*'danger'/, '列表删除必须 danger')
|
|
assert.match(list, /kind:\s*'default'/, '列表上下架必须 default')
|
|
assert.match(detail, /kind:\s*'danger'/, '详情删除必须 danger')
|
|
assert.doesNotMatch(detail, /fetchUpdateProductStatus/, '详情不提供上下架')
|
|
assert.match(categories, /kind:\s*'danger'/, '分类删除必须 danger')
|
|
assert.match(categories, /删除分类/, '分类删除标题须为删除分类')
|
|
|
|
console.log('mp-crm-product-confirm-dom: ok')
|