Create Vehicle component + tests
This commit is contained in:
30
components/Vehicle/Vehicle.spec.js
Normal file
30
components/Vehicle/Vehicle.spec.js
Normal 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}`
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user