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 @@