Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
chore: fix test and css issue
Browse files Browse the repository at this point in the history
  • Loading branch information
shafin-deriv committed Apr 22, 2024
1 parent 299a9f9 commit 0eb3a26
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 17 additions & 7 deletions src/features/Home/GetStarted/__tests__/GetStarted.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { cleanup, render, screen } from '@site/src/test-utils';
import { GetStarted } from '../GetStarted';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import { act, renderHook } from '@testing-library/react-hooks';

describe('GetStarted', () => {
beforeEach(() => {
Expand All @@ -13,19 +15,27 @@ describe('GetStarted', () => {
const get_started = screen.getByTestId('started-header');
expect(get_started).toBeInTheDocument();
});
it('should render title properly', () => {
const started_header = screen.getByRole('heading', { level: 2, name: /Get started with/ });
expect(started_header).toHaveTextContent('Get started with our API in 3 simple steps:');
});
it('should navigate to the correct links on click', () => {

it('should navigate to the correct links on click when language is portuguese', () => {
const { result } = renderHook(() => useDocusaurusContext());

let local: string;
act(() => {
local = result.current.i18n.currentLocale;
});
const lang = local === 'en' ? '' : `/${local}`;

expect(screen.getByTestId('signUp').closest('a')).toHaveAttribute(
'href',
'https://deriv.com/signup/',
);
expect(screen.getByTestId('register').closest('a')).toHaveAttribute('href', '/dashboard');
expect(screen.getByTestId('register').closest('a')).toHaveAttribute(
'href',
`${lang}/dashboard`,
);
expect(screen.getByTestId('guide').closest('a')).toHaveAttribute(
'href',
'/docs/category/guides',
`${lang}/docs/category/guides`,
);
});
});
2 changes: 1 addition & 1 deletion src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ div[class*='sidebarViewport'] {
.search-overlay {
display: none;
}
&.search-closed + div[class*='searchBox'] {
&.search-closed ~ div[class*='searchBox'] {
display: none;
}
&.search-open {
Expand Down

0 comments on commit 0eb3a26

Please sign in to comment.