forked from openshift/console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ldap-idp-form.spec.tsx
56 lines (48 loc) · 2.16 KB
/
ldap-idp-form.spec.tsx
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
import * as React from 'react';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom-v5-compat';
import store from '@console/internal/redux';
import { ListInput } from '../../../public/components/utils';
import { IDPNameInput } from '../../../public/components/cluster-settings/idp-name-input';
import { IDPCAFileInput } from '../../../public/components/cluster-settings/idp-cafile-input';
import { AddLDAPPage } from '../../../public/components/cluster-settings/ldap-idp-form';
import { controlButtonTest } from './basicauth-idp-form.spec';
describe('Add Identity Provider: LDAP', () => {
let wrapper;
beforeEach(() => {
wrapper = mount(
<Provider store={store}>
<BrowserRouter>
<AddLDAPPage />
</BrowserRouter>
</Provider>,
);
});
it('should render AddLDAPPage component', () => {
expect(wrapper.exists()).toBe(true);
});
it('should render correct LDAP IDP page title', () => {
expect(wrapper.contains('Add Identity Provider: LDAP')).toBeTruthy();
});
it('should render the form elements of AddLDAPPage component', () => {
expect(wrapper.find(IDPNameInput).exists()).toBe(true);
expect(wrapper.find(IDPCAFileInput).exists()).toBe(true);
expect(wrapper.find('input[id="url"]').exists()).toBe(true);
expect(wrapper.find('input[id="bind-dn"]').exists()).toBe(true);
expect(wrapper.find('input[id="bind-password"]').exists()).toBe(true);
expect(wrapper.find(ListInput).length).toEqual(4);
});
it('should render control buttons in a button bar', () => {
controlButtonTest(wrapper);
});
it('should prefill ldap in name field by default', () => {
expect(wrapper.find(IDPNameInput).props().value).toEqual('ldap');
});
it('should prefill ldap attribute list input default values', () => {
expect(wrapper.find(ListInput).at(0).props().initialValues).toEqual(['dn']);
expect(wrapper.find(ListInput).at(1).props().initialValues).toEqual(['uid']);
expect(wrapper.find(ListInput).at(2).props().initialValues).toEqual(['cn']);
expect(wrapper.find(ListInput).at(3).props().initialValues).toEqual(undefined);
});
});