Skip to content

Commit 79541c6

Browse files
authored
Merge pull request #8271 from nextcloud-libraries/fix/app-name-stable8
[stable8] fix(NcContent): provide `appName` to children
2 parents d440bbf + 05a93e0 commit 79541c6

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

src/components/NcContent/NcContent.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export default {
112112
113113
provide() {
114114
return {
115+
appName: this.appName,
115116
'NcContent:setHasAppNavigation': this.setAppNavigation,
116117
'NcContent:selector': '#content-vue',
117118
}

tests/unit/utils/appName.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*!
2+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { describe, expect, it } from '@jest/globals'
7+
import { mount } from '@vue/test-utils'
8+
import { defineComponent } from 'vue'
9+
import NcContent from '../../../src/components/NcContent/NcContent.vue'
10+
import { useAppName } from '../../../src/utils/appName.ts'
11+
12+
const TestComponent = defineComponent({
13+
template: '<div>{{ appName }}</div>',
14+
setup() {
15+
return { appName: useAppName() }
16+
},
17+
})
18+
19+
const WrappedTestComponent = defineComponent({
20+
template: '<NcContent app-name="custom_app"><TestComponent /></NcContent>',
21+
components: { NcContent, TestComponent },
22+
})
23+
24+
describe('useAppName', () => {
25+
it('should return the fallback app name', () => {
26+
const wrapper = mount(TestComponent)
27+
expect(wrapper.text()).toBe('nextcloud-vue')
28+
})
29+
30+
it('should return the app name injected by NcContent', () => {
31+
const wrapper = mount(WrappedTestComponent)
32+
expect(wrapper.text()).toBe('custom_app')
33+
})
34+
})

0 commit comments

Comments
 (0)