-
Notifications
You must be signed in to change notification settings - Fork 437
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: Grigorii K. Shartsev <[email protected]>
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
import { jest, describe, it, expect } from '@jest/globals' | ||
|
||
import { emit } from '@nextcloud/event-bus' | ||
|
||
import { SettingsAPI, useCustomSettings } from '../SettingsAPI.ts' | ||
|
||
jest.mock('@nextcloud/event-bus') | ||
|
||
describe('SettingsAPI', () => { | ||
it('should have open method to open settings', () => { | ||
expect(SettingsAPI.open).toBeDefined() | ||
SettingsAPI.open() | ||
// Currently, a global event is used to open the settings | ||
expect(emit).toHaveBeenCalledWith('show-settings', undefined) | ||
}) | ||
|
||
it('should have registerSection method to register settings sections', () => { | ||
const { customSettingsSections } = useCustomSettings() | ||
expect(customSettingsSections).toEqual([]) | ||
expect(SettingsAPI.registerSection).toBeDefined() | ||
SettingsAPI.registerSection({ | ||
id: 'test', | ||
name: 'Test', | ||
element: 'test-element', | ||
}) | ||
SettingsAPI.registerSection({ | ||
id: 'test2', | ||
name: 'Test 2', | ||
element: 'test-element-two', | ||
}) | ||
expect(customSettingsSections).toEqual([{ | ||
id: 'test', | ||
name: 'Test', | ||
element: 'test-element', | ||
}, { | ||
id: 'test2', | ||
name: 'Test 2', | ||
element: 'test-element-two', | ||
}]) | ||
}) | ||
|
||
it('should have unregisterSection method to unregister settings sections', () => { | ||
const { customSettingsSections } = useCustomSettings() | ||
expect(customSettingsSections).toEqual([{ | ||
id: 'test', | ||
name: 'Test', | ||
element: 'test-element', | ||
}, { | ||
id: 'test2', | ||
name: 'Test 2', | ||
element: 'test-element-two', | ||
}]) | ||
expect(SettingsAPI.unregisterSection).toBeDefined() | ||
SettingsAPI.unregisterSection('test') | ||
expect(customSettingsSections).toEqual([{ | ||
id: 'test2', | ||
name: 'Test 2', | ||
element: 'test-element-two', | ||
}]) | ||
}) | ||
}) |