Skip to content

Commit

Permalink
fix: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Feb 25, 2020
1 parent ec48cde commit 41c8379
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
68 changes: 68 additions & 0 deletions test/coordinate-grid/utilities/drawCoordinateGrid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// @flow

import test from 'ava';
import stripAnsi from 'strip-ansi';
import createCoordinateGridMember from '../../../src/factories/createCoordinateGridMember';
import drawCoordinateGrid from '../../../src/utilities/drawCoordinateGrid';
import drawSquare from '../../../src/utilities/drawSquare';

test('draws a coordinate square', (t) => {
const coordinateGrid = drawCoordinateGrid([
createCoordinateGridMember(0, 0, drawSquare('A1')),
]);

t.is(coordinateGrid, '┌────┐\n│ A1 │\n└────┘');
});

test('draws coordinate squares (multiple columns)', (t) => {
const coordinateGrid = drawCoordinateGrid([
createCoordinateGridMember(0, 0, drawSquare('A1')),
createCoordinateGridMember(1, 0, drawSquare('A2')),
]);

t.is(coordinateGrid, '┌────┐┌────┐\n│ A1 ││ A2 │\n└────┘└────┘');
});

test('draws coordinate squares (multiple rows)', (t) => {
const coordinateGrid = drawCoordinateGrid([
createCoordinateGridMember(0, 0, drawSquare('A1')),
createCoordinateGridMember(0, 1, drawSquare('B1')),
]);

t.is(coordinateGrid, '┌────┐\n│ A1 │\n└────┘\n┌────┐\n│ B1 │\n└────┘');
});

test('draws empty-borderlesss square when coordinate is absent', (t) => {
const coordinateGrid = drawCoordinateGrid([
createCoordinateGridMember(0, 0, drawSquare('A1')),
createCoordinateGridMember(2, 0, drawSquare('A3')),
]);

t.is(coordinateGrid, '┌────┐ ┌────┐\n│ A1 │ │ A3 │\n└────┘ └────┘');
});

test('draws README example (boxes)', (t) => {
const coordinateGrid = drawCoordinateGrid([
createCoordinateGridMember(0, 0, drawSquare('A1')),
createCoordinateGridMember(1, 0, drawSquare('A2', 'double')),
createCoordinateGridMember(2, 0, drawSquare('A3', 'borderless')),
createCoordinateGridMember(1, 1, drawSquare('B2', 'single', 'green')),
createCoordinateGridMember(1, 2, drawSquare('C2')),
createCoordinateGridMember(2, 2, drawSquare('C3', 'single', 'red')),
]);

t.is(stripAnsi(coordinateGrid), '┌────┐╔════╗ \n│ A1 │║ A2 ║ A3 \n└────┘╚════╝ \n ┌────┐ \n │ B2 │ \n └────┘ \n ┌────┐┌────┐\n │ C2 ││ C3 │\n └────┘└────┘');
});

test('draws README example (single character)', (t) => {
const coordinateGrid = drawCoordinateGrid([
createCoordinateGridMember(0, 0, 'x'),
createCoordinateGridMember(1, 0, 'x'),
createCoordinateGridMember(2, 0, 'x'),
createCoordinateGridMember(1, 1, 'x'),
createCoordinateGridMember(1, 2, 'x'),
createCoordinateGridMember(2, 2, 'x'),
], '_');

t.is(coordinateGrid, 'xxx\n_x_\n_xx');
});
29 changes: 29 additions & 0 deletions test/coordinate-grid/utilities/drawSquare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @flow

import test from 'ava';
import chalk from 'chalk';
import drawSquare from '../../../src/utilities/drawSquare';

test('draws a square (style: single)', (t) => {
const square = drawSquare('A1', 'single');

t.is(square, '┌────┐\n│ A1 │\n└────┘');
});

test('draws a square (style: double)', (t) => {
const square = drawSquare('A1', 'double');

t.is(square, '╔════╗\n║ A1 ║\n╚════╝');
});

test('draws a square (style: borderless)', (t) => {
const square = drawSquare('A1', 'borderless');

t.is(square, ' \n A1 \n ');
});

test('draws a square (color: red)', (t) => {
const square = drawSquare('A1', 'single', 'red');

t.is(square, chalk.red('┌────┐\n│ A1 │\n└────┘'));
});

0 comments on commit 41c8379

Please sign in to comment.