Skip to content

Commit d0f1cc2

Browse files
committed
fix(admin-ui): write test for all Gluu custom base UI components #290
1 parent 6878eed commit d0f1cc2

6 files changed

+98
-3
lines changed

app/routes/Apps/Gluu/GluuTypeAhead.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ function GluuTypeAhead({
2323
formik,
2424
required,
2525
doc_category,
26+
doc_entry,
2627
}) {
2728
const { t } = useTranslation()
2829
return (
29-
<GluuTooltip doc_category={doc_category} doc_entry={name}>
30+
<GluuTooltip doc_category={doc_category} doc_entry={doc_entry || name}>
3031
<FormGroup row>
3132
{!!required ? (
3233
<GluuLabel label={label} size={4} required />

app/routes/Apps/Gluu/GluuTypeAheadWithAdd.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ function GluuTypeAheadWithAdd({
5252
&nbsp;
5353
<Row>
5454
<Col sm={10}>
55-
<Input placeholder={placeholder} id={inputId} aria-label="new_entry"/>
55+
<Input
56+
placeholder={placeholder}
57+
id={inputId}
58+
aria-label="new_entry"
59+
/>
5660
</Col>
5761
<Button color="primary" type="button" onClick={addItem}>
5862
<i className="fa fa-plus-circle mr-2"></i>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react'
2+
import { render, screen } from '@testing-library/react'
3+
import GluuToogleRow from '../GluuToogleRow'
4+
import i18n from '../../../../i18n'
5+
import { I18nextProvider } from 'react-i18next'
6+
const LABEL = 'fields.application_type'
7+
const NAME = 'applicationType'
8+
const VALUE = false
9+
function formikf() {}
10+
11+
it('Test gluutooltip', () => {
12+
render(
13+
<I18nextProvider i18n={i18n}>
14+
<GluuToogleRow
15+
label={LABEL}
16+
name={NAME}
17+
value={VALUE}
18+
doc_category="openid_client"
19+
formik={formikf}
20+
/>
21+
</I18nextProvider>,
22+
)
23+
screen.getByText('The OpenID connect Client application type.')
24+
expect(
25+
screen.getByText('The OpenID connect Client application type.'),
26+
).toHaveAttribute('data-id', 'tooltip')
27+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react'
2+
import { render, screen } from '@testing-library/react'
3+
import GluuTypeAhead from '../GluuTypeAhead'
4+
import i18n from '../../../../i18n'
5+
import { I18nextProvider } from 'react-i18next'
6+
7+
const LABEL = 'fields.application_type'
8+
let NAME = 'applicationType'
9+
const VALUE = ['Monday']
10+
const OPTIONS = ['Monday', 'Tuesday']
11+
12+
it('Test gluu typeahead', () => {
13+
render(
14+
<I18nextProvider i18n={i18n}>
15+
<GluuTypeAhead
16+
doc_category="openid_client"
17+
name={NAME}
18+
value={VALUE}
19+
label={LABEL}
20+
options={OPTIONS}
21+
/>
22+
</I18nextProvider>,
23+
)
24+
screen.getByText('Application Type:')
25+
screen.getByText(VALUE[0])
26+
screen.getByText('The OpenID connect Client application type.')
27+
expect(
28+
screen.getByText('The OpenID connect Client application type.'),
29+
).toHaveAttribute('data-id', 'tooltip')
30+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react'
2+
import { render, screen } from '@testing-library/react'
3+
import GluuTypeAheadForDn from '../GluuTypeAheadForDn'
4+
import i18n from '../../../../i18n'
5+
import { I18nextProvider } from 'react-i18next'
6+
7+
const LABEL = 'fields.application_type'
8+
const NAME = 'applicationType'
9+
const VALUE = [{ name: 'Monday', dn: '111111112222' }]
10+
const OPTIONS = [
11+
{ name: 'Monday', dn: '111111112222' },
12+
{ name: 'Tuesday', dn: '1001112222' },
13+
]
14+
15+
it('Test gluu typeahead for dn', () => {
16+
render(
17+
<I18nextProvider i18n={i18n}>
18+
<GluuTypeAheadForDn
19+
doc_category="openid_client"
20+
name={NAME}
21+
value={VALUE}
22+
label={LABEL}
23+
options={OPTIONS}
24+
/>
25+
</I18nextProvider>,
26+
)
27+
screen.getByText('Application Type:')
28+
screen.getByText(VALUE[0].name)
29+
screen.getByText('The OpenID connect Client application type.')
30+
expect(
31+
screen.getByText('The OpenID connect Client application type.'),
32+
).toHaveAttribute('data-id', 'tooltip')
33+
})

app/routes/Apps/Gluu/Tests/GluuTypeAheadWithAdd.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { I18nextProvider } from 'react-i18next'
66

77
it('Test GluuTypeAheadWithAdd component', () => {
88
const LABEL = 'fields.application_type'
9-
let NAME = 'application_type'
9+
const NAME = 'application_type'
1010
const VALUE = ['Monday']
1111
const OPTIONS = ['Monday', 'Tuesday']
1212
render(

0 commit comments

Comments
 (0)