diff --git a/src/action-sheet/test/__snapshots__/index.spec.js.snap b/src/action-sheet/test/__snapshots__/index.spec.js.snap index 4754a0817..41636e0aa 100644 --- a/src/action-sheet/test/__snapshots__/index.spec.js.snap +++ b/src/action-sheet/test/__snapshots__/index.spec.js.snap @@ -1,5 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`should allow to custom close icon with closeIcon prop 1`] = ` + + + + +`; + exports[`should render default slot and match snapshot 1`] = `
@@ -20,3 +27,7 @@ exports[`should render default slot and match snapshot 1`] = `
`; + +exports[`should render description and match snapshot 1`] = `
This is a description
`; + +exports[`should render description slot when match snapshot 1`] = `
Custom Description
`; diff --git a/src/action-sheet/test/index.legacy.js b/src/action-sheet/test/index.legacy.js index 9385d8b76..cfce79b89 100644 --- a/src/action-sheet/test/index.legacy.js +++ b/src/action-sheet/test/index.legacy.js @@ -98,64 +98,3 @@ test('close-on-click-action prop', () => { expect(onInput).toHaveBeenCalledWith(false); }); - -test('color option', () => { - const wrapper = mount(ActionSheet, { - propsData: { - value: true, - actions: [{ name: 'Option', color: 'red' }], - }, - }); - - expect(wrapper.html()).toMatchSnapshot(); -}); - -test('description prop', () => { - const wrapper = mount(ActionSheet, { - propsData: { - value: true, - description: 'This is a description', - actions: [{ name: 'Option' }], - }, - }); - - expect(wrapper.html()).toMatchSnapshot(); -}); - -test('description slot', () => { - const wrapper = mount(ActionSheet, { - propsData: { - value: true, - actions: [{ name: 'Option' }], - }, - scopedSlots: { - description: () => 'Custom Description', - }, - }); - - expect(wrapper.html()).toMatchSnapshot(); -}); - -test('close-icon prop', () => { - const wrapper = mount(ActionSheet, { - propsData: { - value: true, - title: 'Title', - closeIcon: 'cross', - }, - }); - - expect(wrapper.html()).toMatchSnapshot(); -}); - -test('closeable prop', () => { - const wrapper = mount(ActionSheet, { - propsData: { - value: true, - title: 'Title', - closeable: false, - }, - }); - - expect(wrapper.html()).toMatchSnapshot(); -}); diff --git a/src/action-sheet/test/index.spec.js b/src/action-sheet/test/index.spec.js index 591061afa..ab1d84983 100644 --- a/src/action-sheet/test/index.spec.js +++ b/src/action-sheet/test/index.spec.js @@ -47,3 +47,71 @@ test('should have "van-popup--round" class when setting the round prop', () => { expect(wrapper.find('.van-popup--round').exists()).toBeTruthy(); }); + +test('should change option color when using the color prop', () => { + const wrapper = mount(ActionSheet, { + propsData: { + show: true, + actions: [{ name: 'Option', color: 'red' }], + }, + }); + + expect(wrapper.find('.van-action-sheet__item').element.style.color).toEqual( + 'red' + ); +}); + +test('should hide close icon when the closeable prop is false', async () => { + const wrapper = mount(ActionSheet, { + propsData: { + show: true, + title: 'Title', + }, + }); + + expect(wrapper.find('.van-action-sheet__close').exists()).toBeTruthy(); + + wrapper.setProps({ closeable: false }); + await later(); + expect(wrapper.find('.van-action-sheet__close').exists()).toBeFalsy(); +}); + +test('should allow to custom close icon with closeIcon prop', () => { + const wrapper = mount(ActionSheet, { + propsData: { + show: true, + title: 'Title', + closeIcon: 'cross', + }, + }); + + expect(wrapper.find('.van-action-sheet__close').html()).toMatchSnapshot(); +}); + +test('should render description and match snapshot', () => { + const wrapper = mount(ActionSheet, { + propsData: { + show: true, + description: 'This is a description', + }, + }); + + expect( + wrapper.find('.van-action-sheet__description').html() + ).toMatchSnapshot(); +}); + +test('should render description slot when match snapshot', () => { + const wrapper = mount(ActionSheet, { + propsData: { + show: true, + }, + slots: { + description: () => 'Custom Description', + }, + }); + + expect( + wrapper.find('.van-action-sheet__description').html() + ).toMatchSnapshot(); +});