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_index.test.jsx
84 lines (72 loc) · 3.23 KB
/
admin_console_index.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {createIntl} from 'react-intl';
import AdminDefinition from 'components/admin_console/admin_definition.jsx';
import {samplePlugin1, samplePlugin2} from 'tests/helpers/admin_console_plugin_index_sample_pluings';
import {generateIndex} from './admin_console_index.jsx';
const enMessages = require('../i18n/en');
const esMessages = require('../i18n/es');
describe('AdminConsoleIndex.generateIndex', () => {
it('should generate an index where I can search', () => {
const intl = createIntl({locale: 'en', messages: enMessages, defaultLocale: 'en'}, {});
const idx = generateIndex(AdminDefinition, {}, intl);
expect(idx.search('ldap')).toEqual([
'environment/session_lengths',
'authentication/mfa',
'authentication/ldap',
'authentication/saml',
'experimental/features',
'authentication/email',
'authentication/guest_access',
]);
expect(idx.search('saml')).toEqual([
'authentication/saml',
'environment/session_lengths',
'authentication/email',
'experimental/features',
]);
expect(idx.search('nginx')).toEqual([
'environment/rate_limiting',
]);
expect(idx.search('characters')).toEqual([
'authentication/password',
'site_config/customization',
]);
expect(idx.search('caracteres')).toEqual([]);
expect(idx.search('notexistingword')).toEqual([]);
});
it('should generate a index where I can search in other language', () => {
const intl = createIntl({locale: 'es', messages: esMessages, defaultLocale: 'es'}, {});
const idx = generateIndex(AdminDefinition, {}, intl);
expect(idx.search('ldap').sort()).toEqual([
'authentication/mfa',
'authentication/ldap',
'authentication/saml',
'experimental/features',
'authentication/email',
'environment/session_lengths',
'authentication/guest_access',
].sort());
expect(idx.search('saml').sort()).toEqual([
'authentication/saml',
'environment/session_lengths',
'authentication/email',
'experimental/features',
].sort());
expect(idx.search('nginx')).toEqual([
'environment/rate_limiting',
]);
expect(idx.search('caracteres').sort()).toEqual([
'site_config/customization',
'authentication/password',
].sort());
expect(idx.search('characters')).toEqual([]);
expect(idx.search('notexistingword')).toEqual([]);
});
it('should generate a index including the plugin settings', () => {
const intl = createIntl({locale: 'en', messages: enMessages, defaultLocale: 'en'}, {});
const idx = generateIndex(AdminDefinition, {[samplePlugin1.id]: samplePlugin1, [samplePlugin2.id]: samplePlugin2}, intl);
expect(idx.search('random')).toEqual(['plugin_Some-random-plugin', 'site_config/public_links']);
expect(idx.search('autolink')).toEqual(['plugin_mattermost-autolink']);
});
});