Skip to content

Commit

Permalink
fix(admin-ui): write test for all Gluu custom base UI components #290
Browse files Browse the repository at this point in the history
  • Loading branch information
syntrydy committed Nov 2, 2021
1 parent 6878eed commit d0f1cc2
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/routes/Apps/Gluu/GluuTypeAhead.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ function GluuTypeAhead({
formik,
required,
doc_category,
doc_entry,
}) {
const { t } = useTranslation()
return (
<GluuTooltip doc_category={doc_category} doc_entry={name}>
<GluuTooltip doc_category={doc_category} doc_entry={doc_entry || name}>
<FormGroup row>
{!!required ? (
<GluuLabel label={label} size={4} required />
Expand Down
6 changes: 5 additions & 1 deletion app/routes/Apps/Gluu/GluuTypeAheadWithAdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ function GluuTypeAheadWithAdd({
&nbsp;
<Row>
<Col sm={10}>
<Input placeholder={placeholder} id={inputId} aria-label="new_entry"/>
<Input
placeholder={placeholder}
id={inputId}
aria-label="new_entry"
/>
</Col>
<Button color="primary" type="button" onClick={addItem}>
<i className="fa fa-plus-circle mr-2"></i>
Expand Down
27 changes: 27 additions & 0 deletions app/routes/Apps/Gluu/Tests/GluuToogleRow.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import GluuToogleRow from '../GluuToogleRow'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'
const LABEL = 'fields.application_type'
const NAME = 'applicationType'
const VALUE = false
function formikf() {}

it('Test gluutooltip', () => {
render(
<I18nextProvider i18n={i18n}>
<GluuToogleRow
label={LABEL}
name={NAME}
value={VALUE}
doc_category="openid_client"
formik={formikf}
/>
</I18nextProvider>,
)
screen.getByText('The OpenID connect Client application type.')
expect(
screen.getByText('The OpenID connect Client application type.'),
).toHaveAttribute('data-id', 'tooltip')
})
30 changes: 30 additions & 0 deletions app/routes/Apps/Gluu/Tests/GluuTypeAhead.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import GluuTypeAhead from '../GluuTypeAhead'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'

const LABEL = 'fields.application_type'
let NAME = 'applicationType'
const VALUE = ['Monday']
const OPTIONS = ['Monday', 'Tuesday']

it('Test gluu typeahead', () => {
render(
<I18nextProvider i18n={i18n}>
<GluuTypeAhead
doc_category="openid_client"
name={NAME}
value={VALUE}
label={LABEL}
options={OPTIONS}
/>
</I18nextProvider>,
)
screen.getByText('Application Type:')
screen.getByText(VALUE[0])
screen.getByText('The OpenID connect Client application type.')
expect(
screen.getByText('The OpenID connect Client application type.'),
).toHaveAttribute('data-id', 'tooltip')
})
33 changes: 33 additions & 0 deletions app/routes/Apps/Gluu/Tests/GluuTypeAheadForDn.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import GluuTypeAheadForDn from '../GluuTypeAheadForDn'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'

const LABEL = 'fields.application_type'
const NAME = 'applicationType'
const VALUE = [{ name: 'Monday', dn: '111111112222' }]
const OPTIONS = [
{ name: 'Monday', dn: '111111112222' },
{ name: 'Tuesday', dn: '1001112222' },
]

it('Test gluu typeahead for dn', () => {
render(
<I18nextProvider i18n={i18n}>
<GluuTypeAheadForDn
doc_category="openid_client"
name={NAME}
value={VALUE}
label={LABEL}
options={OPTIONS}
/>
</I18nextProvider>,
)
screen.getByText('Application Type:')
screen.getByText(VALUE[0].name)
screen.getByText('The OpenID connect Client application type.')
expect(
screen.getByText('The OpenID connect Client application type.'),
).toHaveAttribute('data-id', 'tooltip')
})
2 changes: 1 addition & 1 deletion app/routes/Apps/Gluu/Tests/GluuTypeAheadWithAdd.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { I18nextProvider } from 'react-i18next'

it('Test GluuTypeAheadWithAdd component', () => {
const LABEL = 'fields.application_type'
let NAME = 'application_type'
const NAME = 'application_type'
const VALUE = ['Monday']
const OPTIONS = ['Monday', 'Tuesday']
render(
Expand Down

0 comments on commit d0f1cc2

Please sign in to comment.