-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(NcAppNavigationCaption): Add
caption-id
prop to allow setting …
…the ID on the caption itself Signed-off-by: Ferdinand Thiessen <[email protected]>
- Loading branch information
Showing
3 changed files
with
92 additions
and
2 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
60 changes: 60 additions & 0 deletions
60
tests/unit/components/NcAppNavigation/NcAppNavigationCaption.spec.ts
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,60 @@ | ||
import { describe, expect } from '@jest/globals' | ||
import { shallowMount } from '@vue/test-utils' | ||
import NcAppNavigationCaption from '../../../../src/components/NcAppNavigationCaption/NcAppNavigationCaption.vue' | ||
|
||
describe('NcAppNavigationCaption.vue', () => { | ||
test('attributes are passed to actions', async () => { | ||
const wrapper = shallowMount(NcAppNavigationCaption, { | ||
propsData: { | ||
name: 'The name', | ||
}, | ||
attrs: { | ||
forceMenu: 'true', | ||
}, | ||
slots: { | ||
actions: [ | ||
'<NcActionButton>Button 1</NcActionButton>', | ||
'<NcActionButton>Button 2</NcActionButton>', | ||
], | ||
}, | ||
}) | ||
|
||
expect(wrapper.findComponent({ name: 'NcActions' }).attributes('forcemenu')).toBe('true') | ||
}) | ||
|
||
test('can set id on the caption', async () => { | ||
const wrapper = shallowMount(NcAppNavigationCaption, { | ||
propsData: { | ||
name: 'The name', | ||
isHeading: true, | ||
captionId: 'my-heading-id', | ||
}, | ||
}) | ||
|
||
expect(wrapper.find('h2').attributes('id')).toBe('my-heading-id') | ||
}) | ||
|
||
test('component is a list entry by default', async () => { | ||
const wrapper = shallowMount(NcAppNavigationCaption, { | ||
propsData: { | ||
name: 'The name', | ||
}, | ||
}) | ||
|
||
expect(wrapper.element.tagName).toBe('LI') | ||
expect(wrapper.find('h2').exists()).toBe(false) | ||
expect(wrapper.find('span').exists()).toBe(true) | ||
}) | ||
|
||
test('component tags are adjusted when used as heading', async () => { | ||
const wrapper = shallowMount(NcAppNavigationCaption, { | ||
propsData: { | ||
name: 'The name', | ||
isHeading: true, | ||
}, | ||
}) | ||
|
||
expect(wrapper.element.tagName).toBe('DIV') | ||
expect(wrapper.find('h2').exists()).toBe(true) | ||
}) | ||
}) |