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 Oct 28, 2021
1 parent df9c3e1 commit 06e7bd2
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/routes/Apps/Gluu/GluuInumInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Col, FormGroup, Input } from '../../../components'
import GluuLabel from './GluuLabel'
import GluuTooltip from './GluuTooltip'

function GluuInumInput({ label, name, value, lsize,rsize, doc_category }) {
function GluuInumInput({ label, name, value, lsize, rsize, doc_category }) {
return (
<GluuTooltip doc_category={doc_category} doc_entry={name}>
<FormGroup row>
Expand Down
2 changes: 1 addition & 1 deletion app/routes/Apps/Gluu/GluuToogleRow.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Col, FormGroup, Input } from '../../../components'
import { Col, FormGroup} from '../../../components'
import GluuLabel from './GluuLabel'
import GluuTooltip from './GluuTooltip'
import GluuToogle from './GluuToogle'
Expand Down
65 changes: 65 additions & 0 deletions app/routes/Apps/Gluu/Tests/GluuInlineInput.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React from 'react'
import { render, screen, fireEvent } from '@testing-library/react'
import GluuInlineInput from '../GluuInlineInput'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'

let LABEL = 'fields.application_type'
let NAME = 'application_type'
let VALUE = true

it('Should render a boolean select box', () => {
function handler() {}
render(
<I18nextProvider i18n={i18n}>
<GluuInlineInput
label={LABEL}
value={VALUE}
name={NAME}
isBoolean
handler={handler}
/>
</I18nextProvider>,
)
screen.getByText('Application Type:')
fireEvent.click(screen.getByText(VALUE))
fireEvent.click(screen.getByText(false))
})

it('Should render a typeahead component with array', () => {
const VALUE = ['Two']
const options = ['One', 'Two', 'Three']
function handler() {}
render(
<I18nextProvider i18n={i18n}>
<GluuInlineInput
label={LABEL}
value={VALUE}
name={NAME}
options={options}
isArray
handler={handler}
/>
</I18nextProvider>,
)
screen.getByText('Application Type:')
fireEvent.click(screen.getByText(VALUE))
})


it('Should render a text input', () => {
const VALUE = "Client Secret"
function handler() {}
render(
<I18nextProvider i18n={i18n}>
<GluuInlineInput
label={LABEL}
value={VALUE}
name={NAME}
handler={handler}
/>
</I18nextProvider>,
)
screen.getByText('Application Type:')
expect(screen.getByDisplayValue(VALUE).id).toBe(NAME)
})
4 changes: 2 additions & 2 deletions app/routes/Apps/Gluu/Tests/GluuInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import GluuInput from '../GluuInput'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'

it('Should show the input with proper text', () => {
it('Should show input text', () => {
const LABEL = 'fields.application_type'
const NAME = 'application_type'
const VALUE = 'Public'
render(
<I18nextProvider i18n={i18n}>
<GluuInput label={LABEL} value={VALUE} name={NAME} />
<GluuInput label={LABEL} value={VALUE} name={NAME}/>
</I18nextProvider>,
)
screen.getByText('Application Type:')
Expand Down
1 change: 0 additions & 1 deletion app/routes/Apps/Gluu/Tests/GluuInputRow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { render, screen } from '@testing-library/react'
import GluuInputRow from '../GluuInputRow'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'
import { Formik } from 'formik'

it('Should show the input with proper text', () => {
const LABEL = 'fields.application_type'
Expand Down
26 changes: 26 additions & 0 deletions app/routes/Apps/Gluu/Tests/GluuInumInput.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import GluuInumInput from '../GluuInumInput'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'

it('Should show the disabled input with proper text wit sa', () => {
const LABEL = 'fields.application_type'
const NAME = 'application_type'
const VALUE = 'Public'
function handler() {}
render(
<I18nextProvider i18n={i18n}>
<GluuInumInput
label={LABEL}
value={VALUE}
name={NAME}
handler={handler}
formik={handler}
/>
</I18nextProvider>,
)
screen.getByText('Application Type:')
expect(screen.getByDisplayValue(VALUE).id).toBe(NAME)
expect(screen.getByDisplayValue(VALUE)).toBeDisabled
})

0 comments on commit 06e7bd2

Please sign in to comment.