import { Product, ProductStore } from '../../models/product' const store = new ProductStore() const testProduct: Product = { id: 1, name: '1984', price: 5, } const updatedProduct: Product = { id: 1, name: 'The Dark Tower', price: 7 } describe("Product model", () => { it('Should have an index method', () => { expect(store.index).toBeDefined(); }); it('Should have a read method', () => { expect(store.read).toBeDefined; }); it('Should have a create method', () => { expect(store.create).toBeDefined; }); it('Should have a update method', () => { expect(store.update).toBeDefined; }); it('Should have a delete method', () => { expect(store.delete).toBeDefined; }); it('Create method should add a product', async () => { const result = await store.create(testProduct); expect(result).toEqual(testProduct); }); it('Index method should return a list of products', async () => { const result = await store.index(); expect(result).toEqual([testProduct]); }); it('Read method should return a product', async () => { const result = await store.read(1); expect(result).toEqual(testProduct); }); it('Update method should update a product', async () => { const result = await store.update(updatedProduct); expect(result).toEqual({ id: 1, name: 'The Dark Tower', price: 7, }); }); it('Delete method should remove the product', async () => { store.delete(1); const result = await store.index() expect(result).toEqual([]); }); });