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

Commit 32bb5fd

Browse files
test: modified testcase for diff language case
1 parent 7cf6c5c commit 32bb5fd

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed
Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22
import { cleanup, render, screen } from '@site/src/test-utils';
33
import { GetStarted } from '../GetStarted';
4+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
5+
import { act, renderHook } from '@testing-library/react-hooks';
46

57
describe('GetStarted', () => {
68
beforeEach(() => {
@@ -13,19 +15,27 @@ describe('GetStarted', () => {
1315
const get_started = screen.getByTestId('started-header');
1416
expect(get_started).toBeInTheDocument();
1517
});
16-
it('should render title properly', () => {
17-
const started_header = screen.getByRole('heading', { level: 2, name: /Get started with/ });
18-
expect(started_header).toHaveTextContent('Get started with our API in 3 simple steps:');
19-
});
20-
it('should navigate to the correct links on click', () => {
18+
19+
it('should navigate to the correct links on click when language is portuguese', () => {
20+
const { result } = renderHook(() => useDocusaurusContext());
21+
22+
let local: string;
23+
act(() => {
24+
local = result.current.i18n.currentLocale;
25+
});
26+
const lang = local === 'en' ? '' : `/${local}`;
27+
2128
expect(screen.getByTestId('signUp').closest('a')).toHaveAttribute(
2229
'href',
2330
'https://deriv.com/signup/',
2431
);
25-
expect(screen.getByTestId('register').closest('a')).toHaveAttribute('href', '/pr/dashboard');
32+
expect(screen.getByTestId('register').closest('a')).toHaveAttribute(
33+
'href',
34+
`${lang}/dashboard`,
35+
);
2636
expect(screen.getByTestId('guide').closest('a')).toHaveAttribute(
2737
'href',
28-
'/pr/docs/category/guides',
38+
`${lang}/docs/category/guides`,
2939
);
3040
});
3141
});

0 commit comments

Comments
 (0)