У меня есть тип данных:
export type Product = {
id?: number;
name: string;
price: number;
category?: string;
};
Это SQL для таблицы:
CREATE TABLE products (id SERIAL PRIMARY KEY, name VARCHAR(50), price DECIMAL, category VARCHAR(50));
Я пишу тест:
describe('Product Model', () => {
it('create method should add a product', async () => {
const result = await store.create({
id: 1,
name: 'War and Peace',
price: 250.25,
category: 'Literature',
});
expect(result).toEqual({
id: 1,
name: 'War and Peace',
price: 250.25,
category: 'Literature',
});
});
});
Этот тест не пройден и получена ошибка:
Randomized with seed 12883
Started
...........F....
Failures:
1) Product Model create method should add a product
Message:
Expected $.price = '250.25' to equal 250.25.
Stack:
Expected $.price = '250.25' to equal 250.25.
Поскольку цена составляет number
, почему тест не пройден и как мне это исправить?