From 411966f7271258695b90818d5791c4e2ecba5d77 Mon Sep 17 00:00:00 2001 From: enzoggqs Date: Thu, 12 Jan 2023 16:02:09 -0300 Subject: [PATCH] Add more tests to TopBar component --- .../TopBar/__tests__/TopBar.spec.ts | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/components/TopBar/__tests__/TopBar.spec.ts b/src/components/TopBar/__tests__/TopBar.spec.ts index 5fa8de8..8e28f75 100644 --- a/src/components/TopBar/__tests__/TopBar.spec.ts +++ b/src/components/TopBar/__tests__/TopBar.spec.ts @@ -1,16 +1,35 @@ /* eslint-disable no-undef */ import { shallowMount } from "@vue/test-utils"; import TopBar from "../TopBar.vue"; -import { createApp } from "vue"; -import App from "../../../App.vue"; -import { createPinia } from "pinia"; +import { useEtherStore } from "../../../store/ether"; -const app = createApp(App); -app.use(createPinia()); +import { createPinia, setActivePinia } from "pinia"; describe("TopBar.vue", () => { - it("render component when called", () => { + beforeEach(() => { + setActivePinia(createPinia()); + }); + + it("should render connect wallet button", () => { const wrapper = shallowMount(TopBar); - // expect(wrapper).toBeCalled(); + expect(wrapper.html()).toContain("Conectar carteira"); + }); + + it("should render button to change to seller view when in buyer screen", () => { + const wrapper = shallowMount(TopBar); + expect(wrapper.html()).toContain("Quero vender"); + }); + + it("should render button to change to seller view when in buyer screen", () => { + const etherStore = useEtherStore(); + etherStore.setSellerView(true); + const wrapper = shallowMount(TopBar); + expect(wrapper.html()).toContain("Quero comprar"); + }); + + it("should render the P2Pix logo correctly", () => { + const wrapper = shallowMount(TopBar); + const img = wrapper.findAll(".logo"); + expect(img.length).toBe(1); }); });