WL-31 - Pass title as props on Hero component

This commit is contained in:
2020-11-03 19:15:07 +01:00
parent 45230db737
commit 45bbcaaac5
3 changed files with 88 additions and 3 deletions

27
test/Hero.spec.js Normal file
View File

@@ -0,0 +1,27 @@
import { mount } from "@vue/test-utils";
import Hero from "@/components/Hero.vue";
describe("Hero", () => {
const factory = propsData => {
return mount(Hero, {
propsData: {
...propsData
}
});
};
it("throw an error when no title", () => {
expect(() => {
factory()
.find("h1")
.toThrow("Missing required prop: 'title'");
});
});
it("should have a title", () => {
const wrapper = factory({
title: "Hero"
});
expect(wrapper.find("h1").text()).toContain("Hero");
});
});