From 080f5f257a596c262a5c9750d01952a2e8f3929b Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 17 Aug 2021 18:32:53 +0200 Subject: [PATCH] more compact wrapper creation --- frontend/src/views/Pages/thx.spec.js | 47 +++++++++------------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/frontend/src/views/Pages/thx.spec.js b/frontend/src/views/Pages/thx.spec.js index 359890fc8..f1bc59b80 100644 --- a/frontend/src/views/Pages/thx.spec.js +++ b/frontend/src/views/Pages/thx.spec.js @@ -3,6 +3,17 @@ import Thx from './thx' const localVue = global.localVue +const createMockObject = (comingFrom) => { + return { + $t: jest.fn((t) => t), + $route: { + params: { + comingFrom, + }, + }, + } +} + describe('Thx', () => { let wrapper @@ -12,14 +23,7 @@ describe('Thx', () => { describe('mount', () => { beforeEach(() => { - wrapper = Wrapper({ - $t: jest.fn((t) => t), - $route: { - params: { - comingFrom: 'password', - }, - }, - }) + wrapper = Wrapper(createMockObject('password')) }) it('renders the thx page', () => { @@ -33,14 +37,7 @@ describe('Thx', () => { describe('coming from /password', () => { beforeEach(() => { - wrapper = Wrapper({ - $t: jest.fn((t) => t), - $route: { - params: { - comingFrom: 'password', - }, - }, - }) + wrapper = Wrapper(createMockObject('password')) }) it('renders the thanks text', () => { @@ -58,14 +55,7 @@ describe('Thx', () => { describe('coming from /reset', () => { beforeEach(() => { - wrapper = Wrapper({ - $t: jest.fn((t) => t), - $route: { - params: { - comingFrom: 'reset', - }, - }, - }) + wrapper = Wrapper(createMockObject('reset')) }) it('renders the thanks text', () => { @@ -83,14 +73,7 @@ describe('Thx', () => { describe('coming from /register', () => { beforeEach(() => { - wrapper = Wrapper({ - $t: jest.fn((t) => t), - $route: { - params: { - comingFrom: 'register', - }, - }, - }) + wrapper = Wrapper(createMockObject('register')) }) it('renders the thanks text', () => {