Skip to content

Commit

Permalink
fix: Edit tests for functional component
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored and robcresswell committed Sep 8, 2019
1 parent 4a0dead commit a574e39
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions __tests__/icon.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
import { shallowMount } from '@vue/test-utils';
import { mount } from '@vue/test-utils';
import AndroidIcon from '../dist/Android';

const WrappedIcon = {
components: {
AndroidIcon,
},
render(h) {
return h(AndroidIcon, {
attrs: this.$attrs,
listeners: this.$listeners,
});
},
};

describe('Icon', () => {
let icon;

beforeEach(() => {
icon = shallowMount(AndroidIcon);
icon = mount(WrappedIcon);
});

it('accepts a "title" property', () => {
expect(icon.vm.title).toEqual('Android icon');
expect(icon.attributes()['aria-label']).toEqual('Android icon');

icon.setProps({ title: 'foo' });

expect(icon.vm.title).toEqual('foo');
expect(icon.attributes()['aria-label']).toEqual('foo');
});

it('accepts a "decorative" property', () => {
expect(icon.vm.decorative).toBe(false);
expect(icon.attributes()['aria-hidden']).toBeFalsy();

icon.setProps({ decorative: true });

expect(icon.vm.decorative).toBe(true);
expect(icon.attributes()['aria-hidden']).toBeTruthy();
});

it('accepts a "fillColor" property', () => {
const svg = icon.find('.material-design-icon__svg');

expect(icon.vm.fillColor).toBe('currentColor');
expect(svg.attributes()['fill']).toEqual('currentColor');

icon.setProps({ fillColor: '#FF0000' });

expect(icon.vm.fillColor).toBe('#FF0000');
expect(svg.attributes()['fill']).toEqual('#FF0000');
});

Expand Down

0 comments on commit a574e39

Please sign in to comment.