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 72a59af commit 6878eed
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions __tests__/setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
jest.spyOn(global.console, 'log').mockImplementation(jest.fn());
jest.spyOn(global.console, 'warn').mockImplementation(jest.fn());
import '@testing-library/jest-dom'

it('Jans-admin UI test setup', () => {
})
7 changes: 1 addition & 6 deletions app/routes/Apps/Gluu/GluuTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ function GluuTooltip(props) {
return (
<div data-tip data-for={props.doc_entry}>
{props.children}
<ReactTooltip
html={true}
type="success"
id={props.doc_entry}
place="bottom"
>
<ReactTooltip html type="success" id={props.doc_entry} place="bottom">
{t('documentation.' + props.doc_category + '.' + props.doc_entry)}
</ReactTooltip>
</div>
Expand Down
20 changes: 20 additions & 0 deletions app/routes/Apps/Gluu/Tests/GluuTooltip.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import GluuTooltip from '../GluuTooltip'
import i18n from '../../../../i18n'
import { I18nextProvider } from 'react-i18next'

it('Test gluutooltip', () => {
render(
<I18nextProvider i18n={i18n}>
<GluuTooltip doc_category="openid_client" doc_entry="applicationType">
<p>A custom component</p>
</GluuTooltip>
</I18nextProvider>,
)
screen.getByText('A custom component')
screen.getByText('The OpenID connect Client application type.')
expect(
screen.getByText('The OpenID connect Client application type.'),
).toHaveAttribute('data-id', 'tooltip')
})

0 comments on commit 6878eed

Please sign in to comment.