19 Commits

Author SHA1 Message Date
c77fe19ed1 Add description in Header + Change title 2020-12-18 02:27:15 +01:00
0b7b64231d Replace films page H2 by Studio Ghibli logo 2020-12-18 02:18:01 +01:00
5de7b3d676 Refactor Footer module + Add basic tesst file 2020-12-18 02:07:15 +01:00
cde972e20e Refactor Header module 2020-12-18 02:03:04 +01:00
e1827b3b7d Refactor Grid module 2020-12-18 02:00:39 +01:00
444d3f8326 Test Film component 2020-12-18 01:47:06 +01:00
c08b0575dc Create Film component 2020-12-18 01:31:09 +01:00
62862e6c14 Add Tailwind Typography plugin 2020-12-18 01:22:17 +01:00
bca6a2ed11 Create Grid component + Test. Index test adaptations 2020-12-17 19:31:25 +01:00
e2051c8d74 Add head property 2020-12-17 18:31:55 +01:00
407ef3dcd1 Improve Page structure and create a redirect middleware to set /films as homepage 2020-12-17 18:28:32 +01:00
467eb68e25 Add styles to H2 2020-12-17 18:17:12 +01:00
7935ae750f Create Footer component with styles 2020-12-17 18:15:40 +01:00
eac90cffd6 Merge branch 'films-page' into develop 2020-12-17 17:16:42 +01:00
e8cc9c89ba Add proper styles to handle Header's fixed position and main tag to display correctly. 2020-12-17 17:15:16 +01:00
7b52deccd8 Test asyncData method. 2020-12-17 17:07:22 +01:00
1a86713c00 Collect films data in AsyncData method. 2020-12-17 14:29:26 +01:00
ea89471cc0 Header tests. 2020-12-17 12:53:19 +01:00
050942c679 Add styles to Header component 2020-12-17 12:43:50 +01:00
20 changed files with 852 additions and 46 deletions

BIN
assets/images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -0,0 +1,56 @@
<svg
width="80px"
height="80px"
viewBox="0 0 80 80"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
<!-- Generator: Sketch 59.1 (86144) - https://sketch.com -->
<title>Icons/Tomatometer &amp; AS/fresh</title>
<desc>Created with Sketch.</desc>
<defs>
<polygon
id="path-1"
points="0.000109100102 0.246970954 77.0827837 0.246970954 77.0827837 63.7145228 0.000109100102 63.7145228"
/>
</defs>
<g
id="Icons/Tomatometer-&amp;-AS/fresh"
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd"
>
<g id="Group">
<rect
id="Rectangle-Copy-2"
fill="#000000"
opacity="0"
x="0"
y="0"
width="80"
height="80"
/>
<g id="RT_Fresh_Tomato_RGB-(1)" transform="translate(1.327801, 0.000000)">
<g id="Group-3" transform="translate(0.000000, 16.265560)">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1" />
</mask>
<g id="Clip-2" />
<path
d="M77.0137759,27.0426556 C76.2423237,14.6741909 69.9521992,5.42041494 60.4876349,0.246970954 C60.5414108,0.548381743 60.273195,0.925145228 59.9678008,0.791701245 C53.7772614,-1.91634855 43.2753527,6.84780083 35.9365975,2.25825726 C35.9917012,3.90539419 35.6700415,11.940249 24.3515353,12.4063071 C24.0843154,12.4172614 23.9372614,12.1443983 24.1062241,11.9512033 C25.619917,10.2247303 27.1482158,5.85360996 24.9507054,3.5233195 C20.2446473,7.74041494 17.5117012,9.32746888 8.48829876,7.23319502 C2.71103734,13.2740249 -0.562655602,21.5419087 0.08,31.8413278 C1.39120332,52.86639 21.0848133,64.8846473 40.9165145,63.6471369 C60.746888,62.4106224 78.3253112,48.0677178 77.0137759,27.0426556"
id="Fill-1"
fill="#FA320A"
mask="url(#mask-2)"
/>
</g>
<path
d="M40.8717012,11.4648963 C44.946722,10.49361 56.6678838,11.3702905 60.4232365,16.3518672 C60.6486307,16.6506224 60.3312863,17.2159336 59.9678008,17.0572614 C53.7772614,14.3492116 43.2753527,23.113361 35.9365975,18.5238174 C35.9917012,20.1709544 35.6700415,28.2058091 24.3515353,28.6718672 C24.0843154,28.6828216 23.9372614,28.4099585 24.1062241,28.2167635 C25.619917,26.4902905 27.1478838,22.1191701 24.9507054,19.7888797 C19.8243983,24.3827386 17.0453112,25.8589212 5.91900415,22.8514523 C5.55485477,22.753195 5.67900415,22.1679668 6.06639004,22.020249 C8.16929461,21.2165975 12.933444,17.6965975 17.4406639,16.1450622 C18.2987552,15.8499585 19.1541909,15.6209129 19.9890456,15.4878008 C15.02639,15.0443154 12.7893776,14.3541909 9.63286307,14.8302075 C9.28697095,14.8823237 9.05195021,14.479668 9.26639004,14.2034855 C13.5193361,8.7253112 21.3540249,7.07087137 26.1878838,9.98107884 C23.2082988,6.28912863 20.8743568,3.34473029 20.8743568,3.34473029 L26.4046473,0.203485477 C26.4046473,0.203485477 28.6894606,5.30821577 30.3518672,9.02340249 C34.4657261,2.94506224 42.119834,2.38406639 45.3536929,6.69676349 C45.5455602,6.95302905 45.3450622,7.31751037 45.0247303,7.30987552 C42.3926971,7.24580913 40.9434025,9.63983402 40.833527,11.4605809 L40.8717012,11.4648963"
id="Fill-4"
fill="#00912D"
/>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

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

