-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(b-table, b-table-lite): add new scoped slot
custom-foot
to all…
- Loading branch information
1 parent
81efb89
commit cbeeef9
Showing
4 changed files
with
151 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { mount } from '@vue/test-utils' | ||
import { BTable } from './table' | ||
|
||
const testItems = [{ a: 1, b: 2, c: 3 }] | ||
const testFields = [{ key: 'a', label: 'A' }, { key: 'b', label: 'B' }, { key: 'c', label: 'C' }] | ||
|
||
describe('table > custom tfoot slot', () => { | ||
it('should not render tfoot by default', async () => { | ||
const wrapper = mount(BTable, { | ||
propsData: { | ||
fields: testFields, | ||
items: testItems, | ||
footClone: false | ||
} | ||
}) | ||
expect(wrapper).toBeDefined() | ||
expect(wrapper.is('table')).toBe(true) | ||
expect(wrapper.find('thead').exists()).toBe(true) | ||
expect(wrapper.find('tbody').exists()).toBe(true) | ||
expect(wrapper.find('tfoot').exists()).toBe(false) | ||
|
||
wrapper.destroy() | ||
}) | ||
|
||
it('should render custom-foot slot inside b-tfoot', async () => { | ||
const wrapper = mount(BTable, { | ||
propsData: { | ||
fields: testFields, | ||
items: testItems, | ||
footClone: false | ||
}, | ||
slots: { | ||
'custom-foot': '<tr><td colspan="3">CUSTOM-FOOTER</td></tr>' | ||
} | ||
}) | ||
expect(wrapper).toBeDefined() | ||
expect(wrapper.is('table')).toBe(true) | ||
expect(wrapper.find('thead').exists()).toBe(true) | ||
expect(wrapper.find('tbody').exists()).toBe(true) | ||
expect(wrapper.find('tfoot').exists()).toBe(true) | ||
expect(wrapper.find('tfoot').text()).toContain('CUSTOM-FOOTER') | ||
expect(wrapper.find('tfoot').classes().length).toBe(0) | ||
|
||
wrapper.destroy() | ||
}) | ||
|
||
it('should not render custom-foot slot when foot-clone is true', async () => { | ||
const wrapper = mount(BTable, { | ||
propsData: { | ||
fields: testFields, | ||
items: testItems, | ||
footClone: true | ||
}, | ||
slots: { | ||
'custom-foot': '<tr><td colspan="3">CUSTOM-FOOTER</td></tr>' | ||
} | ||
}) | ||
expect(wrapper).toBeDefined() | ||
expect(wrapper.is('table')).toBe(true) | ||
expect(wrapper.find('thead').exists()).toBe(true) | ||
expect(wrapper.find('tbody').exists()).toBe(true) | ||
expect(wrapper.find('tfoot').exists()).toBe(true) | ||
expect(wrapper.find('tfoot').text()).not.toContain('CUSTOM-FOOTER') | ||
|
||
wrapper.destroy() | ||
}) | ||
|
||
it('should have foot-variant on custom-foot slot', async () => { | ||
const wrapper = mount(BTable, { | ||
propsData: { | ||
fields: testFields, | ||
items: testItems, | ||
footClone: false, | ||
footVariant: 'dark' | ||
}, | ||
slots: { | ||
'custom-foot': '<tr><td colspan="3">CUSTOM-FOOTER</td></tr>' | ||
} | ||
}) | ||
expect(wrapper).toBeDefined() | ||
expect(wrapper.is('table')).toBe(true) | ||
expect(wrapper.find('thead').exists()).toBe(true) | ||
expect(wrapper.find('tbody').exists()).toBe(true) | ||
expect(wrapper.find('tfoot').exists()).toBe(true) | ||
expect(wrapper.find('tfoot').text()).toContain('CUSTOM-FOOTER') | ||
expect(wrapper.find('tfoot').classes()).toContain('thead-dark') | ||
expect(wrapper.find('tfoot').classes().length).toBe(1) | ||
|
||
wrapper.destroy() | ||
}) | ||
}) |