Skip to content

Commit

Permalink
Merge pull request #289 from cesargb/tag_semantic
Browse files Browse the repository at this point in the history
feat(CFooter): add the `as` property to allow the use of custom tags
  • Loading branch information
mrholek authored May 30, 2024
2 parents 1fd45ef + 9ec6370 commit 7d80cc6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/coreui-vue/src/components/footer/CFooter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import { defineComponent, h } from 'vue'
const CFooter = defineComponent({
name: 'CFooter',
props: {
/**
* Component used for the root node. Either a string to use a HTML element or a component.
*/
as: {
type: String,
default: 'div',
},
/**
* Place footer in non-static positions.
*
Expand All @@ -18,7 +25,7 @@ const CFooter = defineComponent({
setup(props, { slots }) {
return () =>
h(
'div',
props.as,
{ class: ['footer', { [`footer-${props.position}`]: props.position }] },
slots.default && slots.default(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ const customWrapper = mount(Component, {
},
})

const customWrapperTwo = mount(Component, {
propsData: {
as: 'footer',
},
slots: {
default: 'Default slot',
},
})

describe(`Loads and display ${ComponentName} component`, () => {
it('has a name', () => {
expect(Component.name).toMatch(ComponentName)
Expand All @@ -42,3 +51,13 @@ describe(`Customize ${ComponentName} component`, () => {
expect(customWrapper.classes('footer-fixed')).toBe(true)
})
})

describe(`Customize (number two) ${ComponentName} component`, () => {
it('renders correctly', () => {
expect(customWrapperTwo.html()).toMatchSnapshot()
})

it('tag name is custom', () => {
expect(customWrapperTwo.element.tagName).toBe('FOOTER')
})
})

0 comments on commit 7d80cc6

Please sign in to comment.