diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..73f69e0
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/counter-assignment.iml b/.idea/counter-assignment.iml
new file mode 100644
index 0000000..bc2cd87
--- /dev/null
+++ b/.idea/counter-assignment.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..03d9549
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.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 0000000..dac7415
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /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 36cc18a..c575ffe 100644
--- a/src/tests/Counter.test.js
+++ b/src/tests/Counter.test.js
@@ -1,22 +1,47 @@
// import necessary react testing library helpers here
+import { render, screen } from '@testing-library/react';
// import the Counter component here
+import Counter from '../components/Counter';
+import userEvent from "@testing-library/user-event";
beforeEach(() => {
- // Render the Counter component here
+ // Render the Counter component here
+ render ();
})
test('renders counter message', () => {
- // Complete the unit test below based on the objective in the line above
+ // 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
+ // Complete the unit test below based on the objective in the line above
+ const initialCount = screen.getByTestId('count');
+ expect(initialCount.textContent).toBe('0');
});
test('clicking + increments the count', () => {
- // Complete the unit test below based on the objective in the line above
+ // Complete the unit test below based on the objective in the line above
+ const incrementButton = screen.getByText(/\+/i);
+ const countDisplay = screen.getByTestId('count');
+
+ userEvent.click(incrementButton);
+ expect(countDisplay.textContent).toBe('1');
+
+ userEvent.click(incrementButton);
+ expect(countDisplay.textContent).toBe('2');
});
test('clicking - decrements the count', () => {
- // Complete the unit test below based on the objective in the line above
-});
+ // Complete the unit test below based on the objective in the line above
+ const decrementButton = screen.getByText(/-/i);
+ const countDisplay = screen.getByTestId('count');
+
+ userEvent.click(decrementButton);
+ expect(countDisplay.textContent).toBe('-1');
+
+ userEvent.click(decrementButton);
+ expect(countDisplay.textContent).toBe('-2');
+});
\ No newline at end of file