Skip to content

Commit

Permalink
Fix stripping new lines from test results
Browse files Browse the repository at this point in the history
  • Loading branch information
marclipovsky committed Oct 18, 2024
1 parent 77f4b45 commit 9d4882b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type StringTransformationTest = [
let editor: vscode.TextEditor;
let document: vscode.TextDocument;
const originalShowInputBox = vscode.window.showInputBox;
const stripNewlines = (str: string) => str.replace(/[\n\r]/g, "");

suite("Extension Test Suite", () => {
beforeEach(async () => {
Expand Down Expand Up @@ -50,7 +51,9 @@ suite("Extension Test Suite", () => {
});
await vscode.commands.executeCommand(commandName);
return Promise.resolve(
editor.selections.map((selection) => editor.document.getText(selection))
editor.selections.map((selection) =>
stripNewlines(editor.document.getText(selection))
)
);
};

Expand Down Expand Up @@ -375,8 +378,8 @@ suite("Extension Test Suite", () => {
);

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

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

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

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

assert.strictEqual(
output,
"a1 b2 c3 4d 5e 6f 12x y23 34z45a2 b3 c4 5d 6e 7f 13x y24 35z46\n"
"a1 b2 c3 4d 5e 6f 12x y23 34z45a2 b3 c4 5d 6e 7f 13x y24 35z46"
);
});

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

assert.strictEqual(
output,
"a1 b2 c3 4d 5e 6f 12x y23 34z45a0 b1 c2 3d 4e 5f 11x y22 33z44\n"
"a1 b2 c3 4d 5e 6f 12x y23 34z45a0 b1 c2 3d 4e 5f 11x y22 33z44"
);
});

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

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

test("utf8ToChar", async () => {
Expand Down

0 comments on commit 9d4882b

Please sign in to comment.