37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
|
|
/* eslint-env node */
|
||
|
|
import fs from 'node:fs'
|
||
|
|
import path from 'node:path'
|
||
|
|
import { fileURLToPath } from 'node:url'
|
||
|
|
|
||
|
|
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
||
|
|
const trendOptionsFile = path.join(currentDir, '..', 'utils', 'trendOptions.ts')
|
||
|
|
const trendOptionsSource = fs.readFileSync(trendOptionsFile, 'utf8')
|
||
|
|
|
||
|
|
const expectations = [
|
||
|
|
['steady y-axis upper padding uses 1.15', /const\s+STEADY_AXIS_EXPAND_RATIO\s*=\s*1\.15/],
|
||
|
|
['steady y-axis lower padding uses 0.85', /const\s+STEADY_AXIS_SHRINK_RATIO\s*=\s*0\.85/],
|
||
|
|
[
|
||
|
|
'steady integer ranges still enter readable-axis normalization',
|
||
|
|
/rawInterval\s*>=\s*STEADY_AXIS_SMALL_INTERVAL_THRESHOLD/,
|
||
|
|
true
|
||
|
|
],
|
||
|
|
['steady y-axis keeps readable interval normalization', /getReadableAxisInterval\(axisRange\s*\/\s*currentSplitCount\)/],
|
||
|
|
['steady y-axis keeps min label visible', /showMinLabel:\s*true/],
|
||
|
|
['steady y-axis keeps max label visible', /showMaxLabel:\s*true/]
|
||
|
|
]
|
||
|
|
|
||
|
|
const failures = expectations.filter(([, pattern, shouldBeMissing]) => {
|
||
|
|
const exists = pattern.test(trendOptionsSource)
|
||
|
|
return shouldBeMissing ? exists : !exists
|
||
|
|
})
|
||
|
|
|
||
|
|
if (failures.length) {
|
||
|
|
console.error('steady axis range contract check failed:')
|
||
|
|
for (const [name] of failures) {
|
||
|
|
console.error(`- ${name}`)
|
||
|
|
}
|
||
|
|
process.exit(1)
|
||
|
|
}
|
||
|
|
|
||
|
|
console.log('steady axis range contract check passed')
|