From 80c3937151da08c150d608115b45747d53893833 Mon Sep 17 00:00:00 2001 From: Mabel Geronimo <107436170+mageroni@users.noreply.github.com> Date: Thu, 21 Sep 2023 00:23:46 -0500 Subject: [PATCH] filtering nock only when language API is not null --- test/index.test.js | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/test/index.test.js b/test/index.test.js index 66db4dc..62d8a72 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -30,25 +30,27 @@ describe("My Probot app", () => { beforeEach(() => { nock.disableNetConnect(); + if(LANGUAGE_API_ENDPOINT) { nock.enableNetConnect(LANGUAGE_API_ENDPOINT); - nock(LANGUAGE_API_ENDPOINT) - .post('/language/:analyze-text?api-version=2023-04-01') - .reply(200, { - "kind": "LanguageDetectionResults", - "results": { - "documents": [{ - "id": "1", - "detectedLanguage": { - "name": "English", - "iso6391Name": "en", - "confidenceScore": 1.0 - }, - "warnings": [] - }], - "errors": [], - "modelVersion": "2022-10-01" - } - }); + nock(LANGUAGE_API_ENDPOINT) + .post('/language/:analyze-text?api-version=2023-04-01') + .reply(200, { + "kind": "LanguageDetectionResults", + "results": { + "documents": [{ + "id": "1", + "detectedLanguage": { + "name": "English", + "iso6391Name": "en", + "confidenceScore": 1.0 + }, + "warnings": [] + }], + "errors": [], + "modelVersion": "2022-10-01" + } + }); + } probot = new Probot({ appId: 123, privateKey, @@ -72,7 +74,7 @@ describe("My Probot app", () => { issues: "write", }, }) - + // Test that a issue is created .post("/repos/mageroni/TestRepo/issues", (body) => { expect(body).toMatchObject(expected_issue);