summaryrefslogtreecommitdiff
path: root/cli/tests/unit
diff options
context:
space:
mode:
authorLiam Murphy <43807659+Liamolucko@users.noreply.github.com>2021-04-11 22:19:50 +1000
committerGitHub <noreply@github.com>2021-04-11 14:19:50 +0200
commit3c645457a4cb39a393f88635bbca3894df37d3e2 (patch)
treefe71c01dc71c5b05173bf3c8abace03308b71979 /cli/tests/unit
parent6519f232bd8b2a56620e0754e7d58c2b0780676f (diff)
fix(op_crates/console): console.table value misalignment with varying keys (#10127)
Diffstat (limited to 'cli/tests/unit')
-rw-r--r--cli/tests/unit/console_test.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts
index a407df9a1..d7c4fd0cb 100644
--- a/cli/tests/unit/console_test.ts
+++ b/cli/tests/unit/console_test.ts
@@ -1469,6 +1469,39 @@ unitTest(function consoleTable(): void {
`,
);
});
+ mockConsole((console, out) => {
+ console.table([{ a: 0 }, { a: 1, b: 1 }, { a: 2 }, { a: 3, b: 3 }]);
+ assertEquals(
+ stripColor(out.toString()),
+ `┌───────┬───┬───┐
+│ (idx) │ a │ b │
+├───────┼───┼───┤
+│ 0 │ 0 │ │
+│ 1 │ 1 │ 1 │
+│ 2 │ 2 │ │
+│ 3 │ 3 │ 3 │
+└───────┴───┴───┘
+`,
+ );
+ });
+ mockConsole((console, out) => {
+ console.table(
+ [{ a: 0 }, { a: 1, c: 1 }, { a: 2 }, { a: 3, c: 3 }],
+ ["a", "b", "c"],
+ );
+ assertEquals(
+ stripColor(out.toString()),
+ `┌───────┬───┬───┬───┐
+│ (idx) │ a │ b │ c │
+├───────┼───┼───┼───┤
+│ 0 │ 0 │ │ │
+│ 1 │ 1 │ │ 1 │
+│ 2 │ 2 │ │ │
+│ 3 │ 3 │ │ 3 │
+└───────┴───┴───┴───┘
+`,
+ );
+ });
});
// console.log(Error) test