Skip to content

Commit

Permalink
chore: use node:assert
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas committed Apr 8, 2024
1 parent d7e7641 commit 32dfbfc
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 105 deletions.
71 changes: 0 additions & 71 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"ansi-escapes": "6.2.1",
"ansi-styles": "6.2.1",
"c8": "9.1.0",
"chai": "5.1.0",
"mocha": "10.4.0",
"tstyche": "2.0.0-beta.0"
},
Expand Down
27 changes: 15 additions & 12 deletions test/ansi-escapes.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from "node:assert/strict";
import ansiEscapes from "ansi-escapes";
import { expect } from "chai";
import { describe, test } from "mocha";

import prettyAnsi from "pretty-ansi";

describe("supports ansi-escapes", () => {
Expand All @@ -27,7 +26,7 @@ describe("supports ansi-escapes", () => {

cases.forEach(({ key, expected }) => {
test(key, () => {
expect(prettyAnsi(`${ansiEscapes[key]}`)).to.equal(expected);
assert.strictEqual(prettyAnsi(`${ansiEscapes[key]}`), expected);
});
});

Expand All @@ -44,46 +43,50 @@ describe("supports ansi-escapes", () => {

casesWithKey.forEach(({ arg, key, expected }) => {
test(`${key}(${arg})`, () => {
expect(prettyAnsi(ansiEscapes[key](arg))).to.equal(expected);
assert.strictEqual(prettyAnsi(ansiEscapes[key](arg)), expected);
});
});

test("cursorTo(14)", () => {
expect(prettyAnsi(ansiEscapes.cursorTo(14))).to.equal("<moveCursorToColumn15>\n");
assert.strictEqual(prettyAnsi(ansiEscapes.cursorTo(14)), "<moveCursorToColumn15>\n");
});

test("cursorTo(6, 18)", () => {
expect(prettyAnsi(ansiEscapes.cursorTo(6, 18))).to.equal("<moveCursorToRow19Column7>\n");
assert.strictEqual(prettyAnsi(ansiEscapes.cursorTo(6, 18)), "<moveCursorToRow19Column7>\n");
});

test("cursorMove(5)", () => {
expect(prettyAnsi(ansiEscapes.cursorMove(5))).to.equal("<moveCursorRightBy5Columns>\n");
assert.strictEqual(prettyAnsi(ansiEscapes.cursorMove(5)), "<moveCursorRightBy5Columns>\n");
});

test("cursorMove(-2)", () => {
expect(prettyAnsi(ansiEscapes.cursorMove(-2))).to.equal("<moveCursorLeftBy2Columns>\n");
assert.strictEqual(prettyAnsi(ansiEscapes.cursorMove(-2)), "<moveCursorLeftBy2Columns>\n");
});

test("cursorMove(12, 3)", () => {
expect(prettyAnsi(ansiEscapes.cursorMove(12, 3))).to.equal(
assert.strictEqual(
prettyAnsi(ansiEscapes.cursorMove(12, 3)),
"<moveCursorRightBy12Columns>\n<moveCursorDownBy3Rows>\n",
);
});

test("cursorMove(10, -8)", () => {
expect(prettyAnsi(ansiEscapes.cursorMove(10, -8))).to.equal(
assert.strictEqual(
prettyAnsi(ansiEscapes.cursorMove(10, -8)),
"<moveCursorRightBy10Columns>\n<moveCursorUpBy8Rows>\n",
);
});

test("cursorMove(-5, 18)", () => {
expect(prettyAnsi(ansiEscapes.cursorMove(-5, 18))).to.equal(
assert.strictEqual(
prettyAnsi(ansiEscapes.cursorMove(-5, 18)),
"<moveCursorLeftBy5Columns>\n<moveCursorDownBy18Rows>\n",
);
});

test("cursorMove(-17, -2)", () => {
expect(prettyAnsi(ansiEscapes.cursorMove(-21, -9))).to.equal(
assert.strictEqual(
prettyAnsi(ansiEscapes.cursorMove(-21, -9)),
"<moveCursorLeftBy21Columns>\n<moveCursorUpBy9Rows>\n",
);
});
Expand Down
21 changes: 13 additions & 8 deletions test/ansi-styles.test.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
import assert from "node:assert/strict";
import ansiStyle from "ansi-styles";
import { expect } from "chai";
import { describe, test } from "mocha";

import prettyAnsi from "pretty-ansi";

describe("supports ansi-styles", () => {
test("supports style.red", async () => {
expect(prettyAnsi(`${ansiStyle.red.open} foo content ${ansiStyle.red.close}`)).to.equal(
assert.strictEqual(
prettyAnsi(`${ansiStyle.red.open} foo content ${ansiStyle.red.close}`),
"<red> foo content </color>",
);
});

test("supports style.green", () => {
expect(prettyAnsi(`${ansiStyle.green.open} foo content ${ansiStyle.green.close}`)).to.equal(
assert.strictEqual(
prettyAnsi(`${ansiStyle.green.open} foo content ${ansiStyle.green.close}`),
"<green> foo content </color>",
);
});

test("supports style.reset", () => {
expect(prettyAnsi(`${ansiStyle.reset.open} foo content ${ansiStyle.reset.close}`)).to.equal("</> foo content </>");
assert.strictEqual(
prettyAnsi(`${ansiStyle.reset.open} foo content ${ansiStyle.reset.close}`),
"</> foo content </>",
);
});

test("supports style.bold", () => {
expect(prettyAnsi(`${ansiStyle.bold.open} foo content`)).to.equal("<bold> foo content");
assert.strictEqual(prettyAnsi(`${ansiStyle.bold.open} foo content`), "<bold> foo content");
});

test("supports style.dim", () => {
expect(prettyAnsi(`${ansiStyle.dim.open} foo content`)).to.equal("<dim> foo content");
assert.strictEqual(prettyAnsi(`${ansiStyle.dim.open} foo content`), "<dim> foo content");
});

test("does not support other colors", () => {
expect(prettyAnsi(`${ansiStyle.blue.open} foo content ${ansiStyle.reset.close}`)).to.equal(
assert.strictEqual(
prettyAnsi(`${ansiStyle.blue.open} foo content ${ansiStyle.reset.close}`),
"<blue> foo content </>",
);
});
Expand Down
5 changes: 2 additions & 3 deletions test/color-and-style.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from "chai";
import assert from "node:assert/strict";
import { describe, test } from "mocha";

import prettyAnsi from "pretty-ansi";

describe("color and style sequences", () => {
Expand Down Expand Up @@ -78,7 +77,7 @@ describe("color and style sequences", () => {

cases.forEach(({ expected, sequence }) => {
test(expected, () => {
expect(prettyAnsi(sequence)).to.equal(expected);
assert.strictEqual(prettyAnsi(sequence), expected);
});
});
});
19 changes: 9 additions & 10 deletions test/cursor-and-erase.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from "chai";
import assert from "node:assert/strict";
import { describe, test } from "mocha";

import prettyAnsi from "pretty-ansi";

describe("cursor and erase sequences", () => {
Expand Down Expand Up @@ -274,13 +273,13 @@ describe("cursor and erase sequences", () => {

cases.forEach(({ caseName, sequence, expected }) => {
test(caseName, () => {
expect(prettyAnsi(sequence)).to.equal(expected);
assert.strictEqual(prettyAnsi(sequence), expected);
});
});

test("handles unrecognized sequence", () => {
expect(prettyAnsi("\u001b[a1b2c3")).to.equal("<ESC>[a1b2c3");
expect(prettyAnsi("\u001bd4e5f6")).to.equal("<ESC>d4e5f6");
assert.strictEqual(prettyAnsi("\u001b[a1b2c3"), "<ESC>[a1b2c3");
assert.strictEqual(prettyAnsi("\u001bd4e5f6"), "<ESC>d4e5f6");
});
});

Expand Down Expand Up @@ -425,11 +424,11 @@ describe("handles end of line characters", () => {

cases.forEach(({ caseName, sequence, expected }) => {
test(caseName, () => {
expect(prettyAnsi(sequence)).to.equal(`${expected}\n`);
expect(prettyAnsi(`${sequence}\n`)).to.equal(`${expected}\n`);
expect(prettyAnsi(`${sequence}\n\n`)).to.equal(`${expected}\n\n`);
expect(prettyAnsi(`${sequence}text`)).to.equal(`${expected}\ntext`);
expect(prettyAnsi(`text${sequence}`)).to.equal(`text\n${expected}\n`);
assert.strictEqual(prettyAnsi(sequence), `${expected}\n`);
assert.strictEqual(prettyAnsi(`${sequence}\n`), `${expected}\n`);
assert.strictEqual(prettyAnsi(`${sequence}\n\n`), `${expected}\n\n`);
assert.strictEqual(prettyAnsi(`${sequence}text`), `${expected}\ntext`);
assert.strictEqual(prettyAnsi(`text${sequence}`), `text\n${expected}\n`);
});
});
});

0 comments on commit 32dfbfc

Please sign in to comment.