muse/book-reading-clip-lamp
A Wi‑Fi/USB‑C ESP32‑S3 reading lamp with OV5640 camera, microphone, speaker amplifier, rechargeable Li‑Po power management, six-LED boost light, USB protection/charging detection, and a clip/gooseneck enclosure with external FlexPIFA antenna.
- Version
- 0.4.3
- License
- unset
- Stars
- 0
tests/schematic-sheet-bounds.test.mjs
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { checkSheetBounds } from '../schematic-sheet-bounds.mjs'
const original = JSON.parse(readFileSync(new URL('./fixtures/schematic-text-overflow.json', import.meta.url)))
const page = {type:'schematic_sheet',schematic_sheet_id:'page',sheet_width:431.8,sheet_height:279.4,center:{x:0,y:0},name:'Test'}
const text = {type:'schematic_text',schematic_text_id:'text',schematic_sheet_id:'page',text:'Heading',font_size:.55,position:{x:0,y:0},rotation:0,anchor:'center'}
test('reproduces the real USBPower title and footer missed by upstream style rules', () => {
const issues=checkSheetBounds(original)
assert.equal(issues.length,2)
assert.ok(issues.some(i=>i.text.startsWith('02 /')&&i.overflowMm.top>9))
assert.ok(issues.some(i=>i.text.startsWith('Book Reading')&&i.overflowMm.bottom>12))
})
test('accepts an inset title and footer, but rejects crossing each drawing edge', () => {
assert.deepEqual(checkSheetBounds([page,{...text,position:{x:-21.5,y:14},anchor:'top_left'}]),[])
assert.deepEqual(checkSheetBounds([page,{...text,position:{x:-21.5,y:-13.8},anchor:'top_left',font_size:.3}]),[])
for(const position of [{x:-23,y:0},{x:23,y:0},{x:0,y:15},{x:0,y:-15}]) assert.equal(checkSheetBounds([page,{...text,position}]).length,1)
})
test('checks text extent, not only its anchor; handles font size and rotation', () => {
const long={...text,text:'A'.repeat(70),anchor:'left'}
assert.equal(checkSheetBounds([page,long]).length,1)
assert.deepEqual(checkSheetBounds([page,{...long,font_size:.18}]),[])
assert.equal(checkSheetBounds([page,{...long,rotation:90}])[0].overflowMm.top>0,true)
})
test('checks nonzero sheet centers and multiline bottom overflow', () => {
const shifted={...page,center:{x:100,y:-50}}
assert.deepEqual(checkSheetBounds([shifted,{...text,position:{x:100,y:-50}}]),[])
assert.equal(checkSheetBounds([page,{...text,position:{x:0,y:-14},anchor:'top',text:'First\nSecond\nThird'}]).length,1)
})