From ecf2d0207157dfe4525b138606a2c66881f9b647 Mon Sep 17 00:00:00 2001 From: Amitkanswal Date: Mon, 21 Oct 2024 14:51:29 +0530 Subject: [PATCH] fix:unit test case Signed-off-by: Amitkanswal --- __test__/uiLocation.test.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/__test__/uiLocation.test.ts b/__test__/uiLocation.test.ts index 5233cdd..5e0ce30 100644 --- a/__test__/uiLocation.test.ts +++ b/__test__/uiLocation.test.ts @@ -142,12 +142,13 @@ describe("UI Location", () => { beforeEach(() => { mockPostRobot = postRobot; - opts = { method: 'GET', url: '/test' }; + opts = { method: 'GET', url: '/test', baseURL: 'https://test.com' }; uiLocationInstance = new UiLocation(initData); onError = jest.fn(); uiLocationInstance.api = jest.fn().mockResolvedValue({ method: 'GET', url: '/test?limit=10&skip=0', + baseURL: 'https://test.com', body: {} }); }); @@ -158,6 +159,7 @@ describe("UI Location", () => { const result = await uiLocationInstance.api({ method: 'GET', url: '/test?limit=10&skip=0', + baseURL: 'https://test.com', body: {} }); @@ -165,11 +167,13 @@ describe("UI Location", () => { expect(uiLocationInstance.api).toHaveBeenCalledWith({ method: 'GET', url: '/test?limit=10&skip=0', + baseURL: 'https://test.com', body: {} }); expect(result).toEqual({ method: 'GET', url: '/test?limit=10&skip=0', + baseURL: 'https://test.com', body: {} }); @@ -190,6 +194,7 @@ describe("UI Location", () => { await expect(uiLocationInstance.api({ method: 'GET', url: '/test?limit=10&skip=0', + baseURL: 'https://test.com', body: {} })).rejects.toThrow('Test error'); }); @@ -203,12 +208,13 @@ describe("UI Location", () => { let onError: jest.Mock; beforeEach(() => { mockPostRobot = postRobot; - opts = { method: 'GET', url: '/test' }; + opts = { method: 'GET', url: '/test', baseURL: 'https://test.com' }; uiLocationInstance = new UiLocation(initData); onError = jest.fn(); uiLocationInstance.createAdapter = jest.fn().mockResolvedValue({ method: 'GET', url: '/test?limit=10&skip=0', + baseURL: 'https://test.com', data: {} }); }); @@ -228,6 +234,7 @@ describe("UI Location", () => { const result = await uiLocationInstance.createAdapter({ method: 'GET', url: '/test?limit=10&skip=0', + baseURL: 'https://test.com', data: {} }); @@ -235,11 +242,13 @@ describe("UI Location", () => { expect(uiLocationInstance.createAdapter).toHaveBeenCalledWith({ method: 'GET', url: '/test?limit=10&skip=0', + baseURL: 'https://test.com', data: {} }); expect(result).toEqual({ method: 'GET', url: '/test?limit=10&skip=0', + baseURL: 'https://test.com', data: {} }); }) @@ -259,6 +268,7 @@ describe("UI Location", () => { await expect(uiLocationInstance.createAdapter({ method: 'GET', url: '/test?limit=10&skip=0', + baseURL: 'https://test.com', data: {} })).rejects.toThrow('Test error'); })