Skip to content

Commit e6a8f11

Browse files
authored
Merge pull request #39 from oslabs-beta/raisa-tests
added testing and data-testid attributes to allow for easier testing
2 parents 4e90868 + 016fda8 commit e6a8f11

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

lib/__tests__/react-test/VideoCall.unit.test.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/** @jest-environment jsdom */
2+
/* eslint-disable @typescript-eslint/no-unused-vars */
23

34
import React from 'react';
4-
import { render, screen, fireEvent } from '@testing-library/react';
5+
import { render, screen, fireEvent, cleanup } from '@testing-library/react';
56
import VideoCall from '../../src/components/VideoCall';
67

78
describe('VideoCall', () => {
@@ -13,13 +14,22 @@ describe('VideoCall', () => {
1314
height: '480px'
1415
}
1516
};
16-
1717
const { container } = render(<VideoCall URL={Url} mediaOptions={options}/>);
1818

19-
it('Check Submit Username button', () => {
19+
it('Check buttons in VideoCall.tsx', () => {
2020

2121
const submitBtn = screen.getByTestId('submit-username-btn');
2222
expect(submitBtn.innerHTML).toBe('Submit Username');
23+
24+
const shareBtn = screen.getByTestId('share-screen-btn');
25+
expect(shareBtn.innerHTML).toBe('Share Screen');
26+
27+
const endBtn = screen.getByTestId('end-call-btn');
28+
expect(endBtn.innerHTML).toBe('End Call');
29+
30+
const callBtn = screen.getByTestId('call-btn');
31+
expect(callBtn.innerHTML).toBe('Call');
32+
2333
// fireEvent.click(submitBtn);
2434
// expect()
2535
});

lib/src/components/VideoCall.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,10 @@ const VideoCall = ({ URL, mediaOptions }: { URL: string, mediaOptions: { control
376376
: ''
377377
}
378378

379-
<div className='' style={{display: 'flex', justifyContent: 'space-around', flexDirection:'column', padding:'10px', marginTop: '10%'} }>
379+
<div
380+
className=''
381+
style={{display: 'flex', justifyContent: 'space-around', flexDirection:'column', padding:'10px', marginTop: '10%'} }
382+
>
380383

381384
{
382385
username === '' ?
@@ -439,15 +442,17 @@ const VideoCall = ({ URL, mediaOptions }: { URL: string, mediaOptions: { control
439442
>
440443

441444
<button
442-
className='share-btn'
445+
className='share-btn'
446+
data-testid='share-screen-btn'
443447
onClick={() => shareScreen()}
444448
style={buttonStyling}
445449
>
446450
Share Screen
447451
</button>
448452

449453
<button
450-
className='end-btn'
454+
className='end-btn'
455+
data-testid='end-call-btn'
451456
onClick={() => endCall(false)}
452457
style={{ ...buttonStyling, backgroundColor:'#ff6961', color:'#28282B' }}
453458
>
@@ -474,7 +479,8 @@ const VideoCall = ({ URL, mediaOptions }: { URL: string, mediaOptions: { control
474479
>
475480

476481
<button
477-
className=''
482+
className=''
483+
data-testid='call-btn'
478484
onClick={handleOffer}
479485
style={buttonStyling}
480486
>

0 commit comments

Comments
 (0)