95
components/Film/index.vue Normal file
View File

@@ -0,0 +1,95 @@
<template>
<article
class="film bg-gray-100 prose prose-sm rounded-md shadow-md transition-shadow duration-300 hover:shadow-xl mb-4 sm:m-4"
>
<header class="p-4 rounded-t-md">
<h1>
{{ film.title + " (" + film.release_date + ")" }}
</h1>
<h2 class="text-gray-700 mt-0">{{ "by " + film.director }}</h2>
</header>
<main class="inline-block px-4">
<h3>Summary</h3>
<p>{{ excerptOfDescription }}</p>
</main>
<footer class="px-4 flex items-center justify-between">
<p
class="film-score font-bold text-lg"
:class="{
'text-green-600': film.rt_score >= 75,
'text-orange-600': film.rt_score >= 50 && film.rt_score < 75,
'text-yellow-600': film.rt_score >= 25 && film.rt_score < 50,
'text-red-600': film.rt_score >= 0 && film.rt_score < 25
}"
>
{{ film.rt_score + "%" }}
</p>
<router-link
class="rounded font-semibold bg-gray-400 py-2 px-4 border-b-4 border-gray-500"
:to="`/film/${film.id}`"
tag="button"
>
Read more
</router-link>
</footer>
</article>
</template>
<script>
export default {
name: "Film",
props: {
film: {
type: Object,
default: {},
required: true
}
},
computed: {
excerptOfDescription: function() {
return this.film.description.substring(0, 300) + "...";
}
}
};
</script>
<style lang="css" scoped>
header {
background-color: #85ffbd;
background-image: linear-gradient(45deg, #85ffbd 0%, #fffb7d 100%);
}
.film:nth-child(2n) header {
background-color: #ff9a8b;
background-image: linear-gradient(
90deg,
#ff9a8b 0%,
#ff6a88 55%,
#ff99ac 100%
);
}
.film:nth-child(4n) header {
background-color: #fee140;
background-image: linear-gradient(90deg, #fee140 0%, #fa709a 100%);
}
.film:nth-child(5n) header {
background-color: #a9c9ff;
background-image: linear-gradient(180deg, #a9c9ff 0%, #ffbbec 100%);
}
.film-score::before {
content: "";
background: url(~assets/svg/rotten-tomatoes.svg);
background-repeat: no-repeat;
background-size: 100%;
width: 1.5rem;
height: 1.5rem;
display: inline-block;
vertical-align: sub;
margin-right: 0.5rem;
}
</style>

View File

@@ -0,0 +1,9 @@
import { mount } from "@vue/test-utils";
import Footer from "./";
describe("Footer", () => {
it("should render Footer instance", () => {
const wrapper = mount(Footer);
expect(wrapper.exists()).toBe(true);
});
});

View File

@@ -0,0 +1,18 @@
<template>
<footer
class="bg-gray-900 text-gray-300 flex items-center justify-center h-16"
>
<p>
©2020 Made with <span style="color: red;">&#9829;</span> by
<a href="https://wazo-lab.io" target="_blank">Wazo Lab</a>
</p>
</footer>
</template>
<script>
export default {
name: "Footer"
};
</script>
<style></style>

View File

@@ -0,0 +1,26 @@
import { shallowMount } from "@vue/test-utils";
import Grid from "./";
import mockFilms from "@/test/fake-films.json";
describe("Grid", () => {
it("tests props", () => {
expect(Grid.props).toMatchObject({
dataSource: {
type: Array,
required: true
}
});
});
it("should render Grid instance with expected Film components", () => {
const wrapper = shallowMount(Grid, {
propsData: {
dataSource: mockFilms
}
});
expect(wrapper.findAllComponents({ name: "Film" }).length).toBe(
mockFilms.length
);
});
});

22
components/Grid/index.vue Normal file
View File

@@ -0,0 +1,22 @@
<template>
<div class="flex flex-wrap">
<Film :key="film.id" v-for="film in dataSource" :film="film" />
</div>
</template>
<script>
import Film from "../Film";
export default {
components: { Film },
name: "Grid",
props: {
dataSource: {
type: Array,
required: true
}
}
};
</script>
<style></style>

View File

@@ -1,19 +0,0 @@
<template>
<header id="header">
<router-link to="/">
<img
src="https://avatars2.githubusercontent.com/u/1080062?s=200&v=4"
alt="PeopleDoc - Icon"
/>
<h1>Ghibli</h1>
</router-link>
</header>
</template>
<script>
export default {
name: "Header"
};
</script>
<style></style>

View File

@@ -0,0 +1,18 @@
import { mount, RouterLinkStub } from "@vue/test-utils";
import Header from "./";
describe("Header", () => {
it("should render Header instance", () => {
const wrapper = mount(Header, { stubs: ["router-link"] });
expect(wrapper.find("h1").text()).toBe("PeopleDoc");
});
it("should redirect to Home page when clicking on brand logo", () => {
const wrapper = mount(Header, {
stubs: {
RouterLink: RouterLinkStub
}
});
expect(wrapper.findComponent(RouterLinkStub).props().to).toBe("/");
});
});

View File

@@ -0,0 +1,31 @@
<template>
<header
id="header"
class="fixed top-0 left-0 w-screen bg-white h-16 px-4 py-3 shadow-md flex items-center justify-between"
>
<router-link to="/" class="flex w-auto h-full items-center">
<img
class="h-full mr-4"
src="https://avatars2.githubusercontent.com/u/1080062?s=200&v=4"
alt="PeopleDoc - Icon"
/>
<h1 class="text-2xl font-light tracking-wide">PeopleDoc</h1>
</router-link>
<h2 class="font-medium hidden sm:block">{{ description }}</h2>
</header>
</template>
<script>
import pkg from "@/package.json";
export default {
name: "Header",
computed: {
description: function() {
return pkg.description;
}
}
};
</script>
<style></style>

View File

@@ -1,17 +1,16 @@
<template>
<div>
<Header />
<main>
<main class="mt-16 px-4">
<Nuxt />
</main>
<Footer />
</div>
</template>
<script>
import Header from "@/components/Header";
export default {
components: { Header }
middleware: ["redirect"]
};
</script>

3
middleware/redirect.js Normal file
View File

@@ -0,0 +1,3 @@
export default function({ redirect, route }) {
if (route.path === "/") redirect("/films");
}

5
package-lock.json generated
View File

@@ -2362,6 +2362,11 @@
"@sinonjs/commons": "^1.7.0"
}
},
"@tailwindcss/typography": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.3.1.tgz",
"integrity": "sha512-HyZ+3Eay8SGaPq7kcFoANZLr4EjeXQ19yjjb9fp6B0PHHpvZoe00jdsnpnooMEbx9J5rQ93nxPUG3MQmXVxGMQ=="
},
"@types/anymatch": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz",

