Skip to content

Commit

Permalink
Merge branch 'oeb-widgets-dev' of https://github.com/inab/openEBench-…
Browse files Browse the repository at this point in the history
…nuxt into oeb-widgets-dev
  • Loading branch information
JessicaFM committed Oct 28, 2024
2 parents 06690d4 + 60fc106 commit 706291e
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
44 changes: 44 additions & 0 deletions components/Molecules/ApiError.spec.js
Original file line number Diff line number Diff line change
@@ -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: '<img />',
},
},
});

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.'
);
});
});
3 changes: 1 addition & 2 deletions components/Molecules/ApiError.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<div>
<v-img :src="illustration" contain max-height="150" />
<h3 class="api-error-msg">
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.
</h3>
</div>
</template>
Expand Down
16 changes: 16 additions & 0 deletions components/Molecules/MaintenanceNotice.spec.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

0 comments on commit 706291e

Please sign in to comment.