Add jest coverage + Test setFruits mutation
This commit is contained in:
36
tests/unit/mutations.spec.js
Normal file
36
tests/unit/mutations.spec.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import mutations from "@/store/mutations.js";
|
||||
|
||||
describe("Test Vuex mutations.", () => {
|
||||
it("should add fruits to the state", () => {
|
||||
const fruits = [
|
||||
{
|
||||
id: 3,
|
||||
isFruit: true,
|
||||
name: "banana",
|
||||
image: "/image/path.jpg",
|
||||
price: "907.00",
|
||||
color: "#763e44",
|
||||
description: "Iusto illum vero voluptatem.",
|
||||
taste: "Handcrafted",
|
||||
expires: "2021-04-11T08:54:24.588Z"
|
||||
}
|
||||
];
|
||||
const state = {
|
||||
fruits: []
|
||||
};
|
||||
mutations.setFruits(state, fruits);
|
||||
expect(state.fruits).toEqual([
|
||||
{
|
||||
id: 3,
|
||||
isFruit: true,
|
||||
name: "banana",
|
||||
image: "/image/path.jpg",
|
||||
price: "907.00",
|
||||
color: "#763e44",
|
||||
description: "Iusto illum vero voluptatem.",
|
||||
taste: "Handcrafted",
|
||||
expires: "2021-04-11T08:54:24.588Z"
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user