quotationPackageBoundary.test.mjs
1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import assert from 'node:assert/strict'
import { readFileSync, readdirSync, statSync } from 'node:fs'
import path from 'node:path'
import test from 'node:test'
import { fileURLToPath } from 'node:url'
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..')
const quotationRoot = path.join(projectRoot, 'packageEquity/pages/carQuotation')
function listSourceFiles(directory) {
return readdirSync(directory, { withFileTypes: true }).flatMap(entry => {
const target = path.join(directory, entry.name)
if (entry.isDirectory()) return listSourceFiles(target)
return /\.(?:js|json|wxml|wxs)$/.test(entry.name) && statSync(target).isFile()
? [target]
: []
})
}
test('quotation sources do not import another business subpackage', () => {
for (const filePath of listSourceFiles(quotationRoot)) {
const source = readFileSync(filePath, 'utf8')
assert.doesNotMatch(source, /~\/(?:tabWorkOrder|packageUsedCar|packageDynamicForm)\//, filePath)
assert.doesNotMatch(source, /(?:\.\.\/)+(?:tabWorkOrder|packageUsedCar|packageDynamicForm)\//, filePath)
}
})
test('reusable simple quotation product strategy is not owned by the page directory', () => {
const componentPath = path.join(
quotationRoot,
'components/SecondStepSimple/SecondStep.js'
)
assert.doesNotMatch(
readFileSync(componentPath, 'utf8'),
/createOrderCarQuotationSimple\/productStrategy/
)
})