Skip to content

Commit

Permalink
test: add test case for journal-loader.tsx (deriv-com#10843)
Browse files Browse the repository at this point in the history
  • Loading branch information
maryia-matskevich-deriv authored Oct 23, 2023
1 parent 0c048d2 commit 1c29a26
Showing 1 changed file with 35 additions and 0 deletions.
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)');
});
});

0 comments on commit 1c29a26

Please sign in to comment.