Skip to content

Commit 9d4882b

Browse files
Fix stripping new lines from test results
1 parent 77f4b45 commit 9d4882b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/test/extension.test.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type StringTransformationTest = [
1919
let editor: vscode.TextEditor;
2020
let document: vscode.TextDocument;
2121
const originalShowInputBox = vscode.window.showInputBox;
22+
const stripNewlines = (str: string) => str.replace(/[\n\r]/g, "");
2223

2324
suite("Extension Test Suite", () => {
2425
beforeEach(async () => {
@@ -50,7 +51,9 @@ suite("Extension Test Suite", () => {
5051
});
5152
await vscode.commands.executeCommand(commandName);
5253
return Promise.resolve(
53-
editor.selections.map((selection) => editor.document.getText(selection))
54+
editor.selections.map((selection) =>
55+
stripNewlines(editor.document.getText(selection))
56+
)
5457
);
5558
};
5659

@@ -375,8 +378,8 @@ suite("Extension Test Suite", () => {
375378
);
376379

377380
assert.strictEqual(output1, "a2 b3 c4 5d 6e 7f 13x y24 35z46");
378-
assert.strictEqual(output2, "a2 b3 c4 5d 6e\n7f 13x y24 35z46");
379-
assert.strictEqual(output3, "a-3 b-2 c-1 0d 1e\n7f 13x y24 35z46");
381+
assert.strictEqual(output2, "a2 b3 c4 5d 6e7f 13x y24 35z46");
382+
assert.strictEqual(output3, "a-3 b-2 c-1 0d 1e7f 13x y24 35z46");
380383
});
381384

382385
test("decrement", async () => {
@@ -399,8 +402,8 @@ suite("Extension Test Suite", () => {
399402
);
400403

401404
assert.strictEqual(output1, "a0 b1 c2 3d 4e 5f 11x y22 33z44");
402-
assert.strictEqual(output2, "a0 b1 c2 3d\n4e 5f 11x y22 33z44");
403-
assert.strictEqual(output3, "a-4 b-3 c-2 -1d\n0e 5f 11x y22 33z44");
405+
assert.strictEqual(output2, "a0 b1 c2 3d4e 5f 11x y22 33z44");
406+
assert.strictEqual(output3, "a-4 b-3 c-2 -1d0e 5f 11x y22 33z44");
404407
});
405408

406409
test("duplicateAndIncrement", async () => {
@@ -416,7 +419,7 @@ suite("Extension Test Suite", () => {
416419

417420
assert.strictEqual(
418421
output,
419-
"a1 b2 c3 4d 5e 6f 12x y23 34z45a2 b3 c4 5d 6e 7f 13x y24 35z46\n"
422+
"a1 b2 c3 4d 5e 6f 12x y23 34z45a2 b3 c4 5d 6e 7f 13x y24 35z46"
420423
);
421424
});
422425

@@ -433,7 +436,7 @@ suite("Extension Test Suite", () => {
433436

434437
assert.strictEqual(
435438
output,
436-
"a1 b2 c3 4d 5e 6f 12x y23 34z45a0 b1 c2 3d 4e 5f 11x y22 33z44\n"
439+
"a1 b2 c3 4d 5e 6f 12x y23 34z45a0 b1 c2 3d 4e 5f 11x y22 33z44"
437440
);
438441
});
439442

@@ -453,7 +456,7 @@ suite("Extension Test Suite", () => {
453456
);
454457

455458
assert.strictEqual(output1, "a1 b2 c3 4d 5e 6f 7x y8 9z10");
456-
assert.strictEqual(output2, "a11 b12 c13\n14d 15e 16f 17x y18 19z20");
459+
assert.strictEqual(output2, "a11 b12 c1314d 15e 16f 17x y18 19z20");
457460
});
458461

459462
test("utf8ToChar", async () => {

0 commit comments

Comments
 (0)