diff --git a/src/README.md b/src/README.md index d3095f9..ccdd48d 100644 --- a/src/README.md +++ b/src/README.md @@ -187,4 +187,4 @@ p > i { | stroke-linejoin | `string` | `"round"` | miter, round, bevel | Specifies the shape to be used at the corners of paths or basic shapes when they are stroked ([spec](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin)). | | stroke-width | `number \| string` | `2` | - | The stroke width of the icon ([spec](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-width)). | | tag | `string` | `"i"` | - | The tag of the icon. | -| type | `string` | - | All [Feather](https://feathericons.com/)'s icons. | The type of the icon. | +| type | `string` | `"feather"` | All [Feather](https://feathericons.com/)'s icons. | The type of the icon. | diff --git a/src/vue-feather.vue b/src/vue-feather.vue index db28da5..6947d39 100644 --- a/src/vue-feather.vue +++ b/src/vue-feather.vue @@ -52,7 +52,7 @@ export default defineComponent({ type: { type: String, - required: true, + default: 'feather', validator(type: string) { if (!feather) { throw new Error('The Feather icons is required.'); diff --git a/tests/props.spec.ts b/tests/props.spec.ts index ae4328f..989f6a6 100644 --- a/tests/props.spec.ts +++ b/tests/props.spec.ts @@ -5,11 +5,7 @@ import VueFeather from '../src'; describe('props', () => { describe('animation', () => { it('default', () => { - const wrapper = mount(VueFeather, { - props: { - type: 'feather', - }, - }); + const wrapper = mount(VueFeather); expect(wrapper.props('animation')).toBeUndefined(); expect(wrapper.classes()).not.toContain('vue-feather--spin'); @@ -20,7 +16,6 @@ describe('props', () => { const wrapper = mount(VueFeather, { props: { animation: 'spin', - type: 'feather', }, }); @@ -32,7 +27,6 @@ describe('props', () => { const wrapper = mount(VueFeather, { props: { animation: 'pulse', - type: 'feather', }, }); @@ -43,11 +37,7 @@ describe('props', () => { describe('animation-speed', () => { it('default', () => { - const wrapper = mount(VueFeather, { - props: { - type: 'feather', - }, - }); + const wrapper = mount(VueFeather); expect(wrapper.props('animationSpeed')).toBeUndefined(); expect(wrapper.classes()).not.toContain('vue-feather--slow'); @@ -58,7 +48,6 @@ describe('props', () => { const wrapper = mount(VueFeather, { props: { animationSpeed: 'slow', - type: 'feather', }, }); @@ -70,7 +59,6 @@ describe('props', () => { const wrapper = mount(VueFeather, { props: { animationSpeed: 'fast', - type: 'feather', }, }); @@ -83,7 +71,6 @@ describe('props', () => { const wrapper = mount(VueFeather, { props: { fill: 'red', - type: 'feather', }, }); @@ -95,7 +82,6 @@ describe('props', () => { const wrapper = mount(VueFeather, { props: { size: '2rem', - type: 'feather', }, }); @@ -108,7 +94,6 @@ describe('props', () => { const wrapper = mount(VueFeather, { props: { stroke: 'red', - type: 'feather', }, }); @@ -120,7 +105,6 @@ describe('props', () => { const wrapper = mount(VueFeather, { props: { strokeLinecap: 'butt', - type: 'feather', }, }); @@ -132,7 +116,6 @@ describe('props', () => { const wrapper = mount(VueFeather, { props: { strokeLinejoin: 'miter', - type: 'feather', }, }); @@ -144,7 +127,6 @@ describe('props', () => { const wrapper = mount(VueFeather, { props: { strokeWidth: 3, - type: 'feather', }, }); @@ -154,11 +136,7 @@ describe('props', () => { describe('tag', () => { it('default', () => { - const wrapper = mount(VueFeather, { - props: { - type: 'feather', - }, - }); + const wrapper = mount(VueFeather); expect(wrapper.props('tag')).toBe('i'); expect(wrapper.vm.$el.tagName.toLowerCase()).toBe('i'); @@ -168,7 +146,6 @@ describe('props', () => { const wrapper = mount(VueFeather, { props: { tag: 'span', - type: 'feather', }, }); @@ -178,6 +155,14 @@ describe('props', () => { }); describe('type', () => { + it('default', () => { + const wrapper = mount(VueFeather); + + expect(wrapper.props('type')).toBe('feather'); + expect(wrapper.classes()).toContain('vue-feather--feather'); + expect(wrapper.vm.$el.querySelector('svg').innerHTML).toContain(feather.icons.feather.contents); + }); + it('invalid', () => { expect(() => { mount(VueFeather, { @@ -187,17 +172,5 @@ describe('props', () => { }); }).toThrowError(); }); - - it('feather', () => { - const wrapper = mount(VueFeather, { - props: { - type: 'feather', - }, - }); - - expect(wrapper.props('type')).toBe('feather'); - expect(wrapper.classes()).toContain('vue-feather--feather'); - expect(wrapper.vm.$el.querySelector('svg').innerHTML).toContain(feather.icons.feather.contents); - }); }); });