11import React from 'react' ;
22import { cleanup , render , screen } from '@site/src/test-utils' ;
33import { GetStarted } from '../GetStarted' ;
4+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext' ;
5+ import { act , renderHook } from '@testing-library/react-hooks' ;
46
57describe ( '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 : / G e t s t a r t e d w i t h / } ) ;
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