From 3e2f4211902d6e048e7d299374cd9188689472dd Mon Sep 17 00:00:00 2001 From: "Jessica F. Martinez" Date: Fri, 18 Oct 2024 16:22:37 +0200 Subject: [PATCH] ADD codecov fix --- components/Molecules/ApiError.spec.js | 41 +++++++++++++++++++ components/Molecules/ApiError.vue | 3 +- .../Molecules/MaintenanceNotice.spec.js | 16 ++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 components/Molecules/ApiError.spec.js create mode 100644 components/Molecules/MaintenanceNotice.spec.js diff --git a/components/Molecules/ApiError.spec.js b/components/Molecules/ApiError.spec.js new file mode 100644 index 00000000..d044758b --- /dev/null +++ b/components/Molecules/ApiError.spec.js @@ -0,0 +1,41 @@ +import { mount } from '@vue/test-utils'; +import Vuetify from 'vuetify'; +import Vue from 'vue'; +import ApiError from '@/components/Molecules/ApiError.vue'; + +Vue.use(Vuetify); + +describe('ApiError.vue', () => { + let vuetify; + + beforeEach(() => { + vuetify = new Vuetify(); + }); + + it('should render the illustration correctly', () => { + const wrapper = mount(ApiError, { + vuetify, + stubs: { + 'v-img': { + template: '', + }, + }, + }); + + const img = wrapper.find('img'); + expect(img.exists()).toBe(true); + expect(img.attributes('src')).toBe(require('~/static/images/illustrations/error.png')); + }); + + it('should display the error message', () => { + const wrapper = mount(ApiError, { + vuetify, + }); + + const errorMsg = wrapper.find('.api-error-msg'); + expect(errorMsg.exists()).toBe(true); + expect(errorMsg.text()).toBe( + 'Looks like the server is taking to long to respond, please try again later.' + ); + }); +}); diff --git a/components/Molecules/ApiError.vue b/components/Molecules/ApiError.vue index 9437dbf7..f1adb2af 100644 --- a/components/Molecules/ApiError.vue +++ b/components/Molecules/ApiError.vue @@ -2,8 +2,7 @@

- Looks like the server is taking to long to respond, please try again - later. + Looks like the server is taking to long to respond, please try again later.

diff --git a/components/Molecules/MaintenanceNotice.spec.js b/components/Molecules/MaintenanceNotice.spec.js new file mode 100644 index 00000000..31d8f1fc --- /dev/null +++ b/components/Molecules/MaintenanceNotice.spec.js @@ -0,0 +1,16 @@ +import { shallowMount } from '@vue/test-utils'; +import MaintenanceNotice from '@/components/Molecules/MaintenanceNotice.vue'; + +describe('MaintenanceNotice', () => { + it('should show the message when current date is within the range', () => { + jest.useFakeTimers().setSystemTime(new Date('2024-10-19T10:00:00+02:00')); + const wrapper = shallowMount(MaintenanceNotice); + expect(wrapper.vm.isMessageVisible).toBe(true); + }); + + it('should not show the message when current date is outside the range', () => { + jest.useFakeTimers().setSystemTime(new Date('2024-10-25T10:00:00+02:00')); + const wrapper = shallowMount(MaintenanceNotice); + expect(wrapper.vm.isMessageVisible).toBe(false); + }); +});