storage-admin.test.ts31 lines · main
1import { describe, expect, test } from 'bun:test';
2
3import { evaluateStorageLimit } from './storage-admin.js';
4
5describe('evaluateStorageLimit (Sprint 4 over-limit flag math)', () => {
6 test('under both caps → not over', () => {
7 expect(evaluateStorageLimit({ rowCount: 10, tableCount: 2, maxRows: 100, maxTables: 50 })).toEqual({
8 overRows: false,
9 overTables: false,
10 overLimit: false,
11 });
12 });
13
14 test('exactly at the cap is NOT over (strictly greater than)', () => {
15 expect(
16 evaluateStorageLimit({ rowCount: 100, tableCount: 50, maxRows: 100, maxTables: 50 }),
17 ).toEqual({ overRows: false, overTables: false, overLimit: false });
18 });
19
20 test('one over the row cap → overRows + overLimit', () => {
21 expect(
22 evaluateStorageLimit({ rowCount: 101, tableCount: 2, maxRows: 100, maxTables: 50 }),
23 ).toEqual({ overRows: true, overTables: false, overLimit: true });
24 });
25
26 test('over the table cap only → overTables + overLimit', () => {
27 expect(
28 evaluateStorageLimit({ rowCount: 10, tableCount: 51, maxRows: 100, maxTables: 50 }),
29 ).toEqual({ overRows: false, overTables: true, overLimit: true });
30 });
31});