Skip to content

Commit 80c3937

Browse files
committed
filtering nock only when language API is not null
1 parent e5224fa commit 80c3937

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

test/index.test.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,27 @@ describe("My Probot app", () => {
3030

3131
beforeEach(() => {
3232
nock.disableNetConnect();
33+
if(LANGUAGE_API_ENDPOINT) {
3334
nock.enableNetConnect(LANGUAGE_API_ENDPOINT);
34-
nock(LANGUAGE_API_ENDPOINT)
35-
.post('/language/:analyze-text?api-version=2023-04-01')
36-
.reply(200, {
37-
"kind": "LanguageDetectionResults",
38-
"results": {
39-
"documents": [{
40-
"id": "1",
41-
"detectedLanguage": {
42-
"name": "English",
43-
"iso6391Name": "en",
44-
"confidenceScore": 1.0
45-
},
46-
"warnings": []
47-
}],
48-
"errors": [],
49-
"modelVersion": "2022-10-01"
50-
}
51-
});
35+
nock(LANGUAGE_API_ENDPOINT)
36+
.post('/language/:analyze-text?api-version=2023-04-01')
37+
.reply(200, {
38+
"kind": "LanguageDetectionResults",
39+
"results": {
40+
"documents": [{
41+
"id": "1",
42+
"detectedLanguage": {
43+
"name": "English",
44+
"iso6391Name": "en",
45+
"confidenceScore": 1.0
46+
},
47+
"warnings": []
48+
}],
49+
"errors": [],
50+
"modelVersion": "2022-10-01"
51+
}
52+
});
53+
}
5254
probot = new Probot({
5355
appId: 123,
5456
privateKey,
@@ -72,7 +74,7 @@ describe("My Probot app", () => {
7274
issues: "write",
7375
},
7476
})
75-
77+
7678
// Test that a issue is created
7779
.post("/repos/mageroni/TestRepo/issues", (body) => {
7880
expect(body).toMatchObject(expected_issue);

0 commit comments

Comments
 (0)