Skip to content

Commit

Permalink
filtering nock only when language API is not null
Browse files Browse the repository at this point in the history
  • Loading branch information
mageroni committed Sep 21, 2023
1 parent e5224fa commit 80c3937
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit 80c3937

Please sign in to comment.