UNPKG

@mekari/mekari-ui-vue

Version:

--- General web components in Mekari. The components are made using vue.js as its framework. Styling of components on Mekari UI Vue uses [Mekari UI Toolkit](https://bitbucket.org/mid-kelola-indonesia/mekari-ui-toolkit/src/master/). Don't forget to import

93 lines (77 loc) 2.34 kB
import MIcon from './index.vue'; import { shallowMount } from '@vue/test-utils'; describe('Mekari UI Icon Component', () => { let wrapper; beforeEach(() => { wrapper = shallowMount(MIcon); }); afterEach(() => { wrapper.destroy(); }); it('should match snapshot', async () => { wrapper.setProps({ variant: 'add', size: 'regular', color: 'dark', }); await wrapper.vm.$nextTick(); expect(wrapper.element).toMatchSnapshot(); }); it('should use class based on variant correctly', async () => { wrapper.setProps({ variant: 'add', }); await wrapper.vm.$nextTick(); expect(wrapper.classes('ic-add')).toBe(true); }); it('should use class based on size correctly', async () => { wrapper.setProps({ size: 'small', }); await wrapper.vm.$nextTick(); expect(wrapper.classes('ic-small')).toBe(true); }); it('should use class based on color correctly', async () => { wrapper.setProps({ color: 'dark', }); await wrapper.vm.$nextTick(); expect(wrapper.classes('text-dark')).toBe(true); }); it('should not use color class if icon size is blankslate', async () => { wrapper.setProps({ color: 'dark', size: 'blankslate', }); await wrapper.vm.$nextTick(); expect(wrapper.classes('text-dark')).toBe(false); }); it('should not use size class if icon size is regular', async () => { wrapper.setProps({ size: 'regular', }); await wrapper.vm.$nextTick(); expect(wrapper.classes('ic-regular')).toBe(false); }); it('should add `.ic-input-prefix` if prop `isPrefixIcon` is true', async () => { wrapper.setProps({ isPrefixIcon: true, }); await wrapper.vm.$nextTick(); expect(wrapper.classes('ic-input-prefix')).toBe(true); }); it('should add `.ic-input-suffix` if prop `isSuffixIcon` is true', async () => { wrapper.setProps({ isSuffixIcon: true, }); await wrapper.vm.$nextTick(); expect(wrapper.classes('ic-input-suffix')).toBe(true); }); it('should add `.ic-input-suffix--doublee` if prop `isDoubleSuffixIcon` is true', async () => { wrapper.setProps({ isDoubleSuffixIcon: true, }); await wrapper.vm.$nextTick(); expect(wrapper.classes('ic-input-suffix--double')).toBe(true); }); });