Récupération des genres et début du test avec récupération des élément du Dom.
Showing
1 changed file
with
18 additions
and
4 deletions
| @@ -2,13 +2,27 @@ | @@ -2,13 +2,27 @@ | ||
| 2 | import { describe, expect, it } from "vitest"; | 2 | import { describe, expect, it } from "vitest"; |
| 3 | import { mount } from "@vue/test-utils"; | 3 | import { mount } from "@vue/test-utils"; |
| 4 | import MovieGender from "../../components/details/MovieGender.vue"; | 4 | import MovieGender from "../../components/details/MovieGender.vue"; |
| 5 | +import type { Genre } from "~/interfaces/movie"; | ||
| 5 | //#endregion | 6 | //#endregion |
| 6 | 7 | ||
| 7 | describe("MovieGender", () => { | 8 | describe("MovieGender", () => { |
| 8 | - // todo : ajouter les tests ici. | 9 | + it("affiche correctement les genres", () => { |
| 9 | - it("component renders properly", () => { | 10 | + // Données de test |
| 10 | - const wrapper = mount(MovieGender); | 11 | + const genres: Genre[] = [ |
| 12 | + { id: 1, name: "Action" }, | ||
| 13 | + { id: 2, name: "Comédie" }, | ||
| 14 | + { id: 3, name: "Drame" }, | ||
| 15 | + ]; | ||
| 16 | + // Monter le composant avec sa props | ||
| 17 | + const wrapper = mount(MovieGender, { | ||
| 18 | + props: { | ||
| 19 | + genres | ||
| 20 | + } | ||
| 21 | + }); | ||
| 22 | + | ||
| 23 | + const spanElements = wrapper.findAll('span'); | ||
| 24 | + console.log(spanElements); | ||
| 11 | // expect(wrapper.text()).toContain("Hello world"); | 25 | // expect(wrapper.text()).toContain("Hello world"); |
| 12 | expect(wrapper.text()); | 26 | expect(wrapper.text()); |
| 13 | }); | 27 | }); |
| 14 | -}); | 28 | +}); |
-
Please register or login to post a comment