From 304655cae9e5f8e663dac174e2be0215502e5acf Mon Sep 17 00:00:00 2001 From: Thomas Arrow Date: Fri, 28 Aug 2026 10:08:57 +0100 Subject: [PATCH] WIP: quick skeleton for adding a new test This mocks the $route and adds a very crude mock for the $api. I'd rather not continue down this line until we have a working set of api mocks to build from. Rebuilding these in another way is just going to be confusing --- tests/unit/boilerplate.js | 5 +++++ tests/unit/termsOfUserRenderer.spec.js | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/unit/termsOfUserRenderer.spec.js diff --git a/tests/unit/boilerplate.js b/tests/unit/boilerplate.js index 8af23246..6e101709 100644 --- a/tests/unit/boilerplate.js +++ b/tests/unit/boilerplate.js @@ -16,3 +16,8 @@ window.location = { assign: assignMock } afterEach(() => { assignMock.mockClear() }) + +// throw on any console errors +global.console.error = (message) => { + throw message +} diff --git a/tests/unit/termsOfUserRenderer.spec.js b/tests/unit/termsOfUserRenderer.spec.js new file mode 100644 index 00000000..37dffb54 --- /dev/null +++ b/tests/unit/termsOfUserRenderer.spec.js @@ -0,0 +1,23 @@ +import { shallowMount } from '@vue/test-utils' +import TermsOfUseRenderer from '@/components/Pages/TermsOfUse/TermsOfUseRenderer.vue' +require('./boilerplate.js') + +describe('About.vue', () => { + it('renders some error text if the api call fails or there is no api', () => { + const mockRoute = { + params: { + activeFrom: '0001-01-01' + } + } + const mockApi = jest.fn() + const msg = 'An error occurred' + const wrapper = shallowMount(TermsOfUseRenderer, { + mocks: { + $route: mockRoute, + $api: mockApi + } + } + ) + expect(wrapper.text()).toMatch(msg) + }) +})