|
| 1 | +import { shallowMount } from '@vue/test-utils'; |
| 2 | +import StatusIndicator from '../../packages/StatusIndicator/src/main.vue'; |
| 3 | + |
| 4 | +const vm = shallowMount(StatusIndicator); |
| 5 | + |
| 6 | +// Helper function to create a component |
| 7 | +const createComponent = propsData => shallowMount(StatusIndicator, { propsData }); |
| 8 | + |
| 9 | +describe('VueStatusIndicator.vue', () => { |
| 10 | + let cmp; |
| 11 | + it('has a mounted hook', () => { |
| 12 | + expect(typeof StatusIndicator.mounted).toBe('function'); |
| 13 | + }); |
| 14 | + |
| 15 | + it('should match the snapshot', () => { |
| 16 | + expect(vm.$el).toMatchSnapshot(); |
| 17 | + }); |
| 18 | + |
| 19 | + describe('Properties', () => { |
| 20 | + it('should be showed with the default color if the status prop not set', () => { |
| 21 | + cmp = createComponent(); |
| 22 | + expect(cmp.vm.status).toBe(''); |
| 23 | + expect(cmp.vm.$el.active).toBe(undefined); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should be showed with the active color if the status prop is set', () => { |
| 27 | + cmp = createComponent({ status: 'active' }); |
| 28 | + expect(cmp.vm.status).toBe('active'); |
| 29 | + expect(cmp.vm.$el.active).toBe(''); |
| 30 | + }); |
| 31 | + |
| 32 | + it('should be showed with the positive color if the status prop is set', () => { |
| 33 | + cmp = createComponent({ status: 'positive' }); |
| 34 | + expect(cmp.vm.status).toBe('positive'); |
| 35 | + expect(cmp.vm.$el.positive).toBe(''); |
| 36 | + }); |
| 37 | + |
| 38 | + it('should be showed with the intermediary color if the status prop is set', () => { |
| 39 | + cmp = createComponent({ status: 'intermediary' }); |
| 40 | + expect(cmp.vm.status).toBe('intermediary'); |
| 41 | + expect(cmp.vm.$el.intermediary).toBe(''); |
| 42 | + }); |
| 43 | + |
| 44 | + it('should be showed with the negative color if the status prop is set', () => { |
| 45 | + cmp = createComponent({ status: 'negative' }); |
| 46 | + expect(cmp.vm.status).toBe('negative'); |
| 47 | + expect(cmp.vm.$el.negative).toBe(''); |
| 48 | + }); |
| 49 | + |
| 50 | + it('should be showed without pulse effect when the pulse prop is false by default', () => { |
| 51 | + cmp = createComponent(); |
| 52 | + expect(cmp.vm.status).toBeFalsy(); |
| 53 | + expect(cmp.vm.$el.pulse).toBe(undefined); |
| 54 | + }); |
| 55 | + |
| 56 | + it('should be showed with pulse effect when the pulse prop is false by default', () => { |
| 57 | + cmp = createComponent({ pulse: true }); |
| 58 | + expect(cmp.vm.pulse).toBeTruthy(); |
| 59 | + expect(cmp.vm.$el.pulse).toBe(''); |
| 60 | + }); |
| 61 | + }); |
| 62 | +}); |
0 commit comments