Skip to content

Commit

Permalink
chore: added reused strings into variables
Browse files Browse the repository at this point in the history
  • Loading branch information
farabi-deriv committed Aug 27, 2024
1 parent 73bd9d2 commit fa7f365
Showing 1 changed file with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ jest.mock('@deriv/bot-skeleton/src/scratch/hooks/block_svg', () => jest.fn());

jest.useFakeTimers();

const what_is_deriv_bot = 'What is Deriv Bot?';
const deriv_bot_content =
"Deriv Bot is a web-based strategy builder for trading digital options. It’s a platform where you can build your own automated trading bot using drag-and-drop 'blocks'.";

describe('<FAQContent />', () => {
let wrapper: ({ children }: { children: JSX.Element }) => JSX.Element;
const mock_store = mockStore({});
Expand All @@ -37,22 +41,22 @@ describe('<FAQContent />', () => {
render(<FAQContent faq_list={faq_content} />, { wrapper });
const accordion = screen.getByTestId('dt_accordion_test');
userEvent.click(accordion);
expect(accordion).toHaveTextContent('Deriv Bot is a web-based strategy builder for trading digital options.');
expect(accordion).toHaveTextContent(deriv_bot_content);
});

it('should show faq content in text size-s on desktop', () => {
mock_store.ui.is_desktop = true;

render(<FAQContent faq_list={faq_content} />, { wrapper });
const faq = screen.getByText('What is Deriv Bot?');
const faq = screen.getByText(what_is_deriv_bot);
expect(faq).toHaveStyle('--text-size: var(--text-size-s);');
});

it('should show faq content in text size-xs on mobile', () => {
mock_store.ui.is_desktop = false;

render(<FAQContent faq_list={faq_content} />, { wrapper });
const faq = screen.getByText('What is Deriv Bot?');
const faq = screen.getByText(what_is_deriv_bot);
expect(faq).toHaveStyle('--text-size: var(--text-size-xs);');
});

Expand All @@ -63,14 +67,10 @@ describe('<FAQContent />', () => {
const accordion = screen.getByTestId('dt_accordion_test');
expect(accordion).toBeInTheDocument();

const faq = screen.getByText('What is Deriv Bot?');
const faq = screen.getByText(what_is_deriv_bot);
userEvent.click(faq);
jest.advanceTimersByTime(5);
expect(
screen.getByText(
"Deriv Bot is a web-based strategy builder for trading digital options. It’s a platform where you can build your own automated trading bot using drag-and-drop 'blocks'."
)
).toBeInTheDocument();
expect(screen.getByText(deriv_bot_content)).toBeInTheDocument();
});

it('should call handleAccordionOpen and accordion item should open on mobile', () => {
Expand All @@ -80,14 +80,10 @@ describe('<FAQContent />', () => {
const accordion = screen.getByTestId('dt_accordion_test');
expect(accordion).toBeInTheDocument();

const faq = screen.getByText('What is Deriv Bot?');
const faq = screen.getByText(what_is_deriv_bot);
userEvent.click(faq);
jest.advanceTimersByTime(5);
expect(
screen.getByText(
"Deriv Bot is a web-based strategy builder for trading digital options. It’s a platform where you can build your own automated trading bot using drag-and-drop 'blocks'."
)
).toBeInTheDocument();
expect(screen.getByText(deriv_bot_content)).toBeInTheDocument();
});

it('should call handleAccordionOpen and accordion item should close', () => {
Expand All @@ -98,6 +94,6 @@ describe('<FAQContent />', () => {

userEvent.click(accordion);
jest.advanceTimersByTime(5);
expect(screen.getByText('What is Deriv Bot?')).toBeInTheDocument();
expect(screen.getByText(what_is_deriv_bot)).toBeInTheDocument();
});
});

0 comments on commit fa7f365

Please sign in to comment.