test(08-01): add failing tests for Calculator widget and registry constraints (RED)
- calculator-widget.test.tsx: 5 behaviour tests (render, arithmetic, div/0, keyboard, decimal) - widget-registry.test.tsx: DASH-11 structure check for all 8 widget types including new Phase-8 types - Both suites fail (RED baseline) — implementation does not exist yet
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { WIDGET_CONSTRAINTS, type WidgetType } from './widget-registry';
|
||||
|
||||
/**
|
||||
* DASH-11: Every WidgetType entry in WIDGET_CONSTRAINTS must have
|
||||
* the four numeric grid-constraint fields: minW, minH, defaultW, defaultH.
|
||||
*/
|
||||
|
||||
const ALL_WIDGET_TYPES: WidgetType[] = [
|
||||
// Existing types
|
||||
'clock',
|
||||
'search',
|
||||
'calendar',
|
||||
'note',
|
||||
// New types (Phase 8)
|
||||
'calculator',
|
||||
'favorites',
|
||||
'link',
|
||||
'stopwatch',
|
||||
];
|
||||
|
||||
describe('WIDGET_CONSTRAINTS (DASH-11)', () => {
|
||||
it('contains entries for all expected widget types', () => {
|
||||
for (const type of ALL_WIDGET_TYPES) {
|
||||
expect(
|
||||
WIDGET_CONSTRAINTS,
|
||||
`WIDGET_CONSTRAINTS must contain key "${type}"`,
|
||||
).toHaveProperty(type);
|
||||
}
|
||||
});
|
||||
|
||||
it.each(ALL_WIDGET_TYPES)(
|
||||
'WIDGET_CONSTRAINTS["%s"] has numeric minW, minH, defaultW, defaultH',
|
||||
(type) => {
|
||||
const constraints = WIDGET_CONSTRAINTS[type];
|
||||
|
||||
expect(typeof constraints.minW, `${type}.minW must be a number`).toBe('number');
|
||||
expect(typeof constraints.minH, `${type}.minH must be a number`).toBe('number');
|
||||
expect(typeof constraints.defaultW, `${type}.defaultW must be a number`).toBe('number');
|
||||
expect(typeof constraints.defaultH, `${type}.defaultH must be a number`).toBe('number');
|
||||
|
||||
expect(constraints.minW, `${type}.minW must be >= 1`).toBeGreaterThanOrEqual(1);
|
||||
expect(constraints.minH, `${type}.minH must be >= 1`).toBeGreaterThanOrEqual(1);
|
||||
expect(constraints.defaultW, `${type}.defaultW >= minW`).toBeGreaterThanOrEqual(constraints.minW);
|
||||
expect(constraints.defaultH, `${type}.defaultH >= minH`).toBeGreaterThanOrEqual(constraints.minH);
|
||||
},
|
||||
);
|
||||
|
||||
it('WIDGET_CONSTRAINTS contains new Phase-8 keys', () => {
|
||||
expect(Object.keys(WIDGET_CONSTRAINTS)).toContain('calculator');
|
||||
expect(Object.keys(WIDGET_CONSTRAINTS)).toContain('favorites');
|
||||
expect(Object.keys(WIDGET_CONSTRAINTS)).toContain('link');
|
||||
expect(Object.keys(WIDGET_CONSTRAINTS)).toContain('stopwatch');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user