This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
admin_console.test.jsx
57 lines (51 loc) · 2.06 KB
/
admin_console.test.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import AdminDefinition from 'components/admin_console/admin_definition.jsx';
import {getAdminDefinition} from 'selectors/admin_console.jsx';
describe('Selectors.AdminConsole', () => {
describe('get admin definitions', () => {
it('should return the default admin definition if there is not plugins', () => {
const state = {plugins: {adminConsoleReducers: {}}};
expect(getAdminDefinition(state)).toEqual(AdminDefinition);
});
it('should allow to remove everything with a plugin', () => {
const result = getAdminDefinition({
plugins: {
adminConsoleReducers: {clean: () => ({})},
},
});
expect(result).toEqual({});
});
it('should allow to add a value to the existing definition', () => {
const result = getAdminDefinition({
plugins: {
adminConsoleReducers: {
'add-something': (data) => {
data.something = 'test';
return data;
},
},
},
});
expect(result.something).toEqual('test');
});
it('should allow to use multiple plugins', () => {
const result = getAdminDefinition({
plugins: {
adminConsoleReducers: {
'add-something': (data) => {
data.something = 'test';
return data;
},
'add-other-thing': (data) => {
data.otherThing = 'other-thing';
return data;
},
},
},
});
expect(result.something).toEqual('test');
expect(result.otherThing).toEqual('other-thing');
});
});
});