Skip to content

Commit

Permalink
Remove new lines to validate tests across platforms better (windows s…
Browse files Browse the repository at this point in the history
…pecifically)
  • Loading branch information
marclipovsky committed Oct 18, 2024
1 parent ef61771 commit f229753
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 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 removeNewLines = (str: string) => str.replace(/[\n\r]/g, "");

suite("Extension Test Suite", () => {
beforeEach(async () => {
Expand Down Expand Up @@ -375,8 +376,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 +400,14 @@ 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(
removeNewLines(output2),
"a0 b1 c2 3d4e 5f 11x y22 33z44"
);
assert.strictEqual(
removeNewLines(output3),
"a-4 b-3 c-2 -1d0e 5f 11x y22 33z44"
);
});

test("duplicateAndIncrement", async () => {
Expand All @@ -415,8 +422,8 @@ 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"
removeNewLines(output),
"a1 b2 c3 4d 5e 6f 12x y23 34z45a2 b3 c4 5d 6e 7f 13x y24 35z46"
);
});

Expand All @@ -432,8 +439,8 @@ 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"
removeNewLines(output),
"a1 b2 c3 4d 5e 6f 12x y23 34z45a0 b1 c2 3d 4e 5f 11x y22 33z44"
);
});

Expand All @@ -453,7 +460,10 @@ 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(
removeNewLines(output2),
"a11 b12 c1314d 15e 16f 17x y18 19z20"
);
});

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

0 comments on commit f229753

Please sign in to comment.