Skip to content

Commit ad73e13

Browse files
authored
Merge pull request #6 from znsio/fixed_timeout_issue
Fixed errors and warnings while running tests
2 parents e68c7d9 + 6e4db6d commit ad73e13

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
2424

25-
.specmatic
25+
.specmatic
26+
.idea

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"autoprefixer": "^10.4.19",
5252
"postcss": "^8.4.39",
5353
"specmatic": "^2.11.3",
54-
"specmatic-commercial": "github:znsio/specmatic-node-commercial#7a4204131ed99647295f89ee562d1414c62ff401",
54+
"specmatic-commercial": "github:znsio/specmatic-node-commercial#f43d6a2f5140c04fbb49c312e17d217aa4e5dce7",
5555
"tailwindcss": "^3.4.3"
5656
}
5757
}

src/__test__/App.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ beforeAll(async () => {
1616
stub = await startGraphQlStub("127.0.0.1", 8080);
1717
}, 20000);
1818

19+
jest.setTimeout(10000);
20+
1921
jest.mock("react-toastify", () => ({
2022
toast: {
2123
success: jest.fn(),
@@ -27,6 +29,8 @@ jest.mock("react-toastify", () => ({
2729

2830
describe("App component tests", () => {
2931
test("should create product with given form fields", async () => {
32+
const ALLOWED_WAIT_TIME_FOR_RESPONSE = 7000;
33+
3034
await React.act(async () => {
3135
// Use act from @testing-library/react
3236
render(
@@ -47,7 +51,7 @@ describe("App component tests", () => {
4751
// Wait for the mutation to be called
4852
await waitFor(() => {
4953
expect(toast.success).toHaveBeenCalledWith("Product added successfully");
50-
});
54+
}, { timeout: ALLOWED_WAIT_TIME_FOR_RESPONSE });
5155

5256
// Optionally, check if the form is cleared
5357
expect(screen.getByTestId("name").value).toBe("");
@@ -119,4 +123,4 @@ describe("App component tests", () => {
119123

120124
afterAll(async () => {
121125
await stopGraphQlStub(stub);
122-
}, 5000);
126+
}, 10000);

src/components/FindOffersForDate.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,15 @@ const FindOffersForDate = () => {
7171
</button>
7272
</div>
7373
</form>
74-
{offers && offers.map(offer => {
75-
return (<>
76-
<div className="mt-8">
74+
{offers && offers.map((offer, index) => {
75+
return (
76+
<div key={index} className="mt-8">
7777
<div className="p-4 border rounded-lg bg-gray-50 shadow-sm">
7878
<p><strong>Offer code:</strong> {offer.offerCode}</p>
7979
<p><strong>Valid Until:</strong> {new Date(offer.validUntil).toLocaleDateString()}</p>
8080
</div>
8181
</div>
82-
</>
83-
)
82+
);
8483
})
8584
}
8685
</div>

0 commit comments

Comments
 (0)