-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(admin-ui): write test for all Gluu custom base UI components #290
- Loading branch information
Showing
6 changed files
with
95 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) |