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 1, 2021
1 parent 9c18d31 commit 72a59af
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@
"licenseDetails": "License Details"
},
"languages": {
"french": "Français",
"french": "French",
"english": "English",
"portuguese": "Português"
"portuguese": "Portuguese"
},
"menus": {
"adminui": "Admin",
Expand Down
2 changes: 1 addition & 1 deletion app/routes/Apps/Gluu/GluuTypeAheadWithAdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function GluuTypeAheadWithAdd({
 
<Row>
<Col sm={10}>
<Input placeholder={placeholder} id={inputId} />
<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/GluuTypeAheadWithAdd.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'
import GluuTypeAheadWithAdd from '../GluuTypeAheadWithAdd'
import { render, screen, fireEvent } from '@testing-library/react'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'

it('Test GluuTypeAheadWithAdd component', () => {
const LABEL = 'fields.application_type'
let NAME = 'application_type'
const VALUE = ['Monday']
const OPTIONS = ['Monday', 'Tuesday']
render(
<I18nextProvider i18n={i18n}>
<GluuTypeAheadWithAdd
doc_category="openid_client"
name={NAME}
value={VALUE}
label={LABEL}
options={OPTIONS}
/>
</I18nextProvider>,
)
screen.getByText('Application Type:')
screen.getByText('Add')
screen.getByText('Remove')
screen.getByText(VALUE[0])
})
26 changes: 26 additions & 0 deletions app/routes/Apps/Gluu/Tests/GluuViewWrapper.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react'
import GluuViewWrapper from '../GluuViewWrapper'
import { render, screen } from '@testing-library/react'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'

it('Check view wrapper with show', () => {
let componentText = 'the wrapped component'
render(
<I18nextProvider i18n={i18n}>
<GluuViewWrapper canShow>
<p>{componentText}</p>
</GluuViewWrapper>
</I18nextProvider>,
)
screen.getByText(componentText)
})

it('Check view wrapper with no show', () => {
render(
<I18nextProvider i18n={i18n}>
<GluuViewWrapper />
</I18nextProvider>,
)
screen.getByText('Missing required permission')
})
17 changes: 17 additions & 0 deletions app/routes/Apps/Gluu/Tests/LanguageMenu.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import {LanguageMenu} from '../LanguageMenu'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'

it('All supported languages will be visible', () => {
render(
<I18nextProvider i18n={i18n}>
<LanguageMenu />
</I18nextProvider>,
)
screen.getByText('en')
screen.getByText('French')
screen.getByText('English')
screen.getByText('Portuguese')
})

0 comments on commit 72a59af

Please sign in to comment.