diff --git a/components/Molecules/ApiError.spec.js b/components/Molecules/ApiError.spec.js new file mode 100644 index 00000000..25548cc8 --- /dev/null +++ b/components/Molecules/ApiError.spec.js @@ -0,0 +1,44 @@ +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..c598ea3b 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..b7b4e8fb --- /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); + }); +});