You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.7 KiB
TypeScript

import { Product, ProductStore } from '../product'
const store = new ProductStore()
describe("Book store Model", () => {
it('should have an index method', () => {
expect(store.index).toBeDefined();
});
it('index menthod should return a list of products', async () => {
const result = await store.index();
expect(result).toEqual([]);
});
it('should have a create method', () => {
expect(store.index).toBeDefined;
});
it('should have a update method', () => {
expect(store.index).toBeDefined;
});
it('create method should add a product', async () => {
const result = await store.create({
title: '1984',
author: 'George Orwell',
pages: 42,
price: 10
});
expect(result).toEqual({
id: "1",
title: '1984',
author: 'George Orwell',
pages: 42,
price: 10
});
});
it('index method should return a list of products', async () => {
const result = await store.index();
expect(result).toEqual([{
id: "1",
title: '1984',
author: 'George Orwell',
pages: 42,
price: 10
}]);
});
it('show method should return a product', async () => {
const result = await store.show("1");
expect(result).toEqual({
id: "1",
title: '1984',
author: 'George Orwell',
pages: 42,
price: 10
});
});
it('delete method should remove the product', async () => {
store.delete("1");
const result = await store.index()
expect(result).toEqual([]);
});
});