View File

@@ -12,6 +12,7 @@
},
"dependencies": {
"@nuxtjs/axios": "^5.12.4",
"@tailwindcss/typography": "^0.3.1",
"core-js": "^3.6.5",
"nuxt": "^2.14.6"
},

33
pages/films/index.vue Normal file
View File

@@ -0,0 +1,33 @@
<template>
<section class="py-4">
<img
class="w-full max-w-md mx-auto mb-8"
src="~/assets/images/logo.png"
alt="Studio Ghibli"
/>
<Grid :dataSource="films" />
</section>
</template>
<script>
import Grid from "@/components/Grid";
export default {
name: "Films",
components: { Grid },
head: {
titleTemplate: "%s - Films"
},
async asyncData({ $axios }) {
const films = await $axios.$get("/api/films");
return { films };
},
data() {
return {
films: []
};
}
};
</script>
<style></style>

View File

@@ -1,22 +0,0 @@
<template>
<section>
<h1>Ghibli movies</h1>
{{ films }}
</section>
</template>
<script>
export default {
name: "Movies",
data() {
return {
films: []
};
},
async mounted() {
this.films = await this.$axios.$get("/api/films");
}
};
</script>
<style></style>

View File

@@ -16,5 +16,5 @@ module.exports = {
variants: {
extend: {}
},
plugins: []
plugins: [require("@tailwindcss/typography")]
};

