Skip to content

Commit 9a94efd

Browse files
Anshuman SinhaAnshuman Sinha
authored andcommitted
Fix: fixed 75% of test suite
1 parent 59eba74 commit 9a94efd

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

__tests__/React Unit Testing/CB.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const board = () => {
4747
// problem here is that due to css styling, it only appears on a hover. So to test it appears on hover, I need to somehow convince this test file that the CSS hover property is true.
4848
const cbButton = () => {
4949
render(
50-
<Provider store={mockStore(initialState)}>
50+
<Provider store={mockStore()}>
5151
<BrowserRouter>
5252
<ClipboardButton />
5353
</BrowserRouter>
@@ -63,24 +63,24 @@ describe('Unit testing Clipboard component', () => {
6363
change in state then to test properly, you will need to reset the state before wach test to ensure that the
6464
components being rendered in the test have the expected default state.
6565
66-
A similar feature could be achievd through the use of a fireEvent.click method (in this case) being run before all events
66+
A similar feature could be achievd through the use of a fireEvent.click method (in this case) being run before each event
6767
where we want to change state based on a button being clicked!
6868
*/
6969
});
7070

7171
// clipboard that displays snippets
72-
test(`Renders a Clipboard with the role of ${'textbox'}`, () => {
73-
expect(screen.getByRole('textbox', { name:'' })).toBeInTheDocument();
72+
test(`Renders a Clipboard with the classname of ${'code-container'}`, () => {
73+
expect(screen.getByTestId('code-container')).toBeInTheDocument();
7474
});
7575
//delete button:
76-
test('Renders the delete button with an anonymous identity', () => {
77-
expect(screen.getByRole('button', { name:'' })).toBeInTheDocument();
76+
test(`Renders the delete button with the classname of ${'delete'}` , () => {
77+
expect(screen.getByRole('button', { name:'Clear Clipboard' })).toBeInTheDocument();
7878
});
7979
// copy button.
8080
test(`Renders the copy button with a class name of ${'clipboard-button-container'}`, () => {
8181
cbButton();
8282
// how to test as if the css hover property is true? --> this is actually unnecessary as it is being rendered, just not visible until hovered over.
83-
expect(screen.getByRole('button', { name:'clipboard-button-container' })).toBeInTheDocument();
83+
expect(screen.getByRole('button', { name: 'something-weird' })).toBeInTheDocument();
8484
});
8585
// server url textbox
8686
test(`Renders the server url textbox with a label of ${'Server URL'}`, () => {

client/components/Clipboard.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ const Clipboard = () => {
6868
gap: '10px',
6969
width: .8,
7070
}}
71-
className="code-container"
71+
className='code-container'
72+
data-testid='code-container'
7273
>
7374
<TextField
7475
className="text-display"
@@ -98,6 +99,7 @@ const Clipboard = () => {
9899
<Button
99100
onClick={handleClear}
100101
sx={{ flexDirection: 'column' }}
102+
className='delete'
101103
>
102104
<DeleteForeverIcon />
103105
{buttonText}

client/components/ClipboardButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const ClipboardButton = () => {
2828
end={ <DoneAllIcon /> }
2929
onClick={ handleClick }
3030
testId="bttn-copy"
31+
data-testId='bttn-copy'
3132
/>
3233
</Box>
3334
);

0 commit comments

Comments
 (0)