-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apps/userdashboard: add test for AiReportExplanation component
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
apps/userdashboard/assets/js/a4_candy_userdashboard/__tests__/AiReportExplanation.jest.jsx
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,37 @@ | ||
import React from 'react' | ||
import { render, fireEvent, screen } from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
import { AiReportExplanation } from '../AiReportExplanation' | ||
|
||
test('Snapshot Read More <AiReportExplanation>', () => { | ||
const { container } = render( | ||
<AiReportExplanation AiReport="This is the ai report" /> | ||
) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
|
||
test('Snapshot Read Less <AiReportExplanation>', () => { | ||
const { container } = render( | ||
<AiReportExplanation AiReport="This is the ai report" /> | ||
) | ||
const button = screen.getByRole('button') | ||
fireEvent.click(button) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
|
||
test('Render <AiReportExplanation>', () => { | ||
render(<AiReportExplanation AiReport="This is the ai report" />) | ||
const comment = screen.getByText('Read more') | ||
expect(comment).toBeTruthy() | ||
}) | ||
|
||
test('Read More <AiReportExplanation>', () => { | ||
render(<AiReportExplanation AiReport="This is the ai report" />) | ||
const readMore = screen.getByText('Read more') | ||
expect(readMore).toBeTruthy() | ||
const button = screen.getByRole('button') | ||
expect(button).toBeTruthy() | ||
fireEvent.click(button) | ||
const readLess = screen.getByText('Read less') | ||
expect(readLess).toBeTruthy() | ||
}) |
48 changes: 48 additions & 0 deletions
48
...ssets/js/a4_candy_userdashboard/__tests__/__snapshots__/AiReportExplanation.jest.jsx.snap
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,48 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Snapshot Read Less <AiReportExplanation> 1`] = ` | ||
<div> | ||
<li | ||
class="alert alert--danger d-flex text-start mb-3" | ||
> | ||
<i | ||
aria-hidden="True" | ||
class="fas fa-exclamation-circle text-danger pt-1 pe-2" | ||
/> | ||
<p> | ||
This comment contains disinformation. Defakts uses an Artificial Intelligence to scan content for disinformation. Disinformation often shows certain characteristics that allow for a reliable identification. | ||
This is the ai report | ||
<button | ||
aria-label="Click to hide the AI explanation for reporting this comment." | ||
class="btn--link text-danger" | ||
type="button" | ||
> | ||
Read less | ||
</button> | ||
</p> | ||
</li> | ||
</div> | ||
`; | ||
exports[`Snapshot Read More <AiReportExplanation> 1`] = ` | ||
<div> | ||
<li | ||
class="alert alert--danger d-flex text-start mb-3" | ||
> | ||
<i | ||
aria-hidden="True" | ||
class="fas fa-exclamation-circle text-danger pt-1 pe-2" | ||
/> | ||
<p> | ||
This comment contains disinformation. Defakts uses an Artificial Intelligence to scan content for disinformation. Disinformation often shows certain characteristics that allow for a reliable identification. | ||
<button | ||
aria-label="Click to view the AI explanation for reporting this comment." | ||
class="btn--link text-danger" | ||
type="button" | ||
> | ||
Read more | ||
</button> | ||
</p> | ||
</li> | ||
</div> | ||
`; |