From bcb6e8c4448e444f103e0f561528cd71cca1fcc7 Mon Sep 17 00:00:00 2001 From: Nahiyan Kamal Date: Mon, 1 Aug 2022 17:40:14 +0200 Subject: [PATCH] fix: Fix color resetting for borders (#428) --- src/internalTable/internal-table-printer.ts | 4 +- test/__snapshots__/alignment.test.ts.snap | 16 +-- test/__snapshots__/cellColor.test.ts.snap | 10 +- test/__snapshots__/columnColor.test.ts.snap | 16 +-- .../computedColumns.test.ts.snap | 16 +-- .../customizedColor.test.ts.snap | 8 +- .../foreignLanguage.test.ts.snap | 24 ++--- .../__snapshots__/lineWidthLimit.test.ts.snap | 102 +++++++++--------- test/__snapshots__/types.test.ts.snap | 10 +- .../__snapshots__/alignment.test.ts.snap | 15 +++ .../__snapshots__/borderStyle.test.ts.snap | 21 ++++ .../__snapshots__/columnColor.test.ts.snap | 15 +++ .../__snapshots__/computedColumn.test.ts.snap | 11 ++ .../__snapshots__/enableDisable.test.ts.snap | 29 +++++ .../__snapshots__/filter.test.ts.snap | 10 ++ .../__snapshots__/headerTitle.test.ts.snap | 10 ++ .../__snapshots__/rowColor.test.ts.snap | 28 +++++ .../__snapshots__/rowSeparator.test.ts.snap | 64 +++++++++++ .../__snapshots__/simpleTable.test.ts.snap | 10 ++ .../__snapshots__/sorting.test.ts.snap | 15 +++ .../__snapshots__/title.test.ts.snap | 27 +++++ test/internalTable/alignment.test.ts | 16 +-- test/internalTable/borderStyle.test.ts | 26 +---- test/internalTable/columnColor.test.ts | 17 +-- test/internalTable/computedColumn.test.ts | 12 +-- test/internalTable/enableDisable.test.ts | 32 +----- test/internalTable/filter.test.ts | 12 +-- test/internalTable/headerTitle.test.ts | 11 +- test/internalTable/rowColor.test.ts | 36 ++----- test/internalTable/rowSeparator.test.ts | 78 +++----------- test/internalTable/simpleTable.test.ts | 11 +- test/internalTable/sorting.test.ts | 17 +-- test/internalTable/title.test.ts | 30 +----- 33 files changed, 401 insertions(+), 358 deletions(-) create mode 100644 test/internalTable/__snapshots__/alignment.test.ts.snap create mode 100644 test/internalTable/__snapshots__/borderStyle.test.ts.snap create mode 100644 test/internalTable/__snapshots__/columnColor.test.ts.snap create mode 100644 test/internalTable/__snapshots__/computedColumn.test.ts.snap create mode 100644 test/internalTable/__snapshots__/enableDisable.test.ts.snap create mode 100644 test/internalTable/__snapshots__/filter.test.ts.snap create mode 100644 test/internalTable/__snapshots__/headerTitle.test.ts.snap create mode 100644 test/internalTable/__snapshots__/rowColor.test.ts.snap create mode 100644 test/internalTable/__snapshots__/rowSeparator.test.ts.snap create mode 100644 test/internalTable/__snapshots__/simpleTable.test.ts.snap create mode 100644 test/internalTable/__snapshots__/sorting.test.ts.snap create mode 100644 test/internalTable/__snapshots__/title.test.ts.snap diff --git a/src/internalTable/internal-table-printer.ts b/src/internalTable/internal-table-printer.ts index df56d120..696bd933 100644 --- a/src/internalTable/internal-table-printer.ts +++ b/src/internalTable/internal-table-printer.ts @@ -30,7 +30,7 @@ const renderOneLine = ( colorMap: ColorMap ): string => { const line = new ColoredConsoleLine(colorMap); - line.addCharsWithColor(DEFAULT_ROW_FONT_COLOR, tableStyle.vertical); + line.addCharsWithColor('', tableStyle.vertical); // dont Color the Column borders columns.forEach((column) => { const thisLineHasText = currentLineIndex < widthLimitedColumnsArray[column.name].length; @@ -48,7 +48,7 @@ const renderOneLine = ( column.length || DEFAULT_COLUMN_LEN ) ); - line.addCharsWithColor(DEFAULT_ROW_FONT_COLOR, ` ${tableStyle.vertical}`); + line.addCharsWithColor('', ` ${tableStyle.vertical}`); // dont Color the Column borders }); return line.renderConsole(); }; diff --git a/test/__snapshots__/alignment.test.ts.snap b/test/__snapshots__/alignment.test.ts.snap index 53518c87..1f1c5265 100644 --- a/test/__snapshots__/alignment.test.ts.snap +++ b/test/__snapshots__/alignment.test.ts.snap @@ -2,14 +2,14 @@ exports[`Testing column alignment all kind of alignments are working 1`] = ` "┌──────────────────────┬──────────────────────────────────────────┬────────────────────┐ -│ red_left_align_index │  right_align_text │ green_value_center │ +│ red_left_align_index │  right_align_text │ green_value_center │ ├──────────────────────┼──────────────────────────────────────────┼────────────────────┤ -│ 2  │  This row is blue │  10.212  │ -│ 3  │  I would like some red wine please │  10.212  │ -│ 4  │  I would like some cyan wine please │  10.212  │ -│ 5  │ I would like some white_bold wine please │  10.212  │ -│ 6  │  I would like some crimson sky please │  10.212  │ -│ 7  │  I would like some green gemuse please │  20  │ -│ 8  │  I would like some gelb bananen bitte │  100  │ +│ 2  │  This row is blue │  10.212  │ +│ 3  │  I would like some red wine please │  10.212  │ +│ 4  │  I would like some cyan wine please │  10.212  │ +│ 5  │ I would like some white_bold wine please │  10.212  │ +│ 6  │  I would like some crimson sky please │  10.212  │ +│ 7  │  I would like some green gemuse please │  20  │ +│ 8  │  I would like some gelb bananen bitte │  100  │ └──────────────────────┴──────────────────────────────────────────┴────────────────────┘" `; diff --git a/test/__snapshots__/cellColor.test.ts.snap b/test/__snapshots__/cellColor.test.ts.snap index a50bde2b..0fd6a771 100644 --- a/test/__snapshots__/cellColor.test.ts.snap +++ b/test/__snapshots__/cellColor.test.ts.snap @@ -2,11 +2,11 @@ exports[`Example: Print a simple Table with cell colors cell colors are working 1`] = ` "┌───────┬─────────┬────────┐ -│ index │  text │  value │ +│ index │  text │  value │ ├───────┼─────────┼────────┤ -│  1 │  red │ 10.212 │ -│  2 │  green │  20 │ -│  3 │  yellow │  100 │ -│  4 │ magenta │  300 │ +│  1 │  red │ 10.212 │ +│  2 │  green │  20 │ +│  3 │  yellow │  100 │ +│  4 │ magenta │  300 │ └───────┴─────────┴────────┘" `; diff --git a/test/__snapshots__/columnColor.test.ts.snap b/test/__snapshots__/columnColor.test.ts.snap index cbd66914..3cad80d4 100644 --- a/test/__snapshots__/columnColor.test.ts.snap +++ b/test/__snapshots__/columnColor.test.ts.snap @@ -2,14 +2,14 @@ exports[`Example: Print a simple Table with column colors column colors are working 1`] = ` "┌──────────────────────┬──────────────────────────────────────────┬─────────────┐ -│ red_left_align_index │  right_align_text │ green_value │ +│ red_left_align_index │  right_align_text │ green_value │ ├──────────────────────┼──────────────────────────────────────────┼─────────────┤ -│ 2  │  This row is blue │  10.212 │ -│ 3  │  I would like some red wine please │  10.212 │ -│ 4  │  I would like some cyan wine please │  10.212 │ -│ 5  │ I would like some white_bold wine please │  10.212 │ -│ 6  │  I would like some crimson sky please │  10.212 │ -│ 7  │  I would like some green gemuse please │  20 │ -│ 8  │  I would like some gelb bananen bitte │  100 │ +│ 2  │  This row is blue │  10.212 │ +│ 3  │  I would like some red wine please │  10.212 │ +│ 4  │  I would like some cyan wine please │  10.212 │ +│ 5  │ I would like some white_bold wine please │  10.212 │ +│ 6  │  I would like some crimson sky please │  10.212 │ +│ 7  │  I would like some green gemuse please │  20 │ +│ 8  │  I would like some gelb bananen bitte │  100 │ └──────────────────────┴──────────────────────────────────────────┴─────────────┘" `; diff --git a/test/__snapshots__/computedColumns.test.ts.snap b/test/__snapshots__/computedColumns.test.ts.snap index 21e30a58..52aeeb48 100644 --- a/test/__snapshots__/computedColumns.test.ts.snap +++ b/test/__snapshots__/computedColumns.test.ts.snap @@ -2,20 +2,20 @@ exports[`Example: Print a simple Table with Computed Columns Computed Columns are working 1`] = ` "┌────────────┬─────────────┬─────┬─────────────┬──────────────┬─────┬─────────────┬──────────────┐ -│ red_amount │ blue_amount │ sum │ red_percent │ blue_percent │ sum │ red_percent │ blue_percent │ +│ red_amount │ blue_amount │ sum │ red_percent │ blue_percent │ sum │ red_percent │ blue_percent │ ├────────────┼─────────────┼─────┼─────────────┼──────────────┼─────┼─────────────┼──────────────┤ -│  2 │  3 │  5 │  40.00 │  60.00 │  5 │  40.00 │  60.00 │ -│  1 │  1 │  2 │  50.00 │  50.00 │  2 │  50.00 │  50.00 │ -│  5 │  6 │  11 │  45.45 │  54.55 │  11 │  45.45 │  54.55 │ +│  2 │  3 │  5 │  40.00 │  60.00 │  5 │  40.00 │  60.00 │ +│  1 │  1 │  2 │  50.00 │  50.00 │  2 │  50.00 │  50.00 │ +│  5 │  6 │  11 │  45.45 │  54.55 │  11 │  45.45 │  54.55 │ └────────────┴─────────────┴─────┴─────────────┴──────────────┴─────┴─────────────┴──────────────┘" `; exports[`Example: Print a simple Table with Computed Columns Computed Columns are working with Title 1`] = ` "┌────────────┬─────────────┬─────┬─────────────┬──────────────┬─────┬─────────────┬──────────────┐ -│ red_amount │ blue_amount │ sum │ Red Percent │ Blue Percent │ sum │ Red Percent │ Blue Percent │ +│ red_amount │ blue_amount │ sum │ Red Percent │ Blue Percent │ sum │ Red Percent │ Blue Percent │ ├────────────┼─────────────┼─────┼─────────────┼──────────────┼─────┼─────────────┼──────────────┤ -│  2 │  3 │  5 │  40.00 │  60.00 │  5 │  40.00 │  60.00 │ -│  1 │  1 │  2 │  50.00 │  50.00 │  2 │  50.00 │  50.00 │ -│  5 │  6 │  11 │  45.45 │  54.55 │  11 │  45.45 │  54.55 │ +│  2 │  3 │  5 │  40.00 │  60.00 │  5 │  40.00 │  60.00 │ +│  1 │  1 │  2 │  50.00 │  50.00 │  2 │  50.00 │  50.00 │ +│  5 │  6 │  11 │  45.45 │  54.55 │  11 │  45.45 │  54.55 │ └────────────┴─────────────┴─────┴─────────────┴──────────────┴─────┴─────────────┴──────────────┘" `; diff --git a/test/__snapshots__/customizedColor.test.ts.snap b/test/__snapshots__/customizedColor.test.ts.snap index 42160036..3728c907 100644 --- a/test/__snapshots__/customizedColor.test.ts.snap +++ b/test/__snapshots__/customizedColor.test.ts.snap @@ -2,10 +2,10 @@ exports[`Example: Print a simple Table with Custom column colors Custom column colors are working 1`] = ` "┌──────────────────────┬──────────────────────────┬─────────────┐ -│ red_left_align_index │  right_align_text │ green_value │ +│ red_left_align_index │  right_align_text │ green_value │ ├──────────────────────┼──────────────────────────┼─────────────┤ -│ 2  │ This is my defined Green │  10.212 │ -│ 3  │ This row is blue as well │  10.212 │ -│ 4  │  This row is green │  10.212 │ +│ 2  │ This is my defined Green │  10.212 │ +│ 3  │ This row is blue as well │  10.212 │ +│ 4  │  This row is green │  10.212 │ └──────────────────────┴──────────────────────────┴─────────────┘" `; diff --git a/test/__snapshots__/foreignLanguage.test.ts.snap b/test/__snapshots__/foreignLanguage.test.ts.snap index 996a7d71..cae7628a 100644 --- a/test/__snapshots__/foreignLanguage.test.ts.snap +++ b/test/__snapshots__/foreignLanguage.test.ts.snap @@ -2,30 +2,30 @@ exports[`Example: Print a simple Table with cell colors coloring is working 1`] = ` "┌─────────────┬───────────────────────────────────────────────┐ -│  Ticket No │  Description │ +│  Ticket No │  Description │ ├─────────────┼───────────────────────────────────────────────┤ -│  ISSUE-1231 │ Some alphabets 这里是中文这里是中文这里是中文 │ -│ ISSUE-22222 │  Some Summary 这里是中文这里是中文 │ -│  ISSUE-1 │  Description 这里是中文 │ +│  ISSUE-1231 │ Some alphabets 这里是中文这里是中文这里是中文 │ +│ ISSUE-22222 │  Some Summary 这里是中文这里是中文 │ +│  ISSUE-1 │  Description 这里是中文 │ └─────────────┴───────────────────────────────────────────────┘" `; exports[`Example: Print a simple Table with cell colors customized border is working 1`] = ` "╔═════════════╦═══════════════════════════════════════════════╗ -║  Ticket No ║  Description ║ +║  Ticket No ║  Description ║ ╟═════════════╬═══════════════════════════════════════════════╢ -║  ISSUE-1231 ║ Some alphabets 这里是中文这里是中文这里是中文 ║ -║ ISSUE-22222 ║  Some Summary 这里是中文这里是中文 ║ -║  ISSUE-1 ║  Description 这里是中文 ║ +║  ISSUE-1231 ║ Some alphabets 这里是中文这里是中文这里是中文 ║ +║ ISSUE-22222 ║  Some Summary 这里是中文这里是中文 ║ +║  ISSUE-1 ║  Description 这里是中文 ║ ╚═════════════╩═══════════════════════════════════════════════╝" `; exports[`Example: Print a simple Table with cell colors foreign alphabets are working 1`] = ` "┌───────────────────────────────────────────────┬───────────────┐ -│  Description │  Ticket No │ +│  Description │  Ticket No │ ├───────────────────────────────────────────────┼───────────────┤ -│ Some alphabets 这里是中文这里是中文这里是中文 │  ISSUE-1231 │ -│  Some Summary 这里是中文这里是中文 │  ISSUE-22222 │ -│  Description 这里是中文 │ ISSUE-Foreign │ +│ Some alphabets 这里是中文这里是中文这里是中文 │  ISSUE-1231 │ +│  Some Summary 这里是中文这里是中文 │  ISSUE-22222 │ +│  Description 这里是中文 │ ISSUE-Foreign │ └───────────────────────────────────────────────┴───────────────┘" `; diff --git a/test/__snapshots__/lineWidthLimit.test.ts.snap b/test/__snapshots__/lineWidthLimit.test.ts.snap index 15189ba1..5ac49653 100644 --- a/test/__snapshots__/lineWidthLimit.test.ts.snap +++ b/test/__snapshots__/lineWidthLimit.test.ts.snap @@ -2,75 +2,75 @@ exports[`Testing column max Width Max Line Limit 1`] = ` "┌───────┬────────────┬──────────┐ -│ Index │  maxLen:10 │ maxLen:8 │ +│ Index │  maxLen:10 │ maxLen:8 │ ├───────┼────────────┼──────────┤ -│  1  │  This row │ This row │ -│   │  is blue │ is green │ -│   │   │  column  │ -│  10  │  This row │ This row │ -│   │  is blue │ is green │ -│   │  but again │  column  │ -│   │  another │  but a  │ -│   │  line │  little  │ -│   │   │  longer  │ -│   │   │ to make  │ -│   │   │  life  │ -│   │   │  harder  │ -│  2  │  The last │  Thank  │ -│   │ one I dont │ god this │ -│   │  know what │  is the  │ -│   │  the color │ last one │ -│   │  is │   │ +│  1  │  This row │ This row │ +│   │  is blue │ is green │ +│   │   │  column  │ +│  10  │  This row │ This row │ +│   │  is blue │ is green │ +│   │  but again │  column  │ +│   │  another │  but a  │ +│   │  line │  little  │ +│   │   │  longer  │ +│   │   │ to make  │ +│   │   │  life  │ +│   │   │  harder  │ +│  2  │  The last │  Thank  │ +│   │ one I dont │ god this │ +│   │  know what │  is the  │ +│   │  the color │ last one │ +│   │  is │   │ └───────┴────────────┴──────────┘" `; exports[`Testing column max Width Min Line Limit 1`] = ` "┌──────────────────────────────────────────────────────────────────────────────────────────────────────┬──────────────────────────────────────────────────────────────────┐ -│  MnWid:100,align:r │  MnWid:20,align:c  │ +│  MnWid:100,align:r │  MnWid:20,align:c  │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────┤ -│  This row is blue │  This row is green column  │ -│  This row is blue │ This row is green column but a little longer to make life harder │ -│  The last one │  Thank god this is the last one  │ +│  This row is blue │  This row is green column  │ +│  This row is blue │ This row is green column but a little longer to make life harder │ +│  The last one │  Thank god this is the last one  │ └──────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────┘" `; exports[`Testing column max Width Min/Max Line Limit 1`] = ` "┌───────┬────────────────────────────────────────────┬────────────────────┐ -│ Index │  MinWidth:20 │ MinWidth:10,max:15 │ +│ Index │  MinWidth:20 │ MinWidth:10,max:15 │ ├───────┼────────────────────────────────────────────┼────────────────────┤ -│  1  │  This row is blue │ This row is green  │ -│   │   │  column  │ -│  10  │  This row is blue but again another line │ This row is green  │ -│   │   │  column but a  │ -│   │   │  little longer to  │ -│   │   │  make life harder  │ -│  2  │ The last one I dont know what the color is │ Thank god this is  │ -│   │   │  the last one  │ +│  1  │  This row is blue │ This row is green  │ +│   │   │  column  │ +│  10  │  This row is blue but again another line │ This row is green  │ +│   │   │  column but a  │ +│   │   │  little longer to  │ +│   │   │  make life harder  │ +│  2  │ The last one I dont know what the color is │ Thank god this is  │ +│   │   │  the last one  │ └───────┴────────────────────────────────────────────┴────────────────────┘" `; exports[`Testing column max Width Simple Line Limit 1`] = ` "┌──────────────────────┬──────────────────┬────────┐ -│ red_left_align_index │ right_align_text │ green  │ +│ red_left_align_index │ right_align_text │ green  │ ├──────────────────────┼──────────────────┼────────┤ -│ 2  │ This row is blue │ 10.212 │ -│ 3  │  I would like │ 10.212 │ -│   │  some red wine │   │ -│   │  please │   │ -│ 4  │  I would like │ 10.212 │ -│   │  some cyan wine │   │ -│   │  please │   │ -│ 5  │  I would like │ 10.212 │ -│   │  some white_bold │   │ -│   │  wine please │   │ -│ 6  │  I would like │ 10.212 │ -│   │ some crimson sky │   │ -│   │  please │   │ -│ 7  │  I would like │  20  │ -│   │  some green │   │ -│   │  gemuse please │   │ -│ 8  │  I would like │  100  │ -│   │  some gelb │   │ -│   │  bananen bitte │   │ +│ 2  │ This row is blue │ 10.212 │ +│ 3  │  I would like │ 10.212 │ +│   │  some red wine │   │ +│   │  please │   │ +│ 4  │  I would like │ 10.212 │ +│   │  some cyan wine │   │ +│   │  please │   │ +│ 5  │  I would like │ 10.212 │ +│   │  some white_bold │   │ +│   │  wine please │   │ +│ 6  │  I would like │ 10.212 │ +│   │ some crimson sky │   │ +│   │  please │   │ +│ 7  │  I would like │  20  │ +│   │  some green │   │ +│   │  gemuse please │   │ +│ 8  │  I would like │  100  │ +│   │  some gelb │   │ +│   │  bananen bitte │   │ └──────────────────────┴──────────────────┴────────┘" `; diff --git a/test/__snapshots__/types.test.ts.snap b/test/__snapshots__/types.test.ts.snap index 519ce784..2e0f6a2d 100644 --- a/test/__snapshots__/types.test.ts.snap +++ b/test/__snapshots__/types.test.ts.snap @@ -2,17 +2,17 @@ exports[`Testing column alignment all kind of alignments are working 1`] = ` "┌──────────────────────┬──────────────────┬────────────────────┐ -│ red_left_align_index │ right_align_text │ green_value_center │ +│ red_left_align_index │ right_align_text │ green_value_center │ ├──────────────────────┼──────────────────┼────────────────────┤ -│ 2  │ This row is blue │  10.212  │ +│ 2  │ This row is blue │  10.212  │ └──────────────────────┴──────────────────┴────────────────────┘" `; exports[`Testing column alignment should allow chaining add methods 1`] = ` "┌─────┬─────┐ -│ foo │ bar │ +│ foo │ bar │ ├─────┼─────┤ -│  1 │   │ -│   │  2 │ +│  1 │   │ +│   │  2 │ └─────┴─────┘" `; diff --git a/test/internalTable/__snapshots__/alignment.test.ts.snap b/test/internalTable/__snapshots__/alignment.test.ts.snap new file mode 100644 index 00000000..1f1c5265 --- /dev/null +++ b/test/internalTable/__snapshots__/alignment.test.ts.snap @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing column alignment all kind of alignments are working 1`] = ` +"┌──────────────────────┬──────────────────────────────────────────┬────────────────────┐ +│ red_left_align_index │  right_align_text │ green_value_center │ +├──────────────────────┼──────────────────────────────────────────┼────────────────────┤ +│ 2  │  This row is blue │  10.212  │ +│ 3  │  I would like some red wine please │  10.212  │ +│ 4  │  I would like some cyan wine please │  10.212  │ +│ 5  │ I would like some white_bold wine please │  10.212  │ +│ 6  │  I would like some crimson sky please │  10.212  │ +│ 7  │  I would like some green gemuse please │  20  │ +│ 8  │  I would like some gelb bananen bitte │  100  │ +└──────────────────────┴──────────────────────────────────────────┴────────────────────┘" +`; diff --git a/test/internalTable/__snapshots__/borderStyle.test.ts.snap b/test/internalTable/__snapshots__/borderStyle.test.ts.snap new file mode 100644 index 00000000..209fa6c0 --- /dev/null +++ b/test/internalTable/__snapshots__/borderStyle.test.ts.snap @@ -0,0 +1,21 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Example: Check if borders are styled properly print a RED table 1`] = ` +"╔═══════╦═══════════════════════════════════════╦════════╗ +║ index ║  text ║  value ║ +╟═══════╬═══════════════════════════════════════╬════════╢ +║ 1  ║  I would like some red wine please ║ 10.212 ║ +║ 2  ║ I would like some green gemuse please ║  20 ║ +║ 3  ║  I would like some gelb bananen bitte ║  100 ║ +╚═══════╩═══════════════════════════════════════╩════════╝" +`; + +exports[`Example: Check if borders are styled properly print a fat border table 1`] = ` +"╔═══════╦═══════════════════════════════════════╦════════╗ +║ index ║  text ║  value ║ +╟═══════╬═══════════════════════════════════════╬════════╢ +║ 1  ║  I would like some red wine please ║ 10.212 ║ +║ 2  ║ I would like some green gemuse please ║  20 ║ +║ 3  ║  I would like some gelb bananen bitte ║  100 ║ +╚═══════╩═══════════════════════════════════════╩════════╝" +`; diff --git a/test/internalTable/__snapshots__/columnColor.test.ts.snap b/test/internalTable/__snapshots__/columnColor.test.ts.snap new file mode 100644 index 00000000..3cad80d4 --- /dev/null +++ b/test/internalTable/__snapshots__/columnColor.test.ts.snap @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Example: Print a simple Table with column colors column colors are working 1`] = ` +"┌──────────────────────┬──────────────────────────────────────────┬─────────────┐ +│ red_left_align_index │  right_align_text │ green_value │ +├──────────────────────┼──────────────────────────────────────────┼─────────────┤ +│ 2  │  This row is blue │  10.212 │ +│ 3  │  I would like some red wine please │  10.212 │ +│ 4  │  I would like some cyan wine please │  10.212 │ +│ 5  │ I would like some white_bold wine please │  10.212 │ +│ 6  │  I would like some crimson sky please │  10.212 │ +│ 7  │  I would like some green gemuse please │  20 │ +│ 8  │  I would like some gelb bananen bitte │  100 │ +└──────────────────────┴──────────────────────────────────────────┴─────────────┘" +`; diff --git a/test/internalTable/__snapshots__/computedColumn.test.ts.snap b/test/internalTable/__snapshots__/computedColumn.test.ts.snap new file mode 100644 index 00000000..406163a7 --- /dev/null +++ b/test/internalTable/__snapshots__/computedColumn.test.ts.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing Computed Column all kind of computedColumns are working 1`] = ` +"┌────────────┬─────────────┬─────┬─────────────┬──────────────┐ +│ red_amount │ blue_amount │ sum │ red_percent │ blue_percent │ +├────────────┼─────────────┼─────┼─────────────┼──────────────┤ +│  2 │  3 │  5 │  40.00 │  60.00 │ +│  1 │  1 │  2 │  50.00 │  50.00 │ +│  5 │  6 │  11 │  45.45 │  54.55 │ +└────────────┴─────────────┴─────┴─────────────┴──────────────┘" +`; diff --git a/test/internalTable/__snapshots__/enableDisable.test.ts.snap b/test/internalTable/__snapshots__/enableDisable.test.ts.snap new file mode 100644 index 00000000..dcc3547b --- /dev/null +++ b/test/internalTable/__snapshots__/enableDisable.test.ts.snap @@ -0,0 +1,29 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing column Enable and Disable disable basic example 1`] = ` +"┌────────────────────┐ +│ green_value_center │ +├────────────────────┤ +│  10.212 │ +│  10.212 │ +│  10.212 │ +│  10.212 │ +│  10.212 │ +│  20 │ +│  100 │ +└────────────────────┘" +`; + +exports[`Testing column Enable and Disable enable basic example 1`] = ` +"┌──────────────────────┬──────────────────────────────────────────┐ +│ red_left_align_index │  right_align_text │ +├──────────────────────┼──────────────────────────────────────────┤ +│  2 │  This row is blue │ +│  3 │  I would like some red wine please │ +│  4 │  I would like some cyan wine please │ +│  5 │ I would like some white_bold wine please │ +│  6 │  I would like some crimson sky please │ +│  7 │  I would like some green gemuse please │ +│  8 │  I would like some gelb bananen bitte │ +└──────────────────────┴──────────────────────────────────────────┘" +`; diff --git a/test/internalTable/__snapshots__/filter.test.ts.snap b/test/internalTable/__snapshots__/filter.test.ts.snap new file mode 100644 index 00000000..f4088698 --- /dev/null +++ b/test/internalTable/__snapshots__/filter.test.ts.snap @@ -0,0 +1,10 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing column alignment all kind of alignments are working 1`] = ` +"┌──────────────────────┬──────────────────────────────────────────┬────────────────────┐ +│ red_left_align_index │  right_align_text │ green_value_center │ +├──────────────────────┼──────────────────────────────────────────┼────────────────────┤ +│ 2  │  This row is blue │  10.212  │ +│ 3  │  I would like some red wine please │  10.212  │ +└──────────────────────┴──────────────────────────────────────────┴────────────────────┘" +`; diff --git a/test/internalTable/__snapshots__/headerTitle.test.ts.snap b/test/internalTable/__snapshots__/headerTitle.test.ts.snap new file mode 100644 index 00000000..b6b825be --- /dev/null +++ b/test/internalTable/__snapshots__/headerTitle.test.ts.snap @@ -0,0 +1,10 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing Title Of Column title is used in table printing 1`] = ` +"┌──────────────────────┬───────────────────────────────────┬────────────────────────┐ +│ Red Left Align Index │  Right Align Text │ Big Green Value Center │ +├──────────────────────┼───────────────────────────────────┼────────────────────────┤ +│ 2  │  This row is blue │  10.212  │ +│ 3  │ I would like some red wine please │  10.212  │ +└──────────────────────┴───────────────────────────────────┴────────────────────────┘" +`; diff --git a/test/internalTable/__snapshots__/rowColor.test.ts.snap b/test/internalTable/__snapshots__/rowColor.test.ts.snap new file mode 100644 index 00000000..4a3b3b31 --- /dev/null +++ b/test/internalTable/__snapshots__/rowColor.test.ts.snap @@ -0,0 +1,28 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing Row coloring Batch Row coloring by each row 1`] = ` +"┌───────┬───────────────────┬───────┐ +│ index │  text │ value │ +├───────┼───────────────────┼───────┤ +│  3 │ green color text1 │  100 │ +│  4 │ green color text2 │  300 │ +└───────┴───────────────────┴───────┘" +`; + +exports[`Testing Row coloring Batch Row coloring is working 1`] = ` +"┌───────┬───────────────────┬───────┐ +│ index │  text │ value │ +├───────┼───────────────────┼───────┤ +│  3 │ green color text1 │  100 │ +│  4 │ green color text2 │  300 │ +└───────┴───────────────────┴───────┘" +`; + +exports[`Testing Row coloring Batch Row default coloring is working 1`] = ` +"┌───────┬───────────────────┬───────┐ +│ index │  text │ value │ +├───────┼───────────────────┼───────┤ +│  3 │ green color text1 │  100 │ +│  4 │ green color text2 │  300 │ +└───────┴───────────────────┴───────┘" +`; diff --git a/test/internalTable/__snapshots__/rowSeparator.test.ts.snap b/test/internalTable/__snapshots__/rowSeparator.test.ts.snap new file mode 100644 index 00000000..1d828615 --- /dev/null +++ b/test/internalTable/__snapshots__/rowSeparator.test.ts.snap @@ -0,0 +1,64 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing Row separator Batch Row default separator is working 1`] = ` +"┌───────┬───────────────────────┬───────┐ +│ index │  text │ value │ +├───────┼───────────────────────┼───────┤ +│  3 │ row default separator │  100 │ +│  4 │ row default separator │  300 │ +└───────┴───────────────────────┴───────┘" +`; + +exports[`Testing Row separator Batch Row separator by each row 1`] = ` +"┌───────┬───────────────────────┬───────┐ +│ index │  text │ value │ +├───────┼───────────────────────┼───────┤ +│  3 │ row without separator │  100 │ +│  4 │  row with separator │  300 │ +├───────┼───────────────────────┼───────┤ +│  5 │ row without separator │  100 │ +└───────┴───────────────────────┴───────┘" +`; + +exports[`Testing Row separator Batch Row separator combined with sorting 1`] = ` +"┌───────┬───────────────────────┬───────┐ +│ index │  text │ value │ +├───────┼───────────────────────┼───────┤ +│  1 │ row inherit separator │  100 │ +├───────┼───────────────────────┼───────┤ +│  2 │  row with separator │  100 │ +├───────┼───────────────────────┼───────┤ +│  3 │ row without separator │  100 │ +│  4 │ row without separator │  100 │ +│  5 │  row with separator │  100 │ +└───────┴───────────────────────┴───────┘" +`; + +exports[`Testing Row separator Batch Row separator is working 1`] = ` +"┌───────┬────────────────────┬───────┐ +│ index │  text │ value │ +├───────┼────────────────────┼───────┤ +│  3 │ row with separator │  100 │ +├───────┼────────────────────┼───────┤ +│  4 │ row with separator │  300 │ +└───────┴────────────────────┴───────┘" +`; + +exports[`Testing Row separator Batch Row table separator option is working 1`] = ` +"┌───────┬─────────────────────┬───────┐ +│ index │  text │ value │ +├───────┼─────────────────────┼───────┤ +│  3 │ table row separator │  100 │ +├───────┼─────────────────────┼───────┤ +│  4 │ table row separator │  300 │ +└───────┴─────────────────────┴───────┘" +`; + +exports[`Testing Row separator Batch Row table separator override is working 1`] = ` +"┌───────┬──────────────────────────────┬───────┐ +│ index │  text │ value │ +├───────┼──────────────────────────────┼───────┤ +│  3 │ override table row separator │  100 │ +│  4 │ override table row separator │  300 │ +└───────┴──────────────────────────────┴───────┘" +`; diff --git a/test/internalTable/__snapshots__/simpleTable.test.ts.snap b/test/internalTable/__snapshots__/simpleTable.test.ts.snap new file mode 100644 index 00000000..5d6f174f --- /dev/null +++ b/test/internalTable/__snapshots__/simpleTable.test.ts.snap @@ -0,0 +1,10 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Example: Print a simple Table without table instance creation simple print 1`] = ` +"┌───────┬──────────────────────────────────────┬───────┐ +│ index │  text │ value │ +├───────┼──────────────────────────────────────┼───────┤ +│  3 │ I would like some gelb bananen bitte │  100 │ +│  4 │  I hope batch update is working │  300 │ +└───────┴──────────────────────────────────────┴───────┘" +`; diff --git a/test/internalTable/__snapshots__/sorting.test.ts.snap b/test/internalTable/__snapshots__/sorting.test.ts.snap new file mode 100644 index 00000000..70fc3519 --- /dev/null +++ b/test/internalTable/__snapshots__/sorting.test.ts.snap @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing column alignment all kind of alignments are working 1`] = ` +"┌──────────────────────┬──────────────────────────────────────────┬────────────────────┐ +│ red_left_align_index │  right_align_text │ green_value_center │ +├──────────────────────┼──────────────────────────────────────────┼────────────────────┤ +│ 8  │  I would like some gelb bananen bitte │  100  │ +│ 7  │  I would like some green gemuse please │  20  │ +│ 6  │  I would like some crimson sky please │  10.212  │ +│ 5  │ I would like some white_bold wine please │  10.212  │ +│ 4  │  I would like some cyan wine please │  10.212  │ +│ 3  │  I would like some red wine please │  10.212  │ +│ 2  │  This row is blue │  10.212  │ +└──────────────────────┴──────────────────────────────────────────┴────────────────────┘" +`; diff --git a/test/internalTable/__snapshots__/title.test.ts.snap b/test/internalTable/__snapshots__/title.test.ts.snap new file mode 100644 index 00000000..0ac8a098 --- /dev/null +++ b/test/internalTable/__snapshots__/title.test.ts.snap @@ -0,0 +1,27 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing column alignment Simpler title test 1`] = ` +" Some Random Title  +┌──────────────────────┬────────────────────┬──────┬──────┬──────┐ +│ red_left_align_index │ green_value_center │ col1 │ col2 │ col2 │ +├──────────────────────┼────────────────────┼──────┼──────┼──────┤ +│ 3  │  10.212  │   │   │   │ +│ 4  │  10.212  │   │   │   │ +│ 5  │  10.212  │   │   │   │ +└──────────────────────┴────────────────────┴──────┴──────┴──────┘" +`; + +exports[`Testing column alignment all kind of alignments are working 1`] = ` +" Some Random Title  +┌──────────────────────┬──────────────────────────────────────────┬────────────────────┐ +│ red_left_align_index │  right_align_text │ green_value_center │ +├──────────────────────┼──────────────────────────────────────────┼────────────────────┤ +│ 2  │  This row is blue │  10.212  │ +│ 3  │  I would like some red wine please │  10.212  │ +│ 4  │  I would like some cyan wine please │  10.212  │ +│ 5  │ I would like some white_bold wine please │  10.212  │ +│ 6  │  I would like some crimson sky please │  10.212  │ +│ 7  │  I would like some green gemuse please │  20  │ +│ 8  │  I would like some gelb bananen bitte │  100  │ +└──────────────────────┴──────────────────────────────────────────┴────────────────────┘" +`; diff --git a/test/internalTable/alignment.test.ts b/test/internalTable/alignment.test.ts index e34581c1..3f57f20a 100644 --- a/test/internalTable/alignment.test.ts +++ b/test/internalTable/alignment.test.ts @@ -72,19 +72,7 @@ describe('Testing column alignment', () => { // print const returned = renderTable(p.table); - const expected = [ - '┌──────────────────────┬──────────────────────────────────────────┬────────────────────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mred_left_align_index\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m right_align_text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mgreen_value_center\u001b[0m\u001b[37m │\u001b[0m', - '├──────────────────────┼──────────────────────────────────────────┼────────────────────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m2 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[34m This row is blue\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m3 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[31m I would like some red wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m4 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[36m I would like some cyan wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m5 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mI would like some white_bold wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m6 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[38m I would like some crimson sky please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m7 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m I would like some green gemuse please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 20 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m8 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[33m I would like some gelb bananen bitte\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 100 \u001b[0m\u001b[37m │\u001b[0m', - '└──────────────────────┴──────────────────────────────────────────┴────────────────────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); }); diff --git a/test/internalTable/borderStyle.test.ts b/test/internalTable/borderStyle.test.ts index 177430b1..53fbe85a 100644 --- a/test/internalTable/borderStyle.test.ts +++ b/test/internalTable/borderStyle.test.ts @@ -57,17 +57,8 @@ describe('Example: Check if borders are styled properly', () => { // print const returned = renderTable(p.table); - - const expected = [ - '╔═══════╦═══════════════════════════════════════╦════════╗', - '\u001b[37m║\u001b[0m\u001b[37m \u001b[0m\u001b[01mindex\u001b[0m\u001b[37m ║\u001b[0m\u001b[37m \u001b[0m\u001b[01m text\u001b[0m\u001b[37m ║\u001b[0m\u001b[37m \u001b[0m\u001b[01m value\u001b[0m\u001b[37m ║\u001b[0m', - '╟═══════╬═══════════════════════════════════════╬════════╢', - '\u001b[37m║\u001b[0m\u001b[37m \u001b[0m\u001b[31m1 \u001b[0m\u001b[37m ║\u001b[0m\u001b[37m \u001b[0m\u001b[31m I would like some red wine please\u001b[0m\u001b[37m ║\u001b[0m\u001b[37m \u001b[0m\u001b[31m10.212\u001b[0m\u001b[37m ║\u001b[0m', - '\u001b[37m║\u001b[0m\u001b[37m \u001b[0m\u001b[32m2 \u001b[0m\u001b[37m ║\u001b[0m\u001b[37m \u001b[0m\u001b[32mI would like some green gemuse please\u001b[0m\u001b[37m ║\u001b[0m\u001b[37m \u001b[0m\u001b[32m 20\u001b[0m\u001b[37m ║\u001b[0m', - '\u001b[37m║\u001b[0m\u001b[37m \u001b[0m\u001b[33m3 \u001b[0m\u001b[37m ║\u001b[0m\u001b[37m \u001b[0m\u001b[33m I would like some gelb bananen bitte\u001b[0m\u001b[37m ║\u001b[0m\u001b[37m \u001b[0m\u001b[33m 100\u001b[0m\u001b[37m ║\u001b[0m', - '╚═══════╩═══════════════════════════════════════╩════════╝', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); it('print a RED table', () => { @@ -125,16 +116,7 @@ describe('Example: Check if borders are styled properly', () => { // print const returned = renderTable(p.table); - - const expected = [ - '\u001b[31m╔\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m╦\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m╦\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m╗\u001b[0m', - '\u001b[37m\u001b[31m║\u001b[0m\u001b[0m\u001b[37m \u001b[0m\u001b[01mindex\u001b[0m\u001b[37m \u001b[31m║\u001b[0m\u001b[0m\u001b[37m \u001b[0m\u001b[01m text\u001b[0m\u001b[37m \u001b[31m║\u001b[0m\u001b[0m\u001b[37m \u001b[0m\u001b[01m value\u001b[0m\u001b[37m \u001b[31m║\u001b[0m\u001b[0m', - '\u001b[31m╟\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m╬\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m╬\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m╢\u001b[0m', - '\u001b[37m\u001b[31m║\u001b[0m\u001b[0m\u001b[37m \u001b[0m\u001b[31m1 \u001b[0m\u001b[37m \u001b[31m║\u001b[0m\u001b[0m\u001b[37m \u001b[0m\u001b[31m I would like some red wine please\u001b[0m\u001b[37m \u001b[31m║\u001b[0m\u001b[0m\u001b[37m \u001b[0m\u001b[31m10.212\u001b[0m\u001b[37m \u001b[31m║\u001b[0m\u001b[0m', - '\u001b[37m\u001b[31m║\u001b[0m\u001b[0m\u001b[37m \u001b[0m\u001b[32m2 \u001b[0m\u001b[37m \u001b[31m║\u001b[0m\u001b[0m\u001b[37m \u001b[0m\u001b[32mI would like some green gemuse please\u001b[0m\u001b[37m \u001b[31m║\u001b[0m\u001b[0m\u001b[37m \u001b[0m\u001b[32m 20\u001b[0m\u001b[37m \u001b[31m║\u001b[0m\u001b[0m', - '\u001b[37m\u001b[31m║\u001b[0m\u001b[0m\u001b[37m \u001b[0m\u001b[33m3 \u001b[0m\u001b[37m \u001b[31m║\u001b[0m\u001b[0m\u001b[37m \u001b[0m\u001b[33m I would like some gelb bananen bitte\u001b[0m\u001b[37m \u001b[31m║\u001b[0m\u001b[0m\u001b[37m \u001b[0m\u001b[33m 100\u001b[0m\u001b[37m \u001b[31m║\u001b[0m\u001b[0m', - '\u001b[31m╚\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m╩\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m╩\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m═\u001b[0m\u001b[31m╝\u001b[0m', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); }); diff --git a/test/internalTable/columnColor.test.ts b/test/internalTable/columnColor.test.ts index 71935fa2..ef7504fc 100644 --- a/test/internalTable/columnColor.test.ts +++ b/test/internalTable/columnColor.test.ts @@ -72,20 +72,7 @@ describe('Example: Print a simple Table with column colors', () => { // print const returned = renderTable(p.table); - - const expected = [ - '┌──────────────────────┬──────────────────────────────────────────┬─────────────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mred_left_align_index\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m right_align_text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mgreen_value\u001b[0m\u001b[37m │\u001b[0m', - '├──────────────────────┼──────────────────────────────────────────┼─────────────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m2 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[34m This row is blue\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m3 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[31m I would like some red wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m4 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[36m I would like some cyan wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m5 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mI would like some white_bold wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m6 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[38m I would like some crimson sky please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m7 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m I would like some green gemuse please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 20\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m8 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[33m I would like some gelb bananen bitte\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 100\u001b[0m\u001b[37m │\u001b[0m', - '└──────────────────────┴──────────────────────────────────────────┴─────────────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); }); diff --git a/test/internalTable/computedColumn.test.ts b/test/internalTable/computedColumn.test.ts index 05ef9c82..e35592a6 100644 --- a/test/internalTable/computedColumn.test.ts +++ b/test/internalTable/computedColumn.test.ts @@ -41,15 +41,7 @@ describe('Testing Computed Column', () => { // print const returned = renderTable(p.table); - const expected = [ - '┌────────────┬─────────────┬─────┬─────────────┬──────────────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mred_amount\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mblue_amount\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01msum\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mred_percent\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mblue_percent\u001b[0m\u001b[37m │\u001b[0m', - '├────────────┼─────────────┼─────┼─────────────┼──────────────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m 2\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 3\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 5\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 40.00\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 60.00\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m 1\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 1\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 2\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 50.00\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 50.00\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m 5\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 6\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 11\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 45.45\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 54.55\u001b[0m\u001b[37m │\u001b[0m', - '└────────────┴─────────────┴─────┴─────────────┴──────────────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); }); diff --git a/test/internalTable/enableDisable.test.ts b/test/internalTable/enableDisable.test.ts index 45fc3363..2f38c066 100644 --- a/test/internalTable/enableDisable.test.ts +++ b/test/internalTable/enableDisable.test.ts @@ -70,20 +70,8 @@ describe('Testing column Enable and Disable', () => { const returned = renderTable(p.table); console.log(returned); - const expected = [ - '┌──────────────────────┬──────────────────────────────────────────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mred_left_align_index\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m right_align_text\u001b[0m\u001b[37m │\u001b[0m', - '├──────────────────────┼──────────────────────────────────────────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[34m 2\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[34m This row is blue\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m 3\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[31m I would like some red wine please\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[36m 4\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[36m I would like some cyan wine please\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01m 5\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mI would like some white_bold wine please\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[38m 6\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[38m I would like some crimson sky please\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[32m 7\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m I would like some green gemuse please\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[33m 8\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[33m I would like some gelb bananen bitte\u001b[0m\u001b[37m │\u001b[0m', - '└──────────────────────┴──────────────────────────────────────────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); it('disable basic example', () => { @@ -154,19 +142,7 @@ describe('Testing column Enable and Disable', () => { const returned = renderTable(p.table); console.log(returned); - const expected = [ - '┌────────────────────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mgreen_value_center\u001b[0m\u001b[37m │\u001b[0m', - '├────────────────────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[34m 10.212\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m 10.212\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[36m 10.212\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01m 10.212\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[38m 10.212\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[32m 20\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[33m 100\u001b[0m\u001b[37m │\u001b[0m', - '└────────────────────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); }); diff --git a/test/internalTable/filter.test.ts b/test/internalTable/filter.test.ts index 5a4d4af2..f52ee935 100644 --- a/test/internalTable/filter.test.ts +++ b/test/internalTable/filter.test.ts @@ -73,15 +73,7 @@ describe('Testing column alignment', () => { // print const returned = renderTable(p.table); - - const expected = [ - '┌──────────────────────┬──────────────────────────────────────────┬────────────────────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mred_left_align_index\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m right_align_text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mgreen_value_center\u001b[0m\u001b[37m │\u001b[0m', - '├──────────────────────┼──────────────────────────────────────────┼────────────────────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[34m2 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[34m This row is blue\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[34m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m3 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[31m I would like some red wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[31m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '└──────────────────────┴──────────────────────────────────────────┴────────────────────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); }); diff --git a/test/internalTable/headerTitle.test.ts b/test/internalTable/headerTitle.test.ts index b2fb12f8..d842a9c2 100644 --- a/test/internalTable/headerTitle.test.ts +++ b/test/internalTable/headerTitle.test.ts @@ -46,14 +46,7 @@ describe('Testing Title Of Column', () => { const returned = renderTable(p.table); console.log(returned); - const expected = [ - '┌──────────────────────┬───────────────────────────────────┬────────────────────────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mRed Left Align Index\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m Right Align Text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mBig Green Value Center\u001b[0m\u001b[37m │\u001b[0m', - '├──────────────────────┼───────────────────────────────────┼────────────────────────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[34m2 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[34m This row is blue\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[34m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m3 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[31mI would like some red wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[31m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '└──────────────────────┴───────────────────────────────────┴────────────────────────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); }); diff --git a/test/internalTable/rowColor.test.ts b/test/internalTable/rowColor.test.ts index c04c9756..eec0c5f7 100644 --- a/test/internalTable/rowColor.test.ts +++ b/test/internalTable/rowColor.test.ts @@ -18,16 +18,8 @@ describe('Testing Row coloring', () => { // print const returned = renderTable(p.table); - - const expected = [ - '┌───────┬───────────────────┬───────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mindex\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mvalue\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼───────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[32m 3\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32mgreen color text1\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 100\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[32m 4\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32mgreen color text2\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 300\u001b[0m\u001b[37m │\u001b[0m', - '└───────┴───────────────────┴───────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); it('Batch Row default coloring is working', () => { @@ -42,16 +34,8 @@ describe('Testing Row coloring', () => { // print const returned = renderTable(p.table); - - const expected = [ - '┌───────┬───────────────────┬───────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mindex\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mvalue\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼───────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 3\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mgreen color text1\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 100\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 4\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mgreen color text2\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 300\u001b[0m\u001b[37m │\u001b[0m', - '└───────┴───────────────────┴───────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); it('Batch Row coloring is working', () => { @@ -69,15 +53,7 @@ describe('Testing Row coloring', () => { // print const returned = renderTable(p.table); - - const expected = [ - '┌───────┬───────────────────┬───────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mindex\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mvalue\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼───────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[32m 3\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32mgreen color text1\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 100\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[32m 4\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32mgreen color text2\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 300\u001b[0m\u001b[37m │\u001b[0m', - '└───────┴───────────────────┴───────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); }); diff --git a/test/internalTable/rowSeparator.test.ts b/test/internalTable/rowSeparator.test.ts index e1d261e1..0ec9c80e 100644 --- a/test/internalTable/rowSeparator.test.ts +++ b/test/internalTable/rowSeparator.test.ts @@ -18,17 +18,8 @@ describe('Testing Row separator', () => { // print const returned = renderTable(p.table); - const expected = [ - '┌───────┬───────────────────────┬───────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mindex\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mvalue\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼───────────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 3\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mrow without separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 100\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 4\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m row with separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 300\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼───────────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 5\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mrow without separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 100\u001b[0m\u001b[37m │\u001b[0m', - '└───────┴───────────────────────┴───────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); p.printTable(); }); @@ -44,16 +35,8 @@ describe('Testing Row separator', () => { // print const returned = renderTable(p.table); - - const expected = [ - '┌───────┬───────────────────────┬───────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mindex\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mvalue\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼───────────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 3\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mrow default separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 100\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 4\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mrow default separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 300\u001b[0m\u001b[37m │\u001b[0m', - '└───────┴───────────────────────┴───────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); p.printTable(); }); @@ -70,17 +53,8 @@ describe('Testing Row separator', () => { // print const returned = renderTable(p.table); - const expected = [ - '┌───────┬─────────────────────┬───────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mindex\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mvalue\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼─────────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 3\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mtable row separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 100\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼─────────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 4\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mtable row separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 300\u001b[0m\u001b[37m │\u001b[0m', - '└───────┴─────────────────────┴───────┘', - ]; - expect(returned).toBe(expected.join('\n')); - p.printTable(); + expect(returned).toMatchSnapshot(); + console.log(returned); }); it('Batch Row table separator override is working', () => { @@ -99,15 +73,8 @@ describe('Testing Row separator', () => { // print const returned = renderTable(p.table); - const expected = [ - '┌───────┬──────────────────────────────┬───────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mindex\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mvalue\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼──────────────────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 3\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37moverride table row separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 100\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 4\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37moverride table row separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 300\u001b[0m\u001b[37m │\u001b[0m', - '└───────┴──────────────────────────────┴───────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); p.printTable(); }); @@ -126,17 +93,8 @@ describe('Testing Row separator', () => { // print const returned = renderTable(p.table); - - const expected = [ - '┌───────┬────────────────────┬───────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mindex\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mvalue\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼────────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 3\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mrow with separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 100\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼────────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 4\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mrow with separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 300\u001b[0m\u001b[37m │\u001b[0m', - '└───────┴────────────────────┴───────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); it('Batch Row separator combined with sorting', () => { @@ -169,20 +127,8 @@ describe('Testing Row separator', () => { // print const returned = renderTable(p.table); - const expected = [ - '┌───────┬───────────────────────┬───────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mindex\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mvalue\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼───────────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 1\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mrow inherit separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 100\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼───────────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 2\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m row with separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 100\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼───────────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 3\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mrow without separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 100\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 4\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mrow without separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 100\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 5\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m row with separator\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 100\u001b[0m\u001b[37m │\u001b[0m', - '└───────┴───────────────────────┴───────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); p.printTable(); }); }); diff --git a/test/internalTable/simpleTable.test.ts b/test/internalTable/simpleTable.test.ts index 03593818..50d5ef10 100644 --- a/test/internalTable/simpleTable.test.ts +++ b/test/internalTable/simpleTable.test.ts @@ -11,16 +11,7 @@ describe('Example: Print a simple Table without table instance creation', () => ]; const tableStr: string = renderSimpleTable(testCases); - const expected = [ - '┌───────┬──────────────────────────────────────┬───────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mindex\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mvalue\u001b[0m\u001b[37m │\u001b[0m', - '├───────┼──────────────────────────────────────┼───────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 3\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37mI would like some gelb bananen bitte\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 100\u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m 4\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m I hope batch update is working\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m 300\u001b[0m\u001b[37m │\u001b[0m', - '└───────┴──────────────────────────────────────┴───────┘', - ]; - - expect(tableStr).toBe(expected.join('\n')); + expect(tableStr).toMatchSnapshot(); }); it('Make sure this function works dont throw exception', () => { diff --git a/test/internalTable/sorting.test.ts b/test/internalTable/sorting.test.ts index cc008dd9..7e53536d 100644 --- a/test/internalTable/sorting.test.ts +++ b/test/internalTable/sorting.test.ts @@ -74,20 +74,7 @@ describe('Testing column alignment', () => { // print const returned = renderTable(p.table); - - const expected = [ - '┌──────────────────────┬──────────────────────────────────────────┬────────────────────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mred_left_align_index\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m right_align_text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mgreen_value_center\u001b[0m\u001b[37m │\u001b[0m', - '├──────────────────────┼──────────────────────────────────────────┼────────────────────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[33m8 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[33m I would like some gelb bananen bitte\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[33m 100 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[32m7 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m I would like some green gemuse please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 20 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[38m6 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[38m I would like some crimson sky please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[38m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01m5 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mI would like some white_bold wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[36m4 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[36m I would like some cyan wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[36m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m3 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[31m I would like some red wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[31m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[34m2 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[34m This row is blue\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[34m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '└──────────────────────┴──────────────────────────────────────────┴────────────────────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); }); diff --git a/test/internalTable/title.test.ts b/test/internalTable/title.test.ts index 63a19c79..f3c4dedd 100644 --- a/test/internalTable/title.test.ts +++ b/test/internalTable/title.test.ts @@ -73,21 +73,8 @@ describe('Testing column alignment', () => { // print const returned = renderTable(p.table); - const expected = [ - '\u001b[01m Some Random Title \u001b[0m', - '┌──────────────────────┬──────────────────────────────────────────┬────────────────────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mred_left_align_index\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01m right_align_text\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mgreen_value_center\u001b[0m\u001b[37m │\u001b[0m', - '├──────────────────────┼──────────────────────────────────────────┼────────────────────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m2 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[34m This row is blue\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m3 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[31m I would like some red wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m4 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[36m I would like some cyan wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m5 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mI would like some white_bold wine please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m6 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[38m I would like some crimson sky please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m7 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m I would like some green gemuse please\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 20 \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[31m8 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[33m I would like some gelb bananen bitte\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 100 \u001b[0m\u001b[37m │\u001b[0m', - '└──────────────────────┴──────────────────────────────────────────┴────────────────────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); it('Simpler title test', () => { @@ -119,16 +106,7 @@ describe('Testing column alignment', () => { // print const returned = renderTable(p.table); - const expected = [ - '\u001b[01m Some Random Title \u001b[0m', - '┌──────────────────────┬────────────────────┬──────┬──────┬──────┐', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[01mred_left_align_index\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mgreen_value_center\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mcol1\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mcol2\u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[01mcol2\u001b[0m\u001b[37m │\u001b[0m', - '├──────────────────────┼────────────────────┼──────┼──────┼──────┤', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m3 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m4 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m \u001b[0m\u001b[37m │\u001b[0m', - '\u001b[37m│\u001b[0m\u001b[37m \u001b[0m\u001b[37m5 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[32m 10.212 \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m \u001b[0m\u001b[37m │\u001b[0m\u001b[37m \u001b[0m\u001b[37m \u001b[0m\u001b[37m │\u001b[0m', - '└──────────────────────┴────────────────────┴──────┴──────┴──────┘', - ]; - expect(returned).toBe(expected.join('\n')); + expect(returned).toMatchSnapshot(); + console.log(returned); }); });