From 4de3d2b05f26742e4bd51de2f17d679ab97627e6 Mon Sep 17 00:00:00 2001 From: Mateusz Pietryga Date: Fri, 19 Jul 2024 22:50:41 +0200 Subject: [PATCH] Bugfix - fix broken unit tests --- packages/bruno-electron/package.json | 3 ++ .../tests/network/index.spec.js | 34 +++++++------------ 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/packages/bruno-electron/package.json b/packages/bruno-electron/package.json index b5d9958586..0d1b5b0c84 100644 --- a/packages/bruno-electron/package.json +++ b/packages/bruno-electron/package.json @@ -18,6 +18,9 @@ "pack": "electron-builder --dir", "test": "jest" }, + "jest": { + "modulePaths": ["node_modules"] + }, "dependencies": { "@aws-sdk/credential-providers": "3.525.0", "@usebruno/common": "0.1.0", diff --git a/packages/bruno-electron/tests/network/index.spec.js b/packages/bruno-electron/tests/network/index.spec.js index 7c45c25383..02a9b90837 100644 --- a/packages/bruno-electron/tests/network/index.spec.js +++ b/packages/bruno-electron/tests/network/index.spec.js @@ -1,25 +1,15 @@ -// damn jest throws an error when no tests are found in a file -// --passWithNoTests doesn't work +const { configureRequest } = require('../../src/ipc/network/index'); -describe('dummy test', () => { - it('should pass', () => { - expect(true).toBe(true); +describe('index: configureRequest', () => { + it("Should add 'http://' to the URL if no protocol is specified", async () => { + const request = { method: 'GET', url: 'test-domain', body: {} }; + await configureRequest(null, request, null, null, null, null); + expect(request.url).toEqual('http://test-domain'); }); -}); - -// todo: fix this failing test -// const { configureRequest } = require('../../src/ipc/network/index'); - -// describe('index: configureRequest', () => { -// it("Should add 'http://' to the URL if no protocol is specified", async () => { -// const request = { method: 'GET', url: 'test-domain', body: {} }; -// await configureRequest(null, request, null, null, null, null); -// expect(request.url).toEqual('http://test-domain'); -// }); -// it("Should NOT add 'http://' to the URL if a protocol is specified", async () => { -// const request = { method: 'GET', url: 'ftp://test-domain', body: {} }; -// await configureRequest(null, request, null, null, null, null); -// expect(request.url).toEqual('ftp://test-domain'); -// }); -// }); + it("Should NOT add 'http://' to the URL if a protocol is specified", async () => { + const request = { method: 'GET', url: 'ftp://test-domain', body: {} }; + await configureRequest(null, request, null, null, null, null); + expect(request.url).toEqual('ftp://test-domain'); + }); +});