@@ -2,6 +2,7 @@ import React from 'react';
22import '@testing-library/jest-dom' ;
33import { cleanup , render , screen , RenderResult , within } from '@site/src/test-utils' ;
44import Footer from '../' ;
5+ import userEvent from '@testing-library/user-event' ;
56
67describe ( 'HeroHeader' , ( ) => {
78 let render_result : RenderResult ;
@@ -25,27 +26,23 @@ describe('HeroHeader', () => {
2526 ) ;
2627 expect ( footer_description ) . toBeInTheDocument ( ) ;
2728 } ) ;
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' ) ;
4946 } ) ;
5047 it ( 'should render footer body texts properly' , ( ) => {
5148 const help_text = screen . getByText ( / ^ w e ' r e h e r e t o h e l p $ / i) ;
0 commit comments