-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
- Loading branch information
Showing
2 changed files
with
135 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { describe, expect, it } from '@jest/globals' | ||
import { mount } from '@vue/test-utils' | ||
import NcAppContent from '../../../../src/components/NcAppContent/NcAppContent.vue' | ||
|
||
describe('NcAppContent', () => { | ||
beforeEach(() => { | ||
document.title = 'Initial title' | ||
}) | ||
|
||
it('does not set a page heading by default', () => { | ||
const wrapper = mount(NcAppContent) | ||
|
||
expect(wrapper.find('h1').exists()).toBe(false) | ||
}) | ||
|
||
it('can set the page heading', () => { | ||
const wrapper = mount(NcAppContent, { | ||
propsData: { | ||
pageHeading: 'My heading', | ||
}, | ||
}) | ||
|
||
expect(wrapper.find('h1').text()).toBe('My heading') | ||
}) | ||
|
||
it('does not set the document title without page heading', () => { | ||
mount(NcAppContent) | ||
|
||
expect(document.title).toBe('Initial title') | ||
}) | ||
|
||
it('sets the document title if a heading is provided', () => { | ||
mount(NcAppContent, { | ||
propsData: { | ||
pageHeading: 'My heading', | ||
}, | ||
}) | ||
|
||
expect(document.title).toBe('My heading - nextcloud-vue - Nextcloud') | ||
}) | ||
|
||
it('does not duplicate the heading in the document title', () => { | ||
mount(NcAppContent, { | ||
propsData: { | ||
pageHeading: 'nextcloud-vue', | ||
}, | ||
}) | ||
|
||
expect(document.title).toBe('nextcloud-vue - Nextcloud') | ||
}) | ||
|
||
it('sets the document title if pageTitle is provided', () => { | ||
mount(NcAppContent, { | ||
propsData: { | ||
pageTitle: 'My title', | ||
}, | ||
}) | ||
|
||
expect(document.title).toBe('My title - nextcloud-vue - Nextcloud') | ||
}) | ||
|
||
it('does not duplicate the title in the document title', () => { | ||
mount(NcAppContent, { | ||
propsData: { | ||
pageTitle: 'nextcloud-vue', | ||
}, | ||
}) | ||
|
||
expect(document.title).toBe('nextcloud-vue - Nextcloud') | ||
}) | ||
|
||
it('sets the document title if pageTitle and pageHeading are provided', () => { | ||
mount(NcAppContent, { | ||
propsData: { | ||
pageHeading: 'My heading', | ||
pageTitle: 'My title', | ||
}, | ||
}) | ||
|
||
expect(document.title).toBe('My title - My heading - Nextcloud') | ||
}) | ||
}) |