SurenNeware | b31a448 | 2020-12-29 20:55:02 +0530 | [diff] [blame] | 1 | import { mount, createLocalVue } from '@vue/test-utils'; |
| 2 | import LoadingBar from '@/components/Global/LoadingBar'; |
| 3 | import BootstrapVue from 'bootstrap-vue'; |
| 4 | |
| 5 | const localVue = createLocalVue(); |
| 6 | localVue.use(BootstrapVue); |
| 7 | |
| 8 | describe('LoadingBar.vue', () => { |
| 9 | const wrapper = mount(LoadingBar, { |
| 10 | localVue, |
| 11 | data() { |
| 12 | return { |
| 13 | loadingIndicatorValue: 0, |
| 14 | isLoadingComplete: false, |
| 15 | }; |
| 16 | }, |
| 17 | mocks: { |
| 18 | $t: (key) => key, |
| 19 | }, |
| 20 | }); |
| 21 | it('should exist', () => { |
| 22 | expect(wrapper.exists()).toBe(true); |
| 23 | }); |
| 24 | it('should show loading bar element', async () => { |
| 25 | await wrapper.setData({ |
| 26 | isLoadingComplete: false, |
| 27 | loadingIndicatorValue: 100, |
| 28 | }); |
| 29 | expect(wrapper.vm.isLoadingComplete).toBe(false); |
| 30 | expect(wrapper.find('.progress').exists()).toBe(true); |
| 31 | }); |
| 32 | it('should hide loading bar element', async () => { |
| 33 | await wrapper.setData({ |
| 34 | isLoadingComplete: true, |
| 35 | loadingIndicatorValue: 0, |
| 36 | }); |
| 37 | expect(wrapper.vm.isLoadingComplete).toBe(true); |
| 38 | expect(wrapper.find('.progress').exists()).toBe(false); |
| 39 | }); |
| 40 | it('should render correctly', () => { |
| 41 | expect(wrapper.element).toMatchSnapshot(); |
| 42 | }); |
| 43 | }); |