464
test/fake-films.json Normal file
View File

@@ -0,0 +1,464 @@
[
{
"id": "2baf70d1-42bb-4437-b551-e5fed5a87abe",
"title": "Castle in the Sky",
"description": "The orphan Sheeta inherited a mysterious crystal that links her to the mythical sky-kingdom of Laputa. With the help of resourceful Pazu and a rollicking band of sky pirates, she makes her way to the ruins of the once-great civilization. Sheeta and Pazu must outwit the evil Muska, who plans to use Laputa's science to make himself ruler of the world.",
"director": "Hayao Miyazaki",
"producer": "Isao Takahata",
"release_date": "1986",
"rt_score": "95",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/2baf70d1-42bb-4437-b551-e5fed5a87abe"
},
{
"id": "12cfb892-aac0-4c5b-94af-521852e46d6a",
"title": "Grave of the Fireflies",
"description": "In the latter part of World War II, a boy and his sister, orphaned when their mother is killed in the firebombing of Tokyo, are left to survive on their own in what remains of civilian life in Japan. The plot follows this boy and his sister as they do their best to survive in the Japanese countryside, battling hunger, prejudice, and pride in their own quiet, personal battle.",
"director": "Isao Takahata",
"producer": "Toru Hara",
"release_date": "1988",
"rt_score": "97",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/12cfb892-aac0-4c5b-94af-521852e46d6a"
},
{
"id": "58611129-2dbc-4a81-a72f-77ddfc1b1b49",
"title": "My Neighbor Totoro",
"description": "Two sisters move to the country with their father in order to be closer to their hospitalized mother, and discover the surrounding trees are inhabited by Totoros, magical spirits of the forest. When the youngest runs away from home, the older sister seeks help from the spirits to find her.",
"director": "Hayao Miyazaki",
"producer": "Hayao Miyazaki",
"release_date": "1988",
"rt_score": "93",
"people": [
"https://ghibliapi.herokuapp.com/people/986faac6-67e3-4fb8-a9ee-bad077c2e7fe",
"https://ghibliapi.herokuapp.com/people/d5df3c04-f355-4038-833c-83bd3502b6b9",
"https://ghibliapi.herokuapp.com/people/3031caa8-eb1a-41c6-ab93-dd091b541e11",
"https://ghibliapi.herokuapp.com/people/87b68b97-3774-495b-bf80-495a5f3e672d",
"https://ghibliapi.herokuapp.com/people/d39deecb-2bd0-4770-8b45-485f26e1381f",
"https://ghibliapi.herokuapp.com/people/591524bc-04fe-4e60-8d61-2425e42ffb2a",
"https://ghibliapi.herokuapp.com/people/c491755a-407d-4d6e-b58a-240ec78b5061",
"https://ghibliapi.herokuapp.com/people/f467e18e-3694-409f-bdb3-be891ade1106",
"https://ghibliapi.herokuapp.com/people/08ffbce4-7f94-476a-95bc-76d3c3969c19",
"https://ghibliapi.herokuapp.com/people/0f8ef701-b4c7-4f15-bd15-368c7fe38d0a"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2",
"https://ghibliapi.herokuapp.com/species/603428ba-8a86-4b0b-a9f1-65df6abef3d3",
"https://ghibliapi.herokuapp.com/species/74b7f547-1577-4430-806c-c358c8b6bcf5"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/58611129-2dbc-4a81-a72f-77ddfc1b1b49"
},
{
"id": "ea660b10-85c4-4ae3-8a5f-41cea3648e3e",
"title": "Kiki's Delivery Service",
"description": "A young witch, on her mandatory year of independent life, finds fitting into a new community difficult while she supports herself by running an air courier service.",
"director": "Hayao Miyazaki",
"producer": "Hayao Miyazaki",
"release_date": "1989",
"rt_score": "96",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/ea660b10-85c4-4ae3-8a5f-41cea3648e3e"
},
{
"id": "4e236f34-b981-41c3-8c65-f8c9000b94e7",
"title": "Only Yesterday",
"description": "Its 1982, and Taeko is 27 years old, unmarried, and has lived her whole life in Tokyo. She decides to visit her family in the countryside, and as the train travels through the night, memories flood back of her younger years: the first immature stirrings of romance, the onset of puberty, and the frustrations of math and boys. At the station she is met by young farmer Toshio, and the encounters with him begin to reconnect her to forgotten longings. In lyrical switches between the present and the past, Taeko contemplates the arc of her life, and wonders if she has been true to the dreams of her childhood self.",
"director": "Isao Takahata",
"producer": "Toshio Suzuki",
"release_date": "1991",
"rt_score": "100",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/4e236f34-b981-41c3-8c65-f8c9000b94e7"
},
{
"id": "ebbb6b7c-945c-41ee-a792-de0e43191bd8",
"title": "Porco Rosso",
"description": "Porco Rosso, known in Japan as Crimson Pig (Kurenai no Buta) is the sixth animated film by Hayao Miyazaki and released in 1992. You're introduced to an Italian World War I fighter ace, now living as a freelance bounty hunter chasing 'air pirates' in the Adriatic Sea. He has been given a curse that changed his head to that of a pig. Once called Marco Pagot, he is now known to the world as 'Porco Rosso', Italian for 'Red Pig.'",
"director": "Hayao Miyazaki",
"producer": "Toshio Suzuki",
"release_date": "1992",
"rt_score": "94",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/ebbb6b7c-945c-41ee-a792-de0e43191bd8"
},
{
"id": "1b67aa9a-2e4a-45af-ac98-64d6ad15b16c",
"title": "Pom Poko",
"description": "As the human city development encroaches on the raccoon population's forest and meadow habitat, the raccoons find themselves faced with the very real possibility of extinction. In response, the raccoons engage in a desperate struggle to stop the construction and preserve their home.",
"director": "Isao Takahata",
"producer": "Toshio Suzuki",
"release_date": "1994",
"rt_score": "78",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/1b67aa9a-2e4a-45af-ac98-64d6ad15b16c"
},
{
"id": "ff24da26-a969-4f0e-ba1e-a122ead6c6e3",
"title": "Whisper of the Heart",
"description": "Shizuku lives a simple life, dominated by her love for stories and writing. One day she notices that all the library books she has have been previously checked out by the same person: 'Seiji Amasawa'. Curious as to who he is, Shizuku meets a boy her age whom she finds infuriating, but discovers to her shock that he is her 'Prince of Books'. As she grows closer to him, she realises that he merely read all those books to bring himself closer to her. The boy Seiji aspires to be a violin maker in Italy, and it is his dreams that make Shizuku realise that she has no clear path for her life. Knowing that her strength lies in writing, she tests her talents by writing a story about Baron, a cat statuette belonging to Seiji's grandfather.",
"director": "Yoshifumi Kondō",
"producer": "Toshio Suzuki",
"release_date": "1995",
"rt_score": "91",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/ff24da26-a969-4f0e-ba1e-a122ead6c6e3"
},
{
"id": "0440483e-ca0e-4120-8c50-4c8cd9b965d6",
"title": "Princess Mononoke",
"description": "Ashitaka, a prince of the disappearing Ainu tribe, is cursed by a demonized boar god and must journey to the west to find a cure. Along the way, he encounters San, a young human woman fighting to protect the forest, and Lady Eboshi, who is trying to destroy it. Ashitaka must find a way to bring balance to this conflict.",
"director": "Hayao Miyazaki",
"producer": "Toshio Suzuki",
"release_date": "1997",
"rt_score": "92",
"people": [
"https://ghibliapi.herokuapp.com/people/ba924631-068e-4436-b6de-f3283fa848f0",
"https://ghibliapi.herokuapp.com/people/ebe40383-aad2-4208-90ab-698f00c581ab",
"https://ghibliapi.herokuapp.com/people/030555b3-4c92-4fce-93fb-e70c3ae3df8b",
"https://ghibliapi.herokuapp.com/people/ca568e87-4ce2-4afa-a6c5-51f4ae80a60b",
"https://ghibliapi.herokuapp.com/people/e9356bb5-4d4a-4c93-aadc-c83e514bffe3",
"https://ghibliapi.herokuapp.com/people/34277bec-7401-43fa-a00a-5aee64b45b08",
"https://ghibliapi.herokuapp.com/people/91939012-90b9-46e5-a649-96b898073c82",
"https://ghibliapi.herokuapp.com/people/20e3bd33-b35d-41e6-83a4-57ca7f028d38",
"https://ghibliapi.herokuapp.com/people/8bccdc78-545b-49f4-a4c8-756163a38c91",
"https://ghibliapi.herokuapp.com/people/116bfe1b-3ba8-4fa0-8f72-88537a493cb9"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2",
"https://ghibliapi.herokuapp.com/species/6bc92fdd-b0f4-4286-ad71-1f99fb4a0d1e",
"https://ghibliapi.herokuapp.com/species/f25fa661-3073-414d-968a-ab062e3065f7"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/0440483e-ca0e-4120-8c50-4c8cd9b965d6"
},
{
"id": "45204234-adfd-45cb-a505-a8e7a676b114",
"title": "My Neighbors the Yamadas",
"description": "The Yamadas are a typical middle class Japanese family in urban Tokyo and this film shows us a variety of episodes of their lives. With tales that range from the humourous to the heartbreaking, we see this family cope with life's little conflicts, problems and joys in their own way.",
"director": "Isao Takahata",
"producer": "Toshio Suzuki",
"release_date": "1999",
"rt_score": "75",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/45204234-adfd-45cb-a505-a8e7a676b114"
},
{
"id": "dc2e6bd1-8156-4886-adff-b39e6043af0c",
"title": "Spirited Away",
"description": "Spirited Away is an Oscar winning Japanese animated film about a ten year old girl who wanders away from her parents along a path that leads to a world ruled by strange and unusual monster-like animals. Her parents have been changed into pigs along with others inside a bathhouse full of these creatures. Will she ever see the world how it once was?",
"director": "Hayao Miyazaki",
"producer": "Toshio Suzuki",
"release_date": "2001",
"rt_score": "97",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/dc2e6bd1-8156-4886-adff-b39e6043af0c"
},
{
"id": "90b72513-afd4-4570-84de-a56c312fdf81",
"title": "The Cat Returns",
"description": "Haru, a schoolgirl bored by her ordinary routine, saves the life of an unusual cat and suddenly her world is transformed beyond anything she ever imagined. The Cat King rewards her good deed with a flurry of presents, including a very shocking proposal of marriage to his son! Haru embarks on an unexpected journey to the Kingdom of Cats where her eyes are opened to a whole other world.",
"director": "Hiroyuki Morita",
"producer": "Toshio Suzuki",
"release_date": "2002",
"rt_score": "89",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/90b72513-afd4-4570-84de-a56c312fdf81"
},
{
"id": "cd3d059c-09f4-4ff3-8d63-bc765a5184fa",
"title": "Howl's Moving Castle",
"description": "When Sophie, a shy young woman, is cursed with an old body by a spiteful witch, her only chance of breaking the spell lies with a self-indulgent yet insecure young wizard and his companions in his legged, walking home.",
"director": "Hayao Miyazaki",
"producer": "Toshio Suzuki",
"release_date": "2004",
"rt_score": "87",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/cd3d059c-09f4-4ff3-8d63-bc765a5184fa"
},
{
"id": "112c1e67-726f-40b1-ac17-6974127bb9b9",
"title": "Tales from Earthsea",
"description": "Something bizarre has come over the land. The kingdom is deteriorating. People are beginning to act strange... What's even more strange is that people are beginning to see dragons, which shouldn't enter the world of humans. Due to all these bizarre events, Ged, a wandering wizard, is investigating the cause. During his journey, he meets Prince Arren, a young distraught teenage boy. While Arren may look like a shy young teen, he has a severe dark side, which grants him strength, hatred, ruthlessness and has no mercy, especially when it comes to protecting Teru. For the witch Kumo this is a perfect opportunity. She can use the boy's 'fears' against the very one who would help him, Ged.",
"director": "Gorō Miyazaki",
"producer": "Toshio Suzuki",
"release_date": "2006",
"rt_score": "41",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/112c1e67-726f-40b1-ac17-6974127bb9b9"
},
{
"id": "758bf02e-3122-46e0-884e-67cf83df1786",
"title": "Ponyo",
"description": "The son of a sailor, 5-year old Sosuke lives a quiet life on an oceanside cliff with his mother Lisa. One fateful day, he finds a beautiful goldfish trapped in a bottle on the beach and upon rescuing her, names her Ponyo. But she is no ordinary goldfish. The daughter of a masterful wizard and a sea goddess, Ponyo uses her father's magic to transform herself into a young girl and quickly falls in love with Sosuke, but the use of such powerful sorcery causes a dangerous imbalance in the world. As the moon steadily draws nearer to the earth and Ponyo's father sends the ocean's mighty waves to find his daughter, the two children embark on an adventure of a lifetime to save the world and fulfill Ponyo's dreams of becoming human.",
"director": "Hayao Miyazaki",
"producer": "Toshio Suzuki",
"release_date": "2008",
"rt_score": "92",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/758bf02e-3122-46e0-884e-67cf83df1786"
},
{
"id": "2de9426b-914a-4a06-a3a0-5e6d9d3886f6",
"title": "Arrietty",
"description": "14-year-old Arrietty and the rest of the Clock family live in peaceful anonymity as they make their own home from items 'borrowed' from the house's human inhabitants. However, life changes for the Clocks when a human boy discovers Arrietty.",
"director": "Hiromasa Yonebayashi",
"producer": "Toshio Suzuki",
"release_date": "2010",
"rt_score": "95",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/2de9426b-914a-4a06-a3a0-5e6d9d3886f6"
},
{
"id": "45db04e4-304a-4933-9823-33f389e8d74d",
"title": "From Up on Poppy Hill",
"description": "The story is set in 1963 in Yokohama. Kokuriko Manor sits on a hill overlooking the harbour. A 16 year-old girl, Umi, lives in that house. Every morning she raises a signal flag facing the sea. The flag means “I pray for safe voyages”. A 17 year-old boy, Shun, always sees this flag from the sea as he rides a tugboat to school. Gradually the pair are drawn to each other but they are faced with a sudden trial. Even so, they keep going without running from facing the hardships of reality.",
"director": "Gorō Miyazaki",
"producer": "Toshio Suzuki",
"release_date": "2011",
"rt_score": "83",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/45db04e4-304a-4933-9823-33f389e8d74d"
},
{
"id": "67405111-37a5-438f-81cc-4666af60c800",
"title": "The Wind Rises",
"description": "A lifelong love of flight inspires Japanese aviation engineer Jiro Horikoshi, whose storied career includes the creation of the A-6M World War II fighter plane.",
"director": "Hayao Miyazaki",
"producer": "Toshio Suzuki",
"release_date": "2013",
"rt_score": "89",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/67405111-37a5-438f-81cc-4666af60c800"
},
{
"id": "578ae244-7750-4d9f-867b-f3cd3d6fecf4",
"title": "The Tale of the Princess Kaguya",
"description": "A bamboo cutter named Sanuki no Miyatsuko discovers a miniature girl inside a glowing bamboo shoot. Believing her to be a divine presence, he and his wife decide to raise her as their own, calling her 'Princess'.",
"director": "Isao Takahata",
"producer": "Yoshiaki Nishimura",
"release_date": "2013",
"rt_score": "100",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/578ae244-7750-4d9f-867b-f3cd3d6fecf4"
},
{
"id": "5fdfb320-2a02-49a7-94ff-5ca418cae602",
"title": "When Marnie Was There",
"description": "The film follows Anna Sasaki living with her relatives in the seaside town. Anna comes across a nearby abandoned mansion, where she meets Marnie, a mysterious girl who asks her to promise to keep their secrets from everyone. As the summer progresses, Anna spends more time with Marnie, and eventually Anna learns the truth about her family and foster care.",
"director": "Hiromasa Yonebayashi",
"producer": "Yoshiaki Nishimura",
"release_date": "2014",
"rt_score": "92",
"people": [
"https://ghibliapi.herokuapp.com/people/"
],
"species": [
"https://ghibliapi.herokuapp.com/species/af3910a6-429f-4c74-9ad5-dfe1c4aa04f2"
],
"locations": [
"https://ghibliapi.herokuapp.com/locations/"
],
"vehicles": [
"https://ghibliapi.herokuapp.com/vehicles/"
],
"url": "https://ghibliapi.herokuapp.com/films/5fdfb320-2a02-49a7-94ff-5ca418cae602"
}
]

37
test/index.spec.js Normal file
View File

@@ -0,0 +1,37 @@
import { mount, shallowMount } from "@vue/test-utils";
import axios from "axios";
import FilmsView from "@/pages/films";
import mockFilms from "./fake-films.json";
jest.mock("axios", () => ({
$get: jest.fn(() => mockFilms)
}));
describe("Films page", () => {
it("should render Films page instance", () => {
const wrapper = mount(FilmsView);
expect(wrapper.find("img").exists()).toBe(true);
});
it("should get films from Ghibli API", async () => {
let wrapper = shallowMount(FilmsView, {
mocks: {
$axios: axios
}
});
expect((await wrapper.vm.$options.asyncData(wrapper.vm)).films).toEqual(
mockFilms
);
// Init page with mocked asyncData
wrapper = shallowMount(FilmsView, {
mocks: {
films: (await wrapper.vm.$options.asyncData(wrapper.vm)).films,
$axios: axios
}
});
expect(wrapper.findComponent({ name: "Grid" }).exists()).toBe(true);
});
});