forked from deriv-com/deriv-app
-
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.
test: add test case for journal-loader.tsx (deriv-com#10843)
- Loading branch information
1 parent
0c048d2
commit 1c29a26
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...es/bot-web-ui/src/components/journal/journal-components/__tests__/journal-loader.spec.tsx
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,35 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import JournalLoader from '../journal-loader'; | ||
|
||
jest.mock('react-content-loader', () => { | ||
return jest.fn(({ children, ...props }: { children: React.ReactElement; is_mobile: boolean }) => ( | ||
<div data-testid='mock-content-loader' {...props}> | ||
{children} | ||
</div> | ||
)); | ||
}); | ||
|
||
describe('JournalLoader', () => { | ||
it('Renders correctly for desktop', () => { | ||
render(<JournalLoader is_mobile={false} />); | ||
|
||
const journal_loader = screen.getByTestId('mock-content-loader'); | ||
|
||
expect(journal_loader).toBeInTheDocument(); | ||
expect(journal_loader).not.toHaveClass('journal__loader--mobile'); | ||
}); | ||
|
||
it('Renders correctly for mobile with given props', () => { | ||
render(<JournalLoader is_mobile={true} />); | ||
|
||
const journal_loader = screen.getByTestId('mock-content-loader'); | ||
|
||
expect(journal_loader).toBeInTheDocument(); | ||
|
||
expect(journal_loader).toHaveClass('journal__loader--mobile'); | ||
expect(journal_loader).toHaveAttribute('backgroundcolor', 'var(--general-section-1)'); | ||
expect(journal_loader).toHaveAttribute('foregroundcolor', 'var(--general-hover)'); | ||
}); | ||
}); |