From 94b730d5123ddb662fb8fc522e990191c81eedd8 Mon Sep 17 00:00:00 2001 From: Abdulrahman Goni Date: Sat, 6 Apr 2024 22:25:00 +0300 Subject: [PATCH] test: rename test file and solve a failed test case in it Rename `productsCategorieslist_get.test` test file to `settings_storeVariables_get.test` because its response changed, And edit the only test case in the file to match the new response from the endpoint. --- ...get.test.js => settings_storeVariables_get.test.js} | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) rename __tests__/integration_testing/settings_routes_tests/{productsCategorieslist_get.test.js => settings_storeVariables_get.test.js} (60%) diff --git a/__tests__/integration_testing/settings_routes_tests/productsCategorieslist_get.test.js b/__tests__/integration_testing/settings_routes_tests/settings_storeVariables_get.test.js similarity index 60% rename from __tests__/integration_testing/settings_routes_tests/productsCategorieslist_get.test.js rename to __tests__/integration_testing/settings_routes_tests/settings_storeVariables_get.test.js index 98d36d33..61c50b39 100644 --- a/__tests__/integration_testing/settings_routes_tests/productsCategorieslist_get.test.js +++ b/__tests__/integration_testing/settings_routes_tests/settings_storeVariables_get.test.js @@ -1,5 +1,11 @@ +import SettingsModel from "../../../src/models/Settings.js" +import { fakeSettingsObject } from "../../fakes/fakeSettingsObject.js" import { userRequest, closeTestingServer } from "../../helpers/testRequest.js" +beforeAll(async () => { + await SettingsModel.create(fakeSettingsObject) +}) + afterAll(async () => { await closeTestingServer() }) @@ -11,9 +17,7 @@ describe("GET /api/settings/variables", () => { it("Should returns an array of products categories", async () => { const response = await userRequest(routePath, "get") expect(response.statusCode).toBe(200) - expect(response.body.categoriesList).toEqual( - expect.arrayContaining([expect.any(String)]) - ) + expect(fakeSettingsObject).toMatchObject(response.body) }) }) \ No newline at end of file