diff --git a/assets/images/noe.png b/assets/images/noe.png
new file mode 100644
index 0000000..fcea186
Binary files /dev/null and b/assets/images/noe.png differ
diff --git a/components/Hero.vue b/components/Hero.vue
index 03c4387..046b8de 100644
--- a/components/Hero.vue
+++ b/components/Hero.vue
@@ -5,7 +5,6 @@
-
-
+
{{ title }}
-
-
@@ -63,29 +51,39 @@ export default {
props: {
title: {
type: String,
- required: true
+ required: true,
+ validator: string => {
+ return string.length && string.length <= 15;
+ }
+ },
+ avatar: {
+ type: Object,
+ default: () => {
+ return {
+ src: "noe.png",
+ alt: "Noé Viricel"
+ };
+ }
+ },
+ actions: {
+ type: [Array, Object],
+ validator: function(o) {
+ if (o.length <= 5) {
+ if (o.length) {
+ for (let index = 0; index < o.length; index++) {
+ return (
+ o[index].hasOwnProperty("title") &&
+ o[index].hasOwnProperty("url") &&
+ o[index].hasOwnProperty("target") &&
+ o[index].hasOwnProperty("rel")
+ );
+ }
+ }
+ }
+
+ return false;
+ }
}
- // links: {
- // type: [Array, Object],
- // default: () => {
- // return {
- // title: "",
- // url: "",
- // target: "",
- // rel: ""
- // };
- // },
- // validator: () => {
- // const skeleton = [
- // {
- // title: "",
- // url: "",
- // target: "",
- // rel: ""
- // }
- // ];
- // }
- // }
}
};
@@ -94,7 +92,4 @@ export default {
.hero {
height: 460px;
}
-
-/* #brand-member {
-} */
diff --git a/pages/index.vue b/pages/index.vue
index fa4ce30..17c250c 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -1,7 +1,7 @@
-
+
@@ -13,7 +13,21 @@ import projects from "@/content/projects.json";
export default {
data() {
return {
- projects: projects
+ projects: projects,
+ heroActions: [
+ {
+ title: "Projects",
+ url: "#projects",
+ target: "_self",
+ rel: "noopen noreferrer"
+ },
+ {
+ title: "Contact",
+ url: "#contact",
+ target: "_self",
+ rel: "noopen noreferrer"
+ }
+ ]
};
}
};
diff --git a/test/Header.spec.js b/test/Header.spec.js
new file mode 100644
index 0000000..b30811d
--- /dev/null
+++ b/test/Header.spec.js
@@ -0,0 +1,13 @@
+import { mount } from "@vue/test-utils";
+import Header from "@/components/Header.vue";
+
+describe("Header", () => {
+ it("should display proper social networks", () => {
+ const wrapper = mount(Header);
+ const divs = wrapper.findAll("a");
+ expect(divs.at(0).attributes("href")).toBe("https://github.com/wazolab");
+ expect(divs.at(1).attributes("href")).toBe(
+ "https://www.linkedin.com/in/no%C3%A9-v-395bba109"
+ );
+ });
+});
diff --git a/test/Hero.spec.js b/test/Hero.spec.js
index 6417f99..0a37d25 100644
--- a/test/Hero.spec.js
+++ b/test/Hero.spec.js
@@ -2,26 +2,84 @@ import { mount } from "@vue/test-utils";
import Hero from "@/components/Hero.vue";
describe("Hero", () => {
- const factory = propsData => {
- return mount(Hero, {
- propsData: {
- ...propsData
+ test("props validation.", () => {
+ expect(Hero.props).toMatchObject({
+ title: {
+ type: String,
+ required: true
+ },
+ avatar: {
+ type: Object
+ },
+ actions: {
+ type: [Array, Object]
}
});
- };
- it("throw an error when no title", () => {
- expect(() => {
- factory()
- .find("h1")
- .toThrow("Missing required prop: 'title'");
- });
+ // Title
+ expect(Hero.props.title.validator("Hero")).toBe(true);
+ expect(Hero.props.title.validator("Herooooooooooooo")).toBe(false);
+
+ // Avatar
+ expect(Hero.props.avatar.type).toBe(Object);
+
+ // Actions
+ expect(Hero.props.actions.validator([{}])).toBe(false);
+ expect(Hero.props.actions.validator([{}, {}, {}, {}, {}, {}])).toBe(false);
+ expect(
+ Hero.props.actions.validator([
+ {
+ title: "Projects",
+ target: "_self",
+ rel: "noopen noreferrer",
+ type: "freelance"
+ }
+ ])
+ ).toBe(false);
+ expect(
+ Hero.props.actions.validator([
+ {
+ title: "Projects",
+ url: "#projects",
+ target: "_self",
+ rel: "noopen noreferrer"
+ }
+ ])
+ ).toBe(true);
});
- it("should have a title", () => {
- const wrapper = factory({
- title: "Hero"
+ test("props binding.", async () => {
+ const wrapper = mount(Hero, {
+ propsData: {
+ title: "Hero"
+ }
});
expect(wrapper.find("h1").text()).toContain("Hero");
+
+ // Actions
+ let actions = wrapper.findAll(".hero-actions a");
+ expect(actions.length).toBe(0);
+
+ await wrapper.setProps({
+ actions: [
+ {
+ title: "Projects",
+ url: "#projects",
+ target: "_self",
+ rel: "noopen noreferrer"
+ },
+ {
+ title: "Contact",
+ url: "#contact",
+ target: "_self",
+ rel: "noopen noreferrer"
+ }
+ ]
+ });
+
+ actions = wrapper.findAll(".hero-actions a");
+
+ expect(actions.length).toBe(2);
+ expect(actions.at(1).text()).toBe("Contact");
});
});