From 7e2aad5e02e77c33e6ee73b7c1201c9697231f1c Mon Sep 17 00:00:00 2001
From: Natalia Arroyave <116681140+nataliayave@users.noreply.github.com>
Date: Wed, 20 Nov 2024 16:36:00 -0500
Subject: [PATCH] Completed Counter unit tests with 100% coverage
---
.idea/.gitignore | 8 ++++++++
.idea/counter-assignment.iml | 9 +++++++++
.idea/misc.xml | 6 ++++++
.idea/modules.xml | 8 ++++++++
.idea/php.xml | 19 +++++++++++++++++++
.idea/vcs.xml | 6 ++++++
src/tests/Counter.test.js | 25 +++++++++++++++++--------
7 files changed, 73 insertions(+), 8 deletions(-)
create mode 100644 .idea/.gitignore
create mode 100644 .idea/counter-assignment.iml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/php.xml
create mode 100644 .idea/vcs.xml
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..13566b81
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/counter-assignment.iml b/.idea/counter-assignment.iml
new file mode 100644
index 00000000..d6ebd480
--- /dev/null
+++ b/.idea/counter-assignment.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..6f29fee2
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..dac74155
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/php.xml b/.idea/php.xml
new file mode 100644
index 00000000..f324872a
--- /dev/null
+++ b/.idea/php.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/tests/Counter.test.js b/src/tests/Counter.test.js
index 36cc18aa..3f571d53 100644
--- a/src/tests/Counter.test.js
+++ b/src/tests/Counter.test.js
@@ -1,22 +1,31 @@
-// import necessary react testing library helpers here
-// import the Counter component here
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import Counter from '../components/Counter';
beforeEach(() => {
- // Render the Counter component here
-})
+ render();
+});
test('renders counter message', () => {
- // Complete the unit test below based on the objective in the line above
+ const counterMessage = screen.getByText(/Counter/i);
+ expect(counterMessage).toBeInTheDocument();
});
test('should render initial count with value of 0', () => {
- // Complete the unit test below based on the objective in the line above
+ const counterValue = screen.getByTestId('count');
+ expect(counterValue).toHaveTextContent('0');
});
test('clicking + increments the count', () => {
- // Complete the unit test below based on the objective in the line above
+ const incrementButton = screen.getByRole('button', { name: /\+/i });
+ userEvent.click(incrementButton);
+ const counterValue = screen.getByTestId('count');
+ expect(counterValue).toHaveTextContent('1');
});
test('clicking - decrements the count', () => {
- // Complete the unit test below based on the objective in the line above
+ const decrementButton = screen.getByRole('button', { name: /-/i });
+ userEvent.click(decrementButton);
+ const counterValue = screen.getByTestId('count');
+ expect(counterValue).toHaveTextContent('-1');
});