8a48765a46
集中保留原版权声明,移除文件头检查和全局测试忽略规则。验证:全量单测、受影响用例复测及静态检查通过。
35 lines
1008 B
JavaScript
35 lines
1008 B
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { getOrgQuotaAvailability } from '../../src/pages/Organization/orgQuotaAvailability.js';
|
|
|
|
test('quota availability uses unrounded remaining ratio and includes the 20% boundary', () => {
|
|
for (const [quota, used_quota, type] of [
|
|
[110855.34, 19254.66, 'success'],
|
|
[20.001, 79.999, 'success'],
|
|
[20, 80, 'warning'],
|
|
[19.999, 80.001, 'warning'],
|
|
[1, 99, 'warning'],
|
|
[1, 0, 'success'],
|
|
[0, 0, 'danger'],
|
|
[-1, 100, 'danger'],
|
|
['20', '80', 'warning'],
|
|
]) {
|
|
assert.equal(getOrgQuotaAvailability({ quota, used_quota }).type, type);
|
|
}
|
|
});
|
|
|
|
test('missing or invalid quota does not claim that credit is sufficient', () => {
|
|
for (const data of [
|
|
null,
|
|
{},
|
|
{ quota: null },
|
|
{ quota: '' },
|
|
{ quota: 'invalid' },
|
|
{ quota: Infinity },
|
|
{ quota: 10, used_quota: NaN },
|
|
{ quota: 10, used_quota: -1 },
|
|
]) {
|
|
assert.equal(getOrgQuotaAvailability(data), null);
|
|
}
|
|
});
|