31 lines
1.7 KiB
JavaScript
31 lines
1.7 KiB
JavaScript
|
|
import test from 'node:test'
|
||
|
|
import assert from 'node:assert/strict'
|
||
|
|
import { readFileSync } from 'node:fs'
|
||
|
|
import { compileString } from 'sass'
|
||
|
|
import { businessDescriptionColumns } from '../../src/utils/business-layout.js'
|
||
|
|
|
||
|
|
test('description columns use actual content width, keeping a readable label-value pair', () => {
|
||
|
|
for (const [width, expected] of [[0,1],[335,1],[559,1],[599,1],[600,2],[632,2],[899,2],[900,3],[1366,3],[2560,3]])
|
||
|
|
assert.equal(businessDescriptionColumns(width), expected, `width=${width}`)
|
||
|
|
for (const width of [undefined, null, NaN, Infinity, -1, 'not a width']) assert.equal(businessDescriptionColumns(width),1)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('responsive form rules are opt-in and collapse columns using the form container', () => {
|
||
|
|
const source=readFileSync(new URL('../../src/assets/styles/business-forms.scss',import.meta.url),'utf8')
|
||
|
|
const css=compileString(source).css
|
||
|
|
assert.match(css,/container:\s*business-form\s*\/\s*inline-size/)
|
||
|
|
assert.match(css,/@container business-form \(max-width: 520px\)/)
|
||
|
|
assert.match(css,/\.business-responsive-form \.el-row > \.el-col-12/)
|
||
|
|
assert.match(css,/white-space:\s*nowrap/)
|
||
|
|
assert.doesNotMatch(css,/\.el-dialog\s+\.el-col-12/)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('our two-column editors opt in without changing collaboration source', () => {
|
||
|
|
for(const path of ['project/info','system/user','system/menu','system/dept','system/notice','warehouse/purchase']) {
|
||
|
|
const source=readFileSync(new URL(`../../src/views/${path}/index.vue`,import.meta.url),'utf8')
|
||
|
|
assert.match(source,/<el-form[^>]*class="business-responsive-form"[^>]*label-width="auto"/,path)
|
||
|
|
}
|
||
|
|
const styles=readFileSync(new URL('../../src/assets/styles/business-ui.scss',import.meta.url),'utf8')
|
||
|
|
assert.match(styles,/@use '\.\/business-forms\.scss'/)
|
||
|
|
})
|