Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 29c3b36

Browse files
Batta32lauren-mills
authored andcommitted
[Botskills] Fix line endings for test temporal files (#1945)
* Main logic to normalize line endings * Add util to normalize the line ending * Implement the normalization of line endings * Update test dispatch file * Add a comment for the normalize util
1 parent 86889ef commit 29c3b36

File tree

7 files changed

+72
-16
lines changed

7 files changed

+72
-16
lines changed

tools/botskills/test/authentication.test.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ const { writeFileSync } = require("fs");
88
const { join, resolve } = require("path");
99
const sandbox = require("sinon").createSandbox();
1010
const { TestLogger } = require("./helpers/testLogger");
11+
const { normalizeContent } = require("./helpers/normalizeUtils");
1112
const { AuthenticationUtils } = require("../lib/utils");
1213
const authenticationUtils = new AuthenticationUtils();
1314
const emptyAzureAuthSettings = JSON.stringify(require(resolve(__dirname, join("mocks", "azureAuthSettings", "emptyAuthSettings.json"))));
1415
const filledAzureAuthSettings = JSON.stringify(require(resolve(__dirname, join("mocks", "azureAuthSettings", "filledAuthSettings.json"))));
1516
const appShowReplyUrl = JSON.stringify(require(resolve(__dirname, join("mocks", "appShowReplyUrl", "emptyAppShowReplyUrl.json"))));
1617

17-
const noAuthConnectionAppsettings = JSON.stringify(
18+
const noAuthConnectionAppsettings = normalizeContent(JSON.stringify(
1819
{
1920
"microsoftAppId": "",
2021
"microsoftAppPassword": "",
@@ -36,10 +37,41 @@ const noAuthConnectionAppsettings = JSON.stringify(
3637
"key": ""
3738
}
3839
},
39-
null, 4);
40+
null, 4));
41+
42+
const authConnectionAppsettings = normalizeContent(JSON.stringify(
43+
{
44+
"microsoftAppId": "",
45+
"microsoftAppPassword": "",
46+
"appInsights": {
47+
"appId": "",
48+
"instrumentationKey": ""
49+
},
50+
"blobStorage": {
51+
"connectionString": "",
52+
"container": ""
53+
},
54+
"cosmosDb": {
55+
"authkey": "",
56+
"collectionId": "",
57+
"cosmosDBEndpoint": "",
58+
"databaseId": ""
59+
},
60+
"contentModerator": {
61+
"key": ""
62+
},
63+
"oauthConnections": [
64+
{
65+
"name": "Outlook",
66+
"provider": "Azure Active Directory v2"
67+
}
68+
]
69+
},
70+
null,4));
4071

4172
function undoChangesInTemporalFiles() {
4273
writeFileSync(resolve(__dirname, join("mocks", "appsettings", "noAuthConnectionAppsettings.json")), noAuthConnectionAppsettings);
74+
writeFileSync(resolve(__dirname, join("mocks", "appsettings", "authConnectionAppsettings.json")), authConnectionAppsettings);
4375
}
4476

4577
describe("The authentication util", function() {

tools/botskills/test/connect.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ const { writeFileSync } = require("fs");
88
const { join, resolve } = require("path");
99
const sandbox = require("sinon").createSandbox();
1010
const testLogger = require("./helpers/testLogger");
11+
const { normalizeContent } = require("./helpers/normalizeUtils");
1112
const botskills = require("../lib/index");
12-
const filledSkills = JSON.stringify(
13+
const filledSkills = normalizeContent(JSON.stringify(
1314
{
1415
"skills": [
1516
{
@@ -20,7 +21,7 @@ const filledSkills = JSON.stringify(
2021
}
2122
]
2223
},
23-
null, 4);
24+
null, 4));
2425

2526
function undoChangesInTemporalFiles() {
2627
writeFileSync(resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")), filledSkills);

tools/botskills/test/disconnect.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ const { writeFileSync } = require("fs");
88
const { join, resolve } = require("path");
99
const sandbox = require("sinon").createSandbox();
1010
const testLogger = require("./helpers/testLogger");
11+
const { normalizeContent } = require("./helpers/normalizeUtils");
1112
const botskills = require("../lib/index");
12-
const filledDispatch = JSON.stringify(
13+
const filledDispatch = normalizeContent(JSON.stringify(
1314
{
1415
"services": [
1516
{
@@ -21,9 +22,9 @@ const filledDispatch = JSON.stringify(
2122
"1"
2223
]
2324
},
24-
null, 4);
25+
null, 4));
2526

26-
const filledSkills = JSON.stringify(
27+
const filledSkills = normalizeContent(JSON.stringify(
2728
{
2829
"skills": [
2930
{
@@ -34,19 +35,18 @@ const filledSkills = JSON.stringify(
3435
}
3536
]
3637
},
37-
null, 4)
38+
null, 4));
3839

3940
function undoChangesInTemporalFiles() {
4041
writeFileSync(resolve(__dirname, join("mocks", "success", "dispatch", "filledDispatchNoJson.dispatch")), filledDispatch);
42+
writeFileSync(resolve(__dirname, join("mocks", "success", "dispatch", "filledDispatch.dispatch")), filledDispatch);
4143
writeFileSync(resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")), filledSkills);
4244
}
4345

4446
describe("The disconnect command", function () {
4547

4648
beforeEach(function() {
47-
writeFileSync(resolve(__dirname, join("mocks", "success", "dispatch", "filledDispatch.dispatch")),filledDispatch);
4849
undoChangesInTemporalFiles();
49-
5050
this.logger = new testLogger.TestLogger();
5151
this.disconnector = new botskills.DisconnectSkill(this.logger);
5252
this.refreshSkillStub = sandbox.stub(this.disconnector.refreshSkill, "refreshSkill");
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Copyright(c) Microsoft Corporation.All rights reserved.
3+
* Licensed under the MIT License.
4+
*/
5+
6+
/**
7+
* Normalize the line endings of the content received
8+
*/
9+
function normalizeContent(content) {
10+
return content.replace(/\r\n/gm, "\n") //normalize
11+
.replace(/\n/gm, "\r\n"); //CR+LF - Windows EOL;
12+
}
13+
14+
exports.normalizeContent = normalizeContent;

tools/botskills/test/list.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ const { strictEqual } = require("assert");
77
const { writeFileSync } = require("fs");
88
const { join, resolve } = require("path");
99
const testLogger = require("./helpers/testLogger");
10+
const { normalizeContent } = require("./helpers/normalizeUtils");
1011
const botskills = require("../lib/index");
11-
const filledSkills = JSON.stringify(
12+
const filledSkills = normalizeContent(JSON.stringify(
1213
{
1314
"skills": [
1415
{
@@ -19,7 +20,7 @@ const filledSkills = JSON.stringify(
1920
}
2021
]
2122
},
22-
null, 4)
23+
null, 4));
2324

2425
function undoChangesInTemporalFiles() {
2526
writeFileSync(resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")), filledSkills);
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
{
2-
"services": [],
3-
"serviceIds": []
2+
"services": [
3+
{
4+
"name": "testDispatch",
5+
"id": "1"
6+
}
7+
],
8+
"serviceIds": [
9+
"1"
10+
]
411
}

tools/botskills/test/update.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ const { writeFileSync } = require("fs");
88
const { join, resolve } = require("path");
99
const sandbox = require("sinon").createSandbox();
1010
const testLogger = require("./helpers/testLogger");
11+
const { normalizeContent } = require("./helpers/normalizeUtils");
1112
const botskills = require("../lib/index");
12-
const filledSkills = JSON.stringify(
13+
const filledSkills = normalizeContent(JSON.stringify(
1314
{
1415
"skills": [
1516
{
@@ -20,7 +21,7 @@ const filledSkills = JSON.stringify(
2021
}
2122
]
2223
},
23-
null, 4);
24+
null, 4));
2425

2526
function undoChangesInTemporalFiles() {
2627
writeFileSync(resolve(__dirname, join("mocks", "virtualAssistant", "filledSkills.json")), filledSkills);

0 commit comments

Comments
 (0)