From e53b3bd736d494621a347ac529f411943a436d15 Mon Sep 17 00:00:00 2001 From: xiezongchen <952937570@qq.com> Date: Sat, 17 Jul 2021 23:34:51 +0800 Subject: [PATCH] test(descriptions): add NDescriptions slots test --- src/descriptions/tests/Descriptions.spec.ts | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/descriptions/tests/Descriptions.spec.ts b/src/descriptions/tests/Descriptions.spec.ts index 19dd90ad3..8c48db21f 100644 --- a/src/descriptions/tests/Descriptions.spec.ts +++ b/src/descriptions/tests/Descriptions.spec.ts @@ -13,6 +13,34 @@ describe('n-descriptions', () => { mount(NDescriptions) }) + it('should work with slots', async () => { + let wrapper = mount(NDescriptions, { + slots: { default: () => getDescriptionsItemList(), header: () => 'test' } + }) + expect(wrapper.findAll('.n-descriptions-table-header').length).toBe(4) + expect(wrapper.findAll('.n-descriptions-table-content').length).toBe(4) + + expect(wrapper.find('.n-descriptions-header').exists()).toBe(true) + expect(wrapper.find('.n-descriptions-header').text()).toBe('test') + + wrapper = mount(NDescriptions, { + slots: { + default: () => + h(NDescriptionsItem, null, { + default: () => 'test-default', + label: () => 'test-label' + }) + } + }) + + expect(wrapper.find('.n-descriptions-table-header').text()).toBe( + 'test-label' + ) + expect(wrapper.find('.n-descriptions-table-content').text()).toBe( + 'test-default' + ) + }) + it('should work with `bordered` prop', async () => { const wrapper = mount(NDescriptions) expect(wrapper.find('.n-descriptions').classes()).not.toContain(