From c9581196da1782f51b4844a9cbb3aa7dabf1e955 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 13 Dec 2021 12:16:13 +0100 Subject: [PATCH] test admin and setVisible methods, test elopage links --- .../views/Layout/DashboardLayout_gdd.spec.js | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js index 3e03bec2e..4ea2e86b2 100644 --- a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js +++ b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js @@ -52,6 +52,7 @@ describe('DashboardLayoutGdd', () => { publisherId: 123, firstName: 'User', lastName: 'Example', + token: 'valid-token', }, dispatch: storeDispatchMock, commit: storeCommitMock, @@ -222,6 +223,65 @@ describe('DashboardLayoutGdd', () => { expect(toasterMock).toBeCalledWith('Ouch!') }) }) + + describe('set visible method', () => { + beforeEach(() => { + wrapper.findComponent({ name: 'Navbar' }).vm.$emit('set-visible', true) + }) + + it('sets visible to true', () => { + expect(wrapper.vm.visible).toBe(true) + }) + }) + + describe('elopage URI', () => { + describe('user has no publisher ID and no elopage', () => { + beforeEach(() => { + mocks.$store.state.publisherId = null + mocks.$store.state.hasElopage = false + wrapper = Wrapper() + }) + + it('links to basic-de', () => { + expect(wrapper.vm.elopageUri).toBe( + 'https://elopage.com/s/gradido/basic-de/payment?locale=en&prid=111&pid=2896&firstName=User&lastName=Example&email=user@example.org', + ) + }) + }) + + describe('user has elopage', () => { + beforeEach(() => { + mocks.$store.state.publisherId = '123' + mocks.$store.state.hasElopage = true + wrapper = Wrapper() + }) + + it('links to sign in for elopage', () => { + expect(wrapper.vm.elopageUri).toBe('https://elopage.com/s/gradido/sign_in?locale=en') + }) + }) + }) + + describe('admin method', () => { + const windowLocationMock = jest.fn() + beforeEach(() => { + delete window.location + window.location = { + assign: windowLocationMock, + } + wrapper.findComponent({ name: 'Navbar' }).vm.$emit('admin') + }) + + it('dispatches logout to store', () => { + expect(storeDispatchMock).toBeCalled() + }) + + it('changes window location to admin interface', () => { + expect(windowLocationMock).toBeCalledWith( + 'http://localhost/admin/authenticate?token=valid-token', + ) + }) + }) }) }) })