Preserve null remaining_events in package normalization
This commit is contained in:
19
resources/js/admin/__tests__/api.test.ts
Normal file
19
resources/js/admin/__tests__/api.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { normalizeTenantPackage } from '../api';
|
||||
|
||||
describe('normalizeTenantPackage', () => {
|
||||
it('keeps remaining_events null when payload is null', () => {
|
||||
const normalized = normalizeTenantPackage({ id: 1, remaining_events: null, used_events: 0 } as any);
|
||||
expect(normalized.remaining_events).toBeNull();
|
||||
});
|
||||
|
||||
it('keeps remaining_events null when payload is missing', () => {
|
||||
const normalized = normalizeTenantPackage({ id: 1, used_events: 0 } as any);
|
||||
expect(normalized.remaining_events).toBeNull();
|
||||
});
|
||||
|
||||
it('coerces remaining_events to number when provided', () => {
|
||||
const normalized = normalizeTenantPackage({ id: 1, remaining_events: '2', used_events: 0 } as any);
|
||||
expect(normalized.remaining_events).toBe(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user