Phase 5 cleanup
This commit is contained in:
parent
5536acd67d
commit
76a516a417
136 changed files with 6322 additions and 1985 deletions
|
|
@ -8,7 +8,11 @@ import {
|
|||
|
||||
describe('CreatePurchaseItemSchema', () => {
|
||||
it('accepts minimal valid item', () => {
|
||||
const result = CreatePurchaseItemSchema.safeParse({ name: 'Tylenol 30ct', quantity: 30, unit: 'tablet' });
|
||||
const result = CreatePurchaseItemSchema.safeParse({
|
||||
name: 'Tylenol 30ct',
|
||||
quantity: 30,
|
||||
unit: 'tablet',
|
||||
});
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) expect(result.data.addedToCabinet).toBeUndefined();
|
||||
});
|
||||
|
|
@ -27,19 +31,29 @@ describe('CreatePurchaseItemSchema', () => {
|
|||
});
|
||||
|
||||
it('rejects empty name', () => {
|
||||
expect(CreatePurchaseItemSchema.safeParse({ name: '', quantity: 1, unit: 'tablet' }).success).toBe(false);
|
||||
expect(
|
||||
CreatePurchaseItemSchema.safeParse({ name: '', quantity: 1, unit: 'tablet' }).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('rejects non-positive quantity', () => {
|
||||
expect(CreatePurchaseItemSchema.safeParse({ name: 'X', quantity: 0, unit: 'tablet' }).success).toBe(false);
|
||||
expect(
|
||||
CreatePurchaseItemSchema.safeParse({ name: 'X', quantity: 0, unit: 'tablet' }).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('rejects empty unit', () => {
|
||||
expect(CreatePurchaseItemSchema.safeParse({ name: 'X', quantity: 1, unit: '' }).success).toBe(false);
|
||||
expect(CreatePurchaseItemSchema.safeParse({ name: 'X', quantity: 1, unit: '' }).success).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
it('trims name whitespace', () => {
|
||||
const result = CreatePurchaseItemSchema.parse({ name: ' Tylenol ', quantity: 1, unit: 'tablet' });
|
||||
const result = CreatePurchaseItemSchema.parse({
|
||||
name: ' Tylenol ',
|
||||
quantity: 1,
|
||||
unit: 'tablet',
|
||||
});
|
||||
expect(result.name).toBe('Tylenol');
|
||||
});
|
||||
});
|
||||
|
|
@ -53,7 +67,11 @@ describe('CreatePurchaseSchema', () => {
|
|||
});
|
||||
|
||||
it('accepts ordered status', () => {
|
||||
const result = CreatePurchaseSchema.safeParse({ storeId: 'st-1', status: 'ordered', items: [validItem] });
|
||||
const result = CreatePurchaseSchema.safeParse({
|
||||
storeId: 'st-1',
|
||||
status: 'ordered',
|
||||
items: [validItem],
|
||||
});
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
|
|
@ -66,7 +84,10 @@ describe('CreatePurchaseSchema', () => {
|
|||
});
|
||||
|
||||
it('rejects invalid status', () => {
|
||||
expect(CreatePurchaseSchema.safeParse({ storeId: 'st-1', status: 'pending', items: [validItem] }).success).toBe(false);
|
||||
expect(
|
||||
CreatePurchaseSchema.safeParse({ storeId: 'st-1', status: 'pending', items: [validItem] })
|
||||
.success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('accepts optional purchasedAt datetime', () => {
|
||||
|
|
@ -79,7 +100,13 @@ describe('CreatePurchaseSchema', () => {
|
|||
});
|
||||
|
||||
it('rejects invalid purchasedAt', () => {
|
||||
expect(CreatePurchaseSchema.safeParse({ storeId: 'st-1', items: [validItem], purchasedAt: 'not-a-date' }).success).toBe(false);
|
||||
expect(
|
||||
CreatePurchaseSchema.safeParse({
|
||||
storeId: 'st-1',
|
||||
items: [validItem],
|
||||
purchasedAt: 'not-a-date',
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue