@@ -2,6 +2,7 @@ import React from 'react';
2
2
import '@testing-library/jest-dom' ;
3
3
import { cleanup , render , screen , RenderResult , within } from '@site/src/test-utils' ;
4
4
import Footer from '../' ;
5
+ import userEvent from '@testing-library/user-event' ;
5
6
6
7
describe ( 'HeroHeader' , ( ) => {
7
8
let render_result : RenderResult ;
@@ -25,27 +26,23 @@ describe('HeroHeader', () => {
25
26
) ;
26
27
expect ( footer_description ) . toBeInTheDocument ( ) ;
27
28
} ) ;
28
- it ( 'should render community link properly' , ( ) => {
29
- const community_link = screen . getByTestId ( 'community-link' ) ;
30
- expect ( community_link ) . toBeInTheDocument ( ) ;
31
- expect ( community_link ) . toHaveAttribute ( 'href' , 'https://deriv.vanillacommunity.com/' ) ;
32
- } ) ;
33
- it ( 'should render the button inside community link properly' , ( ) => {
34
- const community_link = screen . getByTestId ( 'community-link' ) ;
35
- const { getByRole } = within ( community_link ) ;
36
- const button = getByRole ( 'button' ) ;
37
- expect ( button ) . toHaveTextContent ( 'Join our community' ) ;
38
- } ) ;
39
- it ( 'should render telegram link properly' , ( ) => {
40
- const telegram_link = screen . getByTestId ( 'telegram-link' ) ;
41
- expect ( telegram_link ) . toBeInTheDocument ( ) ;
42
- expect ( telegram_link ) . toHaveAttribute ( 'href' , 'https://t.me/+g6FV5tFY1u9lZGE1' ) ;
43
- } ) ;
44
- it ( 'should render the button inside telegram link properly' , ( ) => {
45
- const telegram_link = screen . getByTestId ( 'telegram-link' ) ;
46
- const { getByRole } = within ( telegram_link ) ;
47
- const button = getByRole ( 'button' ) ;
48
- expect ( button ) . toHaveTextContent ( 'Telegram' ) ;
29
+ it ( 'should render community link when community button is clicked' , async ( ) => {
30
+ window . open = jest . fn ( ) ;
31
+
32
+ const communityButton = screen . getByRole ( 'button' , { name : 'Join our community' } ) ;
33
+ expect ( communityButton ) . toBeInTheDocument ( ) ;
34
+ await userEvent . click ( communityButton ) ;
35
+
36
+ expect ( window . open ) . toHaveBeenCalledWith ( 'https://deriv.vanillacommunity.com/' ) ;
37
+ } ) ;
38
+ it ( 'should render telegram link when telegram button is clicked' , async ( ) => {
39
+ window . open = jest . fn ( ) ;
40
+
41
+ const telegramButton = screen . getByRole ( 'button' , { name : 'Telegram' } ) ;
42
+ expect ( telegramButton ) . toBeInTheDocument ( ) ;
43
+ await userEvent . click ( telegramButton ) ;
44
+
45
+ expect ( window . open ) . toHaveBeenCalledWith ( 'https://t.me/+g6FV5tFY1u9lZGE1' ) ;
49
46
} ) ;
50
47
it ( 'should render footer body texts properly' , ( ) => {
51
48
const help_text = screen . getByText ( / ^ w e ' r e h e r e t o h e l p $ / i) ;
0 commit comments