Tests refactor
This commit is contained in:
parent
245520fb50
commit
99134d8556
165 changed files with 911 additions and 531 deletions
|
|
@ -0,0 +1,257 @@
|
|||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
|
||||
const { mockFind, mockFindOne, mockFindOneAndUpdate, mockAggregate, mockSave } = vi.hoisted(() => ({
|
||||
mockFind: vi.fn(),
|
||||
mockFindOne: vi.fn(),
|
||||
mockFindOneAndUpdate: vi.fn(),
|
||||
mockAggregate: vi.fn(),
|
||||
mockSave: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('../../../src/schemas/purchase.schema.js', () => {
|
||||
const findChain = () => ({
|
||||
sort: vi.fn().mockReturnThis(),
|
||||
limit: vi.fn().mockReturnThis(),
|
||||
lean: vi.fn().mockReturnThis(),
|
||||
exec: mockFind,
|
||||
});
|
||||
const findOneChain = () => ({ lean: vi.fn().mockReturnThis(), exec: mockFindOne });
|
||||
const updateChain = () => ({ exec: mockFindOneAndUpdate });
|
||||
const aggregateChain = () => ({ exec: mockAggregate });
|
||||
|
||||
class FakeModel {
|
||||
data: unknown;
|
||||
constructor(data: unknown) {
|
||||
this.data = data;
|
||||
}
|
||||
save = mockSave;
|
||||
toObject() {
|
||||
return this.data;
|
||||
}
|
||||
static find = vi.fn(() => findChain());
|
||||
static findOne = vi.fn(() => findOneChain());
|
||||
static findOneAndUpdate = vi.fn(() => updateChain());
|
||||
static aggregate = vi.fn(() => aggregateChain());
|
||||
}
|
||||
return { PurchaseModel: FakeModel };
|
||||
});
|
||||
|
||||
import { PurchasesRepository } from '../../../src/modules/purchases/purchases.repository.js';
|
||||
|
||||
const makeItem = (overrides = {}) => ({
|
||||
medicineProductId: 'mp-1',
|
||||
medicineId: 'med-1',
|
||||
name: 'Tylenol',
|
||||
quantity: 30,
|
||||
unit: 'tablet',
|
||||
addedToCabinet: false,
|
||||
...overrides,
|
||||
});
|
||||
|
||||
describe(PurchasesRepository.name, () => {
|
||||
let repo: PurchasesRepository;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
repo = new PurchasesRepository();
|
||||
});
|
||||
|
||||
describe('create', () => {
|
||||
it('saves and returns plain object', async () => {
|
||||
const data = {
|
||||
householdId: 'hh1',
|
||||
storeId: 'st-1',
|
||||
storeName: 'CVS',
|
||||
status: 'in_cabinet',
|
||||
items: [makeItem()],
|
||||
purchasedAt: new Date(),
|
||||
createdBy: 'u-1',
|
||||
};
|
||||
mockSave.mockResolvedValue({ toObject: () => data });
|
||||
|
||||
const result = await repo.create(data);
|
||||
|
||||
expect(mockSave).toHaveBeenCalled();
|
||||
expect(result).toEqual(data);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findByHousehold', () => {
|
||||
it('returns paginated items without hasMore', async () => {
|
||||
const items = [{ _id: { toString: () => 'p-1' }, householdId: 'hh1' }];
|
||||
mockFind.mockResolvedValue(items);
|
||||
|
||||
const result = await repo.findByHousehold('hh1', { limit: 20 });
|
||||
|
||||
expect(result.data).toEqual(items);
|
||||
expect(result.pagination.hasMore).toBe(false);
|
||||
expect(result.pagination.cursor).toBeNull();
|
||||
});
|
||||
|
||||
it('returns hasMore and cursor when results exceed limit', async () => {
|
||||
const items = Array.from({ length: 21 }, (_, i) => ({ _id: { toString: () => `p-${i}` } }));
|
||||
mockFind.mockResolvedValue(items);
|
||||
|
||||
const result = await repo.findByHousehold('hh1', { limit: 20 });
|
||||
|
||||
expect(result.data).toHaveLength(20);
|
||||
expect(result.pagination.hasMore).toBe(true);
|
||||
expect(result.pagination.cursor).not.toBeNull();
|
||||
});
|
||||
|
||||
it('filters by status when provided', async () => {
|
||||
mockFind.mockResolvedValue([]);
|
||||
const { PurchaseModel } = await import('../../../src/schemas/purchase.schema.js');
|
||||
|
||||
await repo.findByHousehold('hh1', { limit: 20, status: 'ordered' });
|
||||
|
||||
expect(PurchaseModel.find).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ status: 'ordered' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('filters by storeId when provided', async () => {
|
||||
mockFind.mockResolvedValue([]);
|
||||
const { PurchaseModel } = await import('../../../src/schemas/purchase.schema.js');
|
||||
|
||||
await repo.findByHousehold('hh1', { limit: 20, storeId: 'st-1' });
|
||||
|
||||
expect(PurchaseModel.find).toHaveBeenCalledWith(expect.objectContaining({ storeId: 'st-1' }));
|
||||
});
|
||||
|
||||
it('applies cursor filter when provided', async () => {
|
||||
mockFind.mockResolvedValue([]);
|
||||
const cursor = Buffer.from('p-1').toString('base64');
|
||||
const { PurchaseModel } = await import('../../../src/schemas/purchase.schema.js');
|
||||
|
||||
await repo.findByHousehold('hh1', { limit: 20, cursor });
|
||||
|
||||
expect(PurchaseModel.find).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ _id: { $lt: 'p-1' } }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findById', () => {
|
||||
it('returns purchase when found', async () => {
|
||||
const purchase = { _id: 'p-1', householdId: 'hh1' };
|
||||
mockFindOne.mockResolvedValue(purchase);
|
||||
|
||||
const result = await repo.findById('p-1', 'hh1');
|
||||
|
||||
expect(result).toEqual(purchase);
|
||||
});
|
||||
|
||||
it('returns null when not found', async () => {
|
||||
mockFindOne.mockResolvedValue(null);
|
||||
|
||||
const result = await repo.findById('missing', 'hh1');
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('update', () => {
|
||||
it('updates notes and returns updated doc', async () => {
|
||||
const updated = { _id: 'p-1', notes: 'new note' };
|
||||
mockFindOneAndUpdate.mockResolvedValue(updated);
|
||||
|
||||
const result = await repo.update('p-1', 'hh1', { notes: 'new note' });
|
||||
|
||||
expect(result).toEqual(updated);
|
||||
});
|
||||
|
||||
it('returns null when purchase not found', async () => {
|
||||
mockFindOneAndUpdate.mockResolvedValue(null);
|
||||
|
||||
const result = await repo.update('missing', 'hh1', {});
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it('includes items in update set when provided', async () => {
|
||||
const updated = { _id: 'p-1' };
|
||||
mockFindOneAndUpdate.mockResolvedValue(updated);
|
||||
const { PurchaseModel } = await import('../../../src/schemas/purchase.schema.js');
|
||||
const items = [{ name: 'X', quantity: 1, unit: 'tablet', addedToCabinet: false }];
|
||||
|
||||
await repo.update('p-1', 'hh1', { items } as never);
|
||||
|
||||
expect(PurchaseModel.findOneAndUpdate).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
expect.objectContaining({ $set: expect.objectContaining({ items }) }),
|
||||
expect.anything(),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('receiveAll', () => {
|
||||
it('sets status to in_cabinet and all items addedToCabinet', async () => {
|
||||
const updated = { _id: 'p-1', status: 'in_cabinet' };
|
||||
mockFindOneAndUpdate.mockResolvedValue(updated);
|
||||
const { PurchaseModel } = await import('../../../src/schemas/purchase.schema.js');
|
||||
|
||||
const result = await repo.receiveAll('p-1', 'hh1');
|
||||
|
||||
expect(PurchaseModel.findOneAndUpdate).toHaveBeenCalledWith(
|
||||
{ _id: 'p-1', householdId: 'hh1', isDeleted: false },
|
||||
expect.objectContaining({
|
||||
$set: expect.objectContaining({ status: 'in_cabinet' }),
|
||||
}),
|
||||
expect.anything(),
|
||||
);
|
||||
expect(result).toEqual(updated);
|
||||
});
|
||||
});
|
||||
|
||||
describe('markItemsAddedToCabinet', () => {
|
||||
it('builds per-index update set and calls findOneAndUpdate', async () => {
|
||||
const updated = { _id: 'p-1', items: [] };
|
||||
mockFindOneAndUpdate.mockResolvedValue(updated);
|
||||
const { PurchaseModel } = await import('../../../src/schemas/purchase.schema.js');
|
||||
|
||||
const result = await repo.markItemsAddedToCabinet('p-1', 'hh1', [0, 2]);
|
||||
|
||||
expect(PurchaseModel.findOneAndUpdate).toHaveBeenCalledWith(
|
||||
{ _id: 'p-1', householdId: 'hh1', isDeleted: false },
|
||||
expect.objectContaining({
|
||||
$set: expect.objectContaining({
|
||||
'items.0.addedToCabinet': true,
|
||||
'items.2.addedToCabinet': true,
|
||||
}),
|
||||
}),
|
||||
expect.anything(),
|
||||
);
|
||||
expect(result).toEqual(updated);
|
||||
});
|
||||
});
|
||||
|
||||
describe('softDelete', () => {
|
||||
it('sets isDeleted to true', async () => {
|
||||
mockFindOneAndUpdate.mockResolvedValue({ _id: 'p-1', isDeleted: true });
|
||||
|
||||
const result = await repo.softDelete('p-1', 'hh1');
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPendingMedicineStock', () => {
|
||||
it('returns aggregated stock by medicineId', async () => {
|
||||
const rows = [{ medicineId: 'med-1', totalUnits: 60 }];
|
||||
mockAggregate.mockResolvedValue(rows);
|
||||
|
||||
const result = await repo.getPendingMedicineStock('hh1');
|
||||
|
||||
expect(result).toEqual(rows);
|
||||
});
|
||||
|
||||
it('returns empty array when no pending purchases', async () => {
|
||||
mockAggregate.mockResolvedValue([]);
|
||||
|
||||
const result = await repo.getPendingMedicineStock('hh1');
|
||||
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
471
packages/api/tests/modules/purchases/purchases.routes.test.ts
Normal file
471
packages/api/tests/modules/purchases/purchases.routes.test.ts
Normal file
|
|
@ -0,0 +1,471 @@
|
|||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import Fastify from 'fastify';
|
||||
import { fastifyAwilixPlugin } from '@fastify/awilix';
|
||||
import { serializerCompiler, validatorCompiler } from 'fastify-type-provider-zod';
|
||||
|
||||
vi.mock('jose', () => ({
|
||||
createRemoteJWKSet: vi.fn(() => 'mock-jwks'),
|
||||
jwtVerify: vi.fn().mockResolvedValue({
|
||||
payload: {
|
||||
sub: 'kc-1',
|
||||
email: 'test@example.com',
|
||||
preferred_username: 'testuser',
|
||||
realm_access: { roles: ['member'] },
|
||||
householdIds: ['hh1'],
|
||||
},
|
||||
protectedHeader: { alg: 'RS256' },
|
||||
key: {},
|
||||
}),
|
||||
}));
|
||||
|
||||
const { mockList, mockGetById, mockCreate, mockUpdate, mockReceive, mockDelete } = vi.hoisted(
|
||||
() => ({
|
||||
mockList: vi.fn(),
|
||||
mockGetById: vi.fn(),
|
||||
mockCreate: vi.fn(),
|
||||
mockUpdate: vi.fn(),
|
||||
mockReceive: vi.fn(),
|
||||
mockDelete: vi.fn(),
|
||||
}),
|
||||
);
|
||||
|
||||
vi.mock('../../../src/modules/purchases/purchases.repository.js', () => ({
|
||||
PurchasesRepository: class {
|
||||
create = vi.fn();
|
||||
findByHousehold = vi.fn();
|
||||
findById = vi.fn();
|
||||
update = vi.fn();
|
||||
receiveAll = vi.fn();
|
||||
softDelete = vi.fn();
|
||||
getPendingMedicineStock = vi.fn();
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('../../../src/modules/purchases/purchases.service.js', () => ({
|
||||
PurchasesService: class {
|
||||
list = mockList;
|
||||
getById = mockGetById;
|
||||
create = mockCreate;
|
||||
update = mockUpdate;
|
||||
receive = mockReceive;
|
||||
delete = mockDelete;
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('../../../src/modules/users/users.repository.js', () => ({
|
||||
UsersRepository: class {
|
||||
findByKeycloakId = vi.fn().mockResolvedValue({ householdIds: ['hh1'] });
|
||||
upsertFromToken = vi.fn().mockResolvedValue({ householdIds: ['hh1'] });
|
||||
},
|
||||
}));
|
||||
|
||||
import authPlugin from '../../../src/plugins/auth.plugin.js';
|
||||
import householdPlugin from '../../../src/plugins/household.plugin.js';
|
||||
import usersRoutes from '../../../src/modules/users/users.routes.js';
|
||||
import purchasesRoutes from '../../../src/modules/purchases/purchases.routes.js';
|
||||
|
||||
function makeFakePurchase(overrides = {}) {
|
||||
return {
|
||||
_id: 'p-1',
|
||||
householdId: 'hh1',
|
||||
storeId: 'st-1',
|
||||
storeName: 'CVS',
|
||||
status: 'in_cabinet',
|
||||
items: [
|
||||
{
|
||||
_id: 'item-1',
|
||||
medicineProductId: 'mp-1',
|
||||
medicineId: 'med-1',
|
||||
name: 'Advil',
|
||||
quantity: 30,
|
||||
unit: 'tablet',
|
||||
addedToCabinet: true,
|
||||
},
|
||||
],
|
||||
purchasedAt: '2026-01-15T00:00:00.000Z',
|
||||
createdBy: 'kc-1',
|
||||
createdAt: '2026-01-15T00:00:00.000Z',
|
||||
updatedAt: '2026-01-15T00:00:00.000Z',
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe('purchases.routes', () => {
|
||||
let app: Awaited<ReturnType<typeof buildTestApp>>;
|
||||
|
||||
async function buildTestApp() {
|
||||
const instance = Fastify({ logger: false });
|
||||
instance.setValidatorCompiler(validatorCompiler);
|
||||
instance.setSerializerCompiler(serializerCompiler);
|
||||
await instance.register(fastifyAwilixPlugin, {
|
||||
disposeOnClose: true,
|
||||
disposeOnResponse: true,
|
||||
strictBooleanEnforced: true,
|
||||
});
|
||||
await instance.register(authPlugin);
|
||||
await instance.register(householdPlugin);
|
||||
await instance.register(usersRoutes);
|
||||
await instance.register(purchasesRoutes);
|
||||
await instance.ready();
|
||||
return instance;
|
||||
}
|
||||
|
||||
const authHeaders = { authorization: 'Bearer valid-token' };
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.clearAllMocks();
|
||||
app = await buildTestApp();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
if (app) await app.close();
|
||||
});
|
||||
|
||||
describe('GET /api/v1/households/:householdId/purchases', () => {
|
||||
it('returns paginated purchase list', async () => {
|
||||
mockList.mockResolvedValue({
|
||||
data: [makeFakePurchase()],
|
||||
pagination: { cursor: null, hasMore: false },
|
||||
});
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/api/v1/households/hh1/purchases',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
const body = res.json();
|
||||
expect(body.data).toHaveLength(1);
|
||||
expect(body.data[0].storeName).toBe('CVS');
|
||||
expect(body.pagination.hasMore).toBe(false);
|
||||
});
|
||||
|
||||
it('passes query params to service', async () => {
|
||||
mockList.mockResolvedValue({ data: [], pagination: { cursor: null, hasMore: false } });
|
||||
|
||||
await app.inject({
|
||||
method: 'GET',
|
||||
url: '/api/v1/households/hh1/purchases?status=ordered&limit=10',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(mockList).toHaveBeenCalledWith(
|
||||
'hh1',
|
||||
expect.objectContaining({ status: 'ordered', limit: 10 }),
|
||||
);
|
||||
});
|
||||
|
||||
it('serializes ObjectId _id to string', async () => {
|
||||
mockList.mockResolvedValue({
|
||||
data: [makeFakePurchase({ _id: { toString: () => 'p-obj' } })],
|
||||
pagination: { cursor: null, hasMore: false },
|
||||
});
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/api/v1/households/hh1/purchases',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.json().data[0]._id).toBe('p-obj');
|
||||
});
|
||||
|
||||
it('converts Date objects to ISO strings', async () => {
|
||||
mockList.mockResolvedValue({
|
||||
data: [
|
||||
makeFakePurchase({
|
||||
purchasedAt: new Date('2026-01-15T00:00:00.000Z'),
|
||||
createdAt: new Date('2026-01-15T00:00:00.000Z'),
|
||||
updatedAt: new Date('2026-01-15T00:00:00.000Z'),
|
||||
}),
|
||||
],
|
||||
pagination: { cursor: null, hasMore: false },
|
||||
});
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/api/v1/households/hh1/purchases',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
const item = res.json().data[0];
|
||||
expect(item.purchasedAt).toBe('2026-01-15T00:00:00.000Z');
|
||||
expect(item.createdAt).toBe('2026-01-15T00:00:00.000Z');
|
||||
});
|
||||
|
||||
it('includes optional fields in item response when present', async () => {
|
||||
mockList.mockResolvedValue({
|
||||
data: [
|
||||
makeFakePurchase({
|
||||
notes: 'picked up on the way home',
|
||||
items: [
|
||||
{
|
||||
_id: 'item-1',
|
||||
medicineProductId: 'mp-1',
|
||||
medicineId: 'med-1',
|
||||
name: 'Advil',
|
||||
quantity: 30,
|
||||
unit: 'tablet',
|
||||
actualPrice: 9.99,
|
||||
currency: 'USD',
|
||||
addedToCabinet: true,
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
pagination: { cursor: null, hasMore: false },
|
||||
});
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/api/v1/households/hh1/purchases',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
const item = res.json().data[0].items[0];
|
||||
expect(item.actualPrice).toBe(9.99);
|
||||
expect(item.currency).toBe('USD');
|
||||
expect(res.json().data[0].notes).toBe('picked up on the way home');
|
||||
});
|
||||
|
||||
it('handles item with ObjectId _id and priceRecordId', async () => {
|
||||
mockList.mockResolvedValue({
|
||||
data: [
|
||||
makeFakePurchase({
|
||||
items: [
|
||||
{
|
||||
_id: { toString: () => 'item-obj' },
|
||||
name: 'Advil',
|
||||
quantity: 10,
|
||||
unit: 'tablet',
|
||||
priceRecordId: 'pr-1',
|
||||
addedToCabinet: false,
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
pagination: { cursor: null, hasMore: false },
|
||||
});
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/api/v1/households/hh1/purchases',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
const item = res.json().data[0].items[0];
|
||||
expect(item._id).toBe('item-obj');
|
||||
expect(item.priceRecordId).toBe('pr-1');
|
||||
});
|
||||
|
||||
it('handles item without _id and includes receivedAt on purchase', async () => {
|
||||
mockList.mockResolvedValue({
|
||||
data: [
|
||||
makeFakePurchase({
|
||||
status: 'in_cabinet',
|
||||
receivedAt: '2026-01-20T00:00:00.000Z',
|
||||
items: [
|
||||
{
|
||||
name: 'Generic',
|
||||
quantity: 5,
|
||||
unit: 'tablet',
|
||||
addedToCabinet: true,
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
pagination: { cursor: null, hasMore: false },
|
||||
});
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/api/v1/households/hh1/purchases',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
const purchase = res.json().data[0];
|
||||
expect(purchase.items[0]._id).toBe('');
|
||||
expect(purchase.receivedAt).toBe('2026-01-20T00:00:00.000Z');
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /api/v1/households/:householdId/purchases/:id', () => {
|
||||
it('returns single purchase', async () => {
|
||||
mockGetById.mockResolvedValue(makeFakePurchase());
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/api/v1/households/hh1/purchases/p-1',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.json().storeName).toBe('CVS');
|
||||
});
|
||||
|
||||
it('passes id and householdId to service', async () => {
|
||||
mockGetById.mockResolvedValue(makeFakePurchase());
|
||||
|
||||
await app.inject({
|
||||
method: 'GET',
|
||||
url: '/api/v1/households/hh1/purchases/p-99',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(mockGetById).toHaveBeenCalledWith('p-99', 'hh1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /api/v1/households/:householdId/purchases', () => {
|
||||
const validBody = {
|
||||
storeId: 'st-1',
|
||||
items: [{ name: 'Advil', quantity: 30, unit: 'tablet' }],
|
||||
};
|
||||
|
||||
it('creates purchase and returns 201', async () => {
|
||||
mockCreate.mockResolvedValue(makeFakePurchase());
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/api/v1/households/hh1/purchases',
|
||||
headers: authHeaders,
|
||||
payload: validBody,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(201);
|
||||
expect(res.json().storeName).toBe('CVS');
|
||||
});
|
||||
|
||||
it('passes body, householdId, and userId to service', async () => {
|
||||
mockCreate.mockResolvedValue(makeFakePurchase());
|
||||
|
||||
await app.inject({
|
||||
method: 'POST',
|
||||
url: '/api/v1/households/hh1/purchases',
|
||||
headers: authHeaders,
|
||||
payload: { ...validBody, status: 'ordered' },
|
||||
});
|
||||
|
||||
expect(mockCreate).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ storeId: 'st-1', status: 'ordered' }),
|
||||
'hh1',
|
||||
'kc-1',
|
||||
);
|
||||
});
|
||||
|
||||
it('returns 400 for missing storeId', async () => {
|
||||
const res = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/api/v1/households/hh1/purchases',
|
||||
headers: authHeaders,
|
||||
payload: { items: [{ name: 'X', quantity: 1, unit: 'tablet' }] },
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(400);
|
||||
});
|
||||
|
||||
it('returns 400 for empty items array', async () => {
|
||||
const res = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/api/v1/households/hh1/purchases',
|
||||
headers: authHeaders,
|
||||
payload: { storeId: 'st-1', items: [] },
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(400);
|
||||
});
|
||||
});
|
||||
|
||||
describe('PATCH /api/v1/households/:householdId/purchases/:id', () => {
|
||||
it('updates purchase and returns 200', async () => {
|
||||
mockUpdate.mockResolvedValue(makeFakePurchase({ notes: 'updated note' }));
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'PATCH',
|
||||
url: '/api/v1/households/hh1/purchases/p-1',
|
||||
headers: authHeaders,
|
||||
payload: { notes: 'updated note' },
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.json().notes).toBe('updated note');
|
||||
});
|
||||
|
||||
it('passes id, householdId, and body to service', async () => {
|
||||
mockUpdate.mockResolvedValue(makeFakePurchase());
|
||||
|
||||
await app.inject({
|
||||
method: 'PATCH',
|
||||
url: '/api/v1/households/hh1/purchases/p-1',
|
||||
headers: authHeaders,
|
||||
payload: { notes: 'note' },
|
||||
});
|
||||
|
||||
expect(mockUpdate).toHaveBeenCalledWith(
|
||||
'p-1',
|
||||
'hh1',
|
||||
expect.objectContaining({ notes: 'note' }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /api/v1/households/:householdId/purchases/:id/receive', () => {
|
||||
it('returns addedCount and priceRecordsCreated', async () => {
|
||||
mockReceive.mockResolvedValue({ addedCount: 2, priceRecordsCreated: 1 });
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/api/v1/households/hh1/purchases/p-1/receive',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.json()).toEqual({ addedCount: 2, priceRecordsCreated: 1 });
|
||||
});
|
||||
|
||||
it('passes id, householdId, and userId to service', async () => {
|
||||
mockReceive.mockResolvedValue({ addedCount: 0, priceRecordsCreated: 0 });
|
||||
|
||||
await app.inject({
|
||||
method: 'POST',
|
||||
url: '/api/v1/households/hh1/purchases/p-1/receive',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(mockReceive).toHaveBeenCalledWith('p-1', 'hh1', 'kc-1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('DELETE /api/v1/households/:householdId/purchases/:id', () => {
|
||||
it('deletes purchase and returns 200', async () => {
|
||||
mockDelete.mockResolvedValue(makeFakePurchase());
|
||||
|
||||
const res = await app.inject({
|
||||
method: 'DELETE',
|
||||
url: '/api/v1/households/hh1/purchases/p-1',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.json()._id).toBe('p-1');
|
||||
});
|
||||
|
||||
it('passes id and householdId to service', async () => {
|
||||
mockDelete.mockResolvedValue(makeFakePurchase());
|
||||
|
||||
await app.inject({
|
||||
method: 'DELETE',
|
||||
url: '/api/v1/households/hh1/purchases/p-1',
|
||||
headers: authHeaders,
|
||||
});
|
||||
|
||||
expect(mockDelete).toHaveBeenCalledWith('p-1', 'hh1');
|
||||
});
|
||||
});
|
||||
});
|
||||
432
packages/api/tests/modules/purchases/purchases.service.test.ts
Normal file
432
packages/api/tests/modules/purchases/purchases.service.test.ts
Normal file
|
|
@ -0,0 +1,432 @@
|
|||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { PurchasesService } from '../../../src/modules/purchases/purchases.service.js';
|
||||
|
||||
describe(PurchasesService.name, () => {
|
||||
const mockPurchasesRepo = {
|
||||
create: vi.fn(),
|
||||
findByHousehold: vi.fn(),
|
||||
findById: vi.fn(),
|
||||
update: vi.fn(),
|
||||
receiveAll: vi.fn(),
|
||||
softDelete: vi.fn(),
|
||||
getPendingMedicineStock: vi.fn(),
|
||||
};
|
||||
const mockCabinetService = {
|
||||
addItem: vi.fn(),
|
||||
};
|
||||
const mockStoresRepo = {
|
||||
findById: vi.fn(),
|
||||
};
|
||||
const mockProductsRepo = {
|
||||
findById: vi.fn(),
|
||||
};
|
||||
const mockPricesRepo = {
|
||||
create: vi.fn(),
|
||||
};
|
||||
|
||||
let service: PurchasesService;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
service = new PurchasesService({
|
||||
purchasesRepository: mockPurchasesRepo as never,
|
||||
cabinetService: mockCabinetService as never,
|
||||
storesRepository: mockStoresRepo as never,
|
||||
medicineProductsRepository: mockProductsRepo as never,
|
||||
medicinePricesRepository: mockPricesRepo as never,
|
||||
});
|
||||
});
|
||||
|
||||
const fakeStore = { _id: 'st-1', name: 'CVS' };
|
||||
const fakeProduct = {
|
||||
_id: 'mp-1',
|
||||
medicineId: 'med-1',
|
||||
medicineName: 'Ibuprofen',
|
||||
brand: 'Advil',
|
||||
};
|
||||
|
||||
describe('create', () => {
|
||||
const validInput = {
|
||||
storeId: 'st-1',
|
||||
status: 'in_cabinet' as const,
|
||||
items: [{ name: 'Advil', quantity: 30, unit: 'tablet', medicineProductId: 'mp-1' }],
|
||||
};
|
||||
|
||||
it('throws NotFoundError when store not found', async () => {
|
||||
mockStoresRepo.findById.mockResolvedValue(null);
|
||||
|
||||
await expect(service.create(validInput, 'hh1', 'user-1')).rejects.toThrow('Store not found');
|
||||
});
|
||||
|
||||
it('throws NotFoundError when medicine product not found', async () => {
|
||||
mockStoresRepo.findById.mockResolvedValue(fakeStore);
|
||||
mockProductsRepo.findById.mockResolvedValue(null);
|
||||
|
||||
await expect(service.create(validInput, 'hh1', 'user-1')).rejects.toThrow(
|
||||
'Medicine product not found: mp-1',
|
||||
);
|
||||
});
|
||||
|
||||
it('creates purchase with in_cabinet status and adds items to cabinet', async () => {
|
||||
mockStoresRepo.findById.mockResolvedValue(fakeStore);
|
||||
mockProductsRepo.findById.mockResolvedValue(fakeProduct);
|
||||
mockCabinetService.addItem.mockResolvedValue({});
|
||||
const purchase = { _id: 'p-1', status: 'in_cabinet' };
|
||||
mockPurchasesRepo.create.mockResolvedValue(purchase);
|
||||
|
||||
const result = await service.create(validInput, 'hh1', 'user-1');
|
||||
|
||||
expect(mockCabinetService.addItem).toHaveBeenCalledOnce();
|
||||
expect(mockPurchasesRepo.create).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ status: 'in_cabinet', storeName: 'CVS' }),
|
||||
);
|
||||
expect(result).toEqual(purchase);
|
||||
});
|
||||
|
||||
it('records price when actualPrice is set and status is in_cabinet', async () => {
|
||||
const inputWithPrice = {
|
||||
...validInput,
|
||||
items: [{ ...validInput.items[0], actualPrice: 9.99, currency: 'USD' }],
|
||||
};
|
||||
mockStoresRepo.findById.mockResolvedValue(fakeStore);
|
||||
mockProductsRepo.findById.mockResolvedValue(fakeProduct);
|
||||
mockCabinetService.addItem.mockResolvedValue({});
|
||||
mockPricesRepo.create.mockResolvedValue({});
|
||||
mockPurchasesRepo.create.mockResolvedValue({ _id: 'p-1' });
|
||||
|
||||
await service.create(inputWithPrice, 'hh1', 'user-1');
|
||||
|
||||
expect(mockPricesRepo.create).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
price: 9.99,
|
||||
medicineName: 'Ibuprofen',
|
||||
storeName: 'CVS',
|
||||
pricePerUnit: expect.closeTo(0.333, 2),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('does not add to cabinet when status is ordered', async () => {
|
||||
const orderedInput = { ...validInput, status: 'ordered' as const };
|
||||
mockStoresRepo.findById.mockResolvedValue(fakeStore);
|
||||
mockProductsRepo.findById.mockResolvedValue(fakeProduct);
|
||||
mockPurchasesRepo.create.mockResolvedValue({ _id: 'p-1', status: 'ordered' });
|
||||
|
||||
await service.create(orderedInput, 'hh1', 'user-1');
|
||||
|
||||
expect(mockCabinetService.addItem).not.toHaveBeenCalled();
|
||||
expect(mockPricesRepo.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('handles item without medicineProductId for in_cabinet', async () => {
|
||||
const noProductInput = {
|
||||
storeId: 'st-1',
|
||||
status: 'in_cabinet' as const,
|
||||
items: [{ name: 'Generic OTC', quantity: 1, unit: 'tablet' }],
|
||||
};
|
||||
mockStoresRepo.findById.mockResolvedValue(fakeStore);
|
||||
mockPurchasesRepo.create.mockResolvedValue({ _id: 'p-1' });
|
||||
|
||||
await service.create(noProductInput, 'hh1', 'user-1');
|
||||
|
||||
expect(mockCabinetService.addItem).not.toHaveBeenCalled();
|
||||
expect(mockPurchasesRepo.create).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('uses purchasedAt from input when provided', async () => {
|
||||
const inputWithDate = { ...validInput, purchasedAt: '2026-01-15T00:00:00.000Z' };
|
||||
mockStoresRepo.findById.mockResolvedValue(fakeStore);
|
||||
mockProductsRepo.findById.mockResolvedValue(fakeProduct);
|
||||
mockCabinetService.addItem.mockResolvedValue({});
|
||||
mockPurchasesRepo.create.mockResolvedValue({ _id: 'p-1' });
|
||||
|
||||
await service.create(inputWithDate, 'hh1', 'user-1');
|
||||
|
||||
expect(mockPurchasesRepo.create).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ purchasedAt: new Date('2026-01-15T00:00:00.000Z') }),
|
||||
);
|
||||
});
|
||||
|
||||
it('uses medicineName as brand fallback when brand is undefined', async () => {
|
||||
mockStoresRepo.findById.mockResolvedValue(fakeStore);
|
||||
mockProductsRepo.findById.mockResolvedValue({ ...fakeProduct, brand: undefined });
|
||||
mockCabinetService.addItem.mockResolvedValue({});
|
||||
mockPricesRepo.create.mockResolvedValue({});
|
||||
const inputWithPrice = {
|
||||
...validInput,
|
||||
items: [{ ...validInput.items[0], actualPrice: 5 }],
|
||||
};
|
||||
mockPurchasesRepo.create.mockResolvedValue({ _id: 'p-1' });
|
||||
|
||||
await service.create(inputWithPrice, 'hh1', 'user-1');
|
||||
|
||||
expect(mockPricesRepo.create).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ medicineProductBrand: 'Ibuprofen' }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('receive', () => {
|
||||
it('throws NotFoundError when purchase not found', async () => {
|
||||
mockPurchasesRepo.findById.mockResolvedValue(null);
|
||||
|
||||
await expect(service.receive('missing', 'hh1', 'user-1')).rejects.toThrow(
|
||||
'Purchase not found',
|
||||
);
|
||||
});
|
||||
|
||||
it('throws BadRequestError when status is not ordered', async () => {
|
||||
mockPurchasesRepo.findById.mockResolvedValue({ _id: 'p-1', status: 'in_cabinet', items: [] });
|
||||
|
||||
await expect(service.receive('p-1', 'hh1', 'user-1')).rejects.toThrow(
|
||||
'Purchase is not in ordered status',
|
||||
);
|
||||
});
|
||||
|
||||
it('adds medicine items to cabinet and calls receiveAll', async () => {
|
||||
const purchase = {
|
||||
_id: 'p-1',
|
||||
status: 'ordered',
|
||||
storeId: 'st-1',
|
||||
storeName: 'CVS',
|
||||
purchasedAt: new Date('2026-01-01T00:00:00.000Z'),
|
||||
items: [
|
||||
{
|
||||
medicineProductId: 'mp-1',
|
||||
medicineId: 'med-1',
|
||||
name: 'Advil',
|
||||
quantity: 30,
|
||||
unit: 'tablet',
|
||||
addedToCabinet: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
mockPurchasesRepo.findById.mockResolvedValue(purchase);
|
||||
mockCabinetService.addItem.mockResolvedValue({});
|
||||
mockPurchasesRepo.receiveAll.mockResolvedValue({ _id: 'p-1', status: 'in_cabinet' });
|
||||
|
||||
const result = await service.receive('p-1', 'hh1', 'user-1');
|
||||
|
||||
expect(mockCabinetService.addItem).toHaveBeenCalledOnce();
|
||||
expect(mockPurchasesRepo.receiveAll).toHaveBeenCalledWith('p-1', 'hh1');
|
||||
expect(result.addedCount).toBe(1);
|
||||
expect(result.priceRecordsCreated).toBe(0);
|
||||
});
|
||||
|
||||
it('creates price record when actualPrice is set on item', async () => {
|
||||
const purchase = {
|
||||
_id: 'p-1',
|
||||
status: 'ordered',
|
||||
storeId: 'st-1',
|
||||
storeName: 'CVS',
|
||||
purchasedAt: new Date('2026-01-01T00:00:00.000Z'),
|
||||
items: [
|
||||
{
|
||||
medicineProductId: 'mp-1',
|
||||
medicineId: 'med-1',
|
||||
name: 'Advil',
|
||||
quantity: 30,
|
||||
unit: 'tablet',
|
||||
actualPrice: 9.99,
|
||||
currency: 'USD',
|
||||
addedToCabinet: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
mockPurchasesRepo.findById.mockResolvedValue(purchase);
|
||||
mockCabinetService.addItem.mockResolvedValue({});
|
||||
mockProductsRepo.findById.mockResolvedValue(fakeProduct);
|
||||
mockPricesRepo.create.mockResolvedValue({});
|
||||
mockPurchasesRepo.receiveAll.mockResolvedValue({});
|
||||
|
||||
const result = await service.receive('p-1', 'hh1', 'user-1');
|
||||
|
||||
expect(mockPricesRepo.create).toHaveBeenCalledOnce();
|
||||
expect(result.priceRecordsCreated).toBe(1);
|
||||
});
|
||||
|
||||
it('uses medicineName as brand fallback in price record when brand is undefined', async () => {
|
||||
const purchase = {
|
||||
_id: 'p-1',
|
||||
status: 'ordered',
|
||||
storeId: 'st-1',
|
||||
storeName: 'CVS',
|
||||
purchasedAt: new Date('2026-01-01T00:00:00.000Z'),
|
||||
items: [
|
||||
{
|
||||
medicineProductId: 'mp-1',
|
||||
medicineId: 'med-1',
|
||||
name: 'Ibuprofen',
|
||||
quantity: 30,
|
||||
unit: 'tablet',
|
||||
actualPrice: 9.99,
|
||||
currency: 'USD',
|
||||
addedToCabinet: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
mockPurchasesRepo.findById.mockResolvedValue(purchase);
|
||||
mockCabinetService.addItem.mockResolvedValue({});
|
||||
mockProductsRepo.findById.mockResolvedValue({ ...fakeProduct, brand: undefined });
|
||||
mockPricesRepo.create.mockResolvedValue({});
|
||||
mockPurchasesRepo.receiveAll.mockResolvedValue({});
|
||||
|
||||
await service.receive('p-1', 'hh1', 'user-1');
|
||||
|
||||
expect(mockPricesRepo.create).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ medicineProductBrand: 'Ibuprofen' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('skips price record creation when product not found in receive', async () => {
|
||||
const purchase = {
|
||||
_id: 'p-1',
|
||||
status: 'ordered',
|
||||
storeId: 'st-1',
|
||||
storeName: 'CVS',
|
||||
purchasedAt: new Date(),
|
||||
items: [
|
||||
{
|
||||
medicineProductId: 'mp-1',
|
||||
medicineId: 'med-1',
|
||||
name: 'Advil',
|
||||
quantity: 30,
|
||||
unit: 'tablet',
|
||||
actualPrice: 9.99,
|
||||
addedToCabinet: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
mockPurchasesRepo.findById.mockResolvedValue(purchase);
|
||||
mockCabinetService.addItem.mockResolvedValue({});
|
||||
mockProductsRepo.findById.mockResolvedValue(null);
|
||||
mockPurchasesRepo.receiveAll.mockResolvedValue({});
|
||||
|
||||
const result = await service.receive('p-1', 'hh1', 'user-1');
|
||||
|
||||
expect(mockPricesRepo.create).not.toHaveBeenCalled();
|
||||
expect(result.priceRecordsCreated).toBe(0);
|
||||
});
|
||||
|
||||
it('skips items already added to cabinet', async () => {
|
||||
const purchase = {
|
||||
_id: 'p-1',
|
||||
status: 'ordered',
|
||||
storeId: 'st-1',
|
||||
storeName: 'CVS',
|
||||
purchasedAt: new Date(),
|
||||
items: [
|
||||
{
|
||||
medicineProductId: 'mp-1',
|
||||
medicineId: 'med-1',
|
||||
name: 'X',
|
||||
quantity: 10,
|
||||
unit: 'tablet',
|
||||
addedToCabinet: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
mockPurchasesRepo.findById.mockResolvedValue(purchase);
|
||||
mockPurchasesRepo.receiveAll.mockResolvedValue({});
|
||||
|
||||
const result = await service.receive('p-1', 'hh1', 'user-1');
|
||||
|
||||
expect(mockCabinetService.addItem).not.toHaveBeenCalled();
|
||||
expect(result.addedCount).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('list', () => {
|
||||
it('delegates to repository', async () => {
|
||||
const result = { data: [], pagination: { cursor: null, hasMore: false } };
|
||||
mockPurchasesRepo.findByHousehold.mockResolvedValue(result);
|
||||
|
||||
const response = await service.list('hh1', { limit: 20 });
|
||||
|
||||
expect(response).toEqual(result);
|
||||
expect(mockPurchasesRepo.findByHousehold).toHaveBeenCalledWith('hh1', { limit: 20 });
|
||||
});
|
||||
});
|
||||
|
||||
describe('getById', () => {
|
||||
it('returns purchase when found', async () => {
|
||||
const purchase = { _id: 'p-1', status: 'in_cabinet' };
|
||||
mockPurchasesRepo.findById.mockResolvedValue(purchase);
|
||||
|
||||
expect(await service.getById('p-1', 'hh1')).toEqual(purchase);
|
||||
});
|
||||
|
||||
it('throws NotFoundError when not found', async () => {
|
||||
mockPurchasesRepo.findById.mockResolvedValue(null);
|
||||
|
||||
await expect(service.getById('missing', 'hh1')).rejects.toThrow('Purchase not found');
|
||||
});
|
||||
});
|
||||
|
||||
describe('update', () => {
|
||||
it('updates and returns purchase', async () => {
|
||||
mockPurchasesRepo.findById.mockResolvedValue({ _id: 'p-1' });
|
||||
const updated = { _id: 'p-1', notes: 'updated' };
|
||||
mockPurchasesRepo.update.mockResolvedValue(updated);
|
||||
|
||||
const result = await service.update('p-1', 'hh1', { notes: 'updated' });
|
||||
|
||||
expect(result).toEqual(updated);
|
||||
});
|
||||
|
||||
it('throws NotFoundError when purchase does not exist', async () => {
|
||||
mockPurchasesRepo.findById.mockResolvedValue(null);
|
||||
|
||||
await expect(service.update('missing', 'hh1', {})).rejects.toThrow('Purchase not found');
|
||||
});
|
||||
|
||||
it('throws NotFoundError when update returns null', async () => {
|
||||
mockPurchasesRepo.findById.mockResolvedValue({ _id: 'p-1' });
|
||||
mockPurchasesRepo.update.mockResolvedValue(null);
|
||||
|
||||
await expect(service.update('p-1', 'hh1', {})).rejects.toThrow('Purchase not found');
|
||||
});
|
||||
});
|
||||
|
||||
describe('delete', () => {
|
||||
it('soft-deletes and returns purchase', async () => {
|
||||
const deleted = { _id: 'p-1', isDeleted: true };
|
||||
mockPurchasesRepo.softDelete.mockResolvedValue(deleted);
|
||||
|
||||
const result = await service.delete('p-1', 'hh1');
|
||||
|
||||
expect(result).toEqual(deleted);
|
||||
expect(mockPurchasesRepo.softDelete).toHaveBeenCalledWith('p-1', 'hh1');
|
||||
});
|
||||
|
||||
it('throws NotFoundError when purchase not found', async () => {
|
||||
mockPurchasesRepo.softDelete.mockResolvedValue(null);
|
||||
|
||||
await expect(service.delete('missing', 'hh1')).rejects.toThrow(
|
||||
'Purchase not found or cannot be deleted',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPendingStockByMedicine', () => {
|
||||
it('returns map of medicineId to totalUnits', async () => {
|
||||
mockPurchasesRepo.getPendingMedicineStock.mockResolvedValue([
|
||||
{ medicineId: 'med-1', totalUnits: 60 },
|
||||
{ medicineId: 'med-2', totalUnits: 30 },
|
||||
]);
|
||||
|
||||
const result = await service.getPendingStockByMedicine('hh1');
|
||||
|
||||
expect(result.get('med-1')).toBe(60);
|
||||
expect(result.get('med-2')).toBe(30);
|
||||
});
|
||||
|
||||
it('returns empty map when no pending stock', async () => {
|
||||
mockPurchasesRepo.getPendingMedicineStock.mockResolvedValue([]);
|
||||
|
||||
const result = await service.getPendingStockByMedicine('hh1');
|
||||
|
||||
expect(result.size).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue