Create Vehicle component + tests

This commit is contained in:
2020-12-21 22:36:16 +01:00
parent 21f3ed77a4
commit cf9381309e
6 changed files with 115 additions and 8 deletions

View File

@@ -0,0 +1,30 @@
import { mount, RouterLinkStub } from "@vue/test-utils";
import Vehicle from "./";
import mockVehicles from "@/test/fake-vehicles.json";
describe("Vehicle", () => {
it("tests props", () => {
expect(Vehicle.props).toMatchObject({
vehicle: {
type: Object,
default: {},
required: true
}
});
});
it("renders proper link to details", () => {
const wrapper = mount(Vehicle, {
propsData: {
vehicle: mockVehicles[0]
},
stubs: {
RouterLink: RouterLinkStub
}
});
expect(wrapper.findComponent(RouterLinkStub).props().to).toBe(
`/vehicles/${mockVehicles[0].id}`
);
});
});