import { buildQuotaQuery, quotaGate, usagePercent } from '@/views/sense/quota/quotaState' describe('Sense quota state', () => { test('keeps pagination independent from the configured quota', () => { expect(buildQuotaQuery({ pageIndex: 2, pageSize: 64, keyword: ' 东门 ', status: 'active' })).toEqual({ pageIndex: 2, pageSize: 64, keyword: '东门', status: 'active' }) }) test('closes writes when full or unreadable while preserving an actionable explanation', () => { expect(quotaGate({ readStatus: 'readable', remaining: 4 }).writable).toBe(true) expect(quotaGate({ readStatus: 'readable', remaining: 0 })).toMatchObject({ writable: false, title: '当前配额已满' }) expect(quotaGate({ readStatus: 'unreadable', remaining: 4 })).toMatchObject({ writable: false, title: '配额配置不可读取' }) }) test('bounds the occupancy percentage without treating quota as a list limit', () => { expect(usagePercent({ used: 12, limit: 16 })).toBe(75) expect(usagePercent({ used: 20, limit: 16 })).toBe(100) expect(usagePercent({ used: 12, limit: 0 })).toBe(0) }) })