test(Popover): add className test case

This commit is contained in:
chenjiahan 2020-11-20 11:55:56 +08:00 committed by neverland
parent 99b52726b6
commit 178a41a8b0
2 changed files with 20 additions and 3 deletions

View File

@ -1,23 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`should allow to custom the className of action 1`] = `
<div class="van-popover__action foo">
<div class="van-popover__action-text van-hairline--bottom">Option</div>
</div>
`;
exports[`should locate to reference element when showed 1`] = `<!---->`;
exports[`should locate to reference element when showed 2`] = `
<div class="van-popup van-popover van-popover--light" name="van-popover-zoom" style="position: absolute; left: 0px; top: 8px; margin: 0px; z-index: 2005;" data-popper-placement="bottom">
<div class="van-popup van-popover van-popover--light" name="van-popover-zoom" style="position: absolute; left: 0px; top: 8px; margin: 0px; z-index: 2006;" data-popper-placement="bottom">
<div class="van-popover__arrow"></div>
<div class="van-popover__content"></div>
</div>
`;
exports[`should locate to reference element when showed 3`] = `
<div class="van-popup van-popover van-popover--light" name="van-popover-zoom" style="position: absolute; left: 0px; top: 8px; margin: 0px; z-index: 2005; display: none;" data-popper-placement="bottom">
<div class="van-popup van-popover van-popover--light" name="van-popover-zoom" style="position: absolute; left: 0px; top: 8px; margin: 0px; z-index: 2006; display: none;" data-popper-placement="bottom">
<div class="van-popover__arrow"></div>
<div class="van-popover__content"></div>
</div>
`;
exports[`should watch placement prop and update location 1`] = `
<div class="van-popup van-popover van-popover--light" name="van-popover-zoom" style="z-index: 2006; position: absolute; left: 0px; top: -8px; margin: 0px;" data-popper-placement="top">
<div class="van-popup van-popover van-popover--light" name="van-popover-zoom" style="z-index: 2007; position: absolute; left: 0px; top: -8px; margin: 0px;" data-popper-placement="top">
<div class="van-popover__arrow"></div>
<div class="van-popover__content"></div>
</div>

View File

@ -47,6 +47,17 @@ test('should close popover when clicking the action', () => {
expect(wrapper.emitted('input').length).toEqual(1);
});
test('should allow to custom the className of action', () => {
const wrapper = mount(Popover, {
propsData: {
value: true,
actions: [{ text: 'Option', className: 'foo' }],
},
});
expect(wrapper.find('.van-popover__action').html()).toMatchSnapshot();
});
test('should not init popper.js instance before showed', async () => {
const wrapper = mount(Popover);
expect(wrapper.vm.popper).toBeFalsy();