25 lines
1.5 KiB
JavaScript
25 lines
1.5 KiB
JavaScript
|
|
import test from 'node:test'
|
||
|
|
import assert from 'node:assert/strict'
|
||
|
|
import { readFileSync } from 'node:fs'
|
||
|
|
|
||
|
|
const source = readFileSync(new URL('../../src/components/PendingReceipts/index.vue', import.meta.url), 'utf8')
|
||
|
|
const rule = selector => source.match(new RegExp(`${selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\{([^}]+)\\}`))?.[1] || ''
|
||
|
|
|
||
|
|
test('pending batch sidebar overrides the legacy global aside decoration with theme-aware styles', () => {
|
||
|
|
const sidebar = rule('.pending-sources')
|
||
|
|
for (const declaration of ['padding:0', 'margin:0', 'background:var(--el-bg-color)', 'color:var(--el-text-color-primary)', 'font:inherit', 'line-height:normal']) {
|
||
|
|
assert.ok(sidebar.includes(declaration), `Missing sidebar reset: ${declaration}`)
|
||
|
|
}
|
||
|
|
assert.doesNotMatch(sidebar, /#[0-9a-f]{3,8}\b|\b(?:white|black)\b/i)
|
||
|
|
assert.match(source, /<aside class="pending-sources" aria-label="待入库批次">/)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('pending batch buttons retain theme-aware normal, hover, active and keyboard focus states', () => {
|
||
|
|
assert.match(rule('.pending-source'), /background:var\(--el-bg-color\)/)
|
||
|
|
assert.match(rule('.pending-source'), /color:var\(--el-text-color-regular\)/)
|
||
|
|
assert.match(rule('.pending-source:hover'), /background:var\(--el-fill-color-light\)/)
|
||
|
|
assert.match(rule('.pending-source.is-active'), /background:var\(--el-color-primary-light-9\)/)
|
||
|
|
assert.match(rule('.pending-source:focus-visible'), /outline:2px solid var\(--el-color-primary\)/)
|
||
|
|
assert.match(source, /:aria-pressed="activeKey==='ALL'"/)
|
||
|
|
})
|