From 32dfbfc2b720912e742f1bdfd7b821dfc60661ec Mon Sep 17 00:00:00 2001 From: Tom Mrazauskas Date: Mon, 8 Apr 2024 21:29:13 +0300 Subject: [PATCH] chore: use `node:assert` --- package-lock.json | 71 ----------------------------------- package.json | 1 - test/ansi-escapes.test.js | 27 +++++++------ test/ansi-styles.test.js | 21 +++++++---- test/color-and-style.test.js | 5 +-- test/cursor-and-erase.test.js | 19 +++++----- 6 files changed, 39 insertions(+), 105 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5af8185..b63ea82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,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" }, @@ -286,15 +285,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "node_modules/assertion-error": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", - "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", - "dev": true, - "engines": { - "node": ">=12" - } - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -378,22 +368,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/chai": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.0.tgz", - "integrity": "sha512-kDZ7MZyM6Q1DhR9jy7dalKohXQ2yrlXkk59CR52aRKxJrobmlBNqnFQxX9xOX8w+4mz8SYlKJa/7D7ddltFXCw==", - "dev": true, - "dependencies": { - "assertion-error": "^2.0.1", - "check-error": "^2.0.0", - "deep-eql": "^5.0.1", - "loupe": "^3.1.0", - "pathval": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -425,15 +399,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/check-error": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.0.0.tgz", - "integrity": "sha512-tjLAOBHKVxtPoHe/SA7kNOMvhCRdCJ3vETdeY0RuAc9popf+hyaSV6ZEg9hr4cpWF7jmo/JSWEnLDrnijS9Tog==", - "dev": true, - "engines": { - "node": ">= 16" - } - }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -560,15 +525,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/deep-eql": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.1.tgz", - "integrity": "sha512-nwQCf6ne2gez3o1MxWifqkciwt0zhl0LO1/UwVu4uMBuPmflWM4oQ70XMqHqnBJA+nhzncaqL9HVL6KkHJ28lw==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/diff": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", @@ -687,15 +643,6 @@ "node": "6.* || 8.* || >= 10.*" } }, - "node_modules/get-func-name": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", - "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/glob": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", @@ -933,15 +880,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/loupe": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.0.tgz", - "integrity": "sha512-qKl+FrLXUhFuHUoDJG7f8P8gEMHq9NFS0c6ghXG1J0rldmZFQZoNVv/vyirE9qwCIhWZDsvEFd1sbFu3GvRQFg==", - "dev": true, - "dependencies": { - "get-func-name": "^2.0.1" - } - }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -1177,15 +1115,6 @@ "node": ">=8" } }, - "node_modules/pathval": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", - "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", - "dev": true, - "engines": { - "node": ">= 14.16" - } - }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", diff --git a/package.json b/package.json index 1e0d259..7cda7f4 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/test/ansi-escapes.test.js b/test/ansi-escapes.test.js index 58104e5..5dd910e 100644 --- a/test/ansi-escapes.test.js +++ b/test/ansi-escapes.test.js @@ -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", () => { @@ -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); }); }); @@ -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("\n"); + assert.strictEqual(prettyAnsi(ansiEscapes.cursorTo(14)), "\n"); }); test("cursorTo(6, 18)", () => { - expect(prettyAnsi(ansiEscapes.cursorTo(6, 18))).to.equal("\n"); + assert.strictEqual(prettyAnsi(ansiEscapes.cursorTo(6, 18)), "\n"); }); test("cursorMove(5)", () => { - expect(prettyAnsi(ansiEscapes.cursorMove(5))).to.equal("\n"); + assert.strictEqual(prettyAnsi(ansiEscapes.cursorMove(5)), "\n"); }); test("cursorMove(-2)", () => { - expect(prettyAnsi(ansiEscapes.cursorMove(-2))).to.equal("\n"); + assert.strictEqual(prettyAnsi(ansiEscapes.cursorMove(-2)), "\n"); }); test("cursorMove(12, 3)", () => { - expect(prettyAnsi(ansiEscapes.cursorMove(12, 3))).to.equal( + assert.strictEqual( + prettyAnsi(ansiEscapes.cursorMove(12, 3)), "\n\n", ); }); test("cursorMove(10, -8)", () => { - expect(prettyAnsi(ansiEscapes.cursorMove(10, -8))).to.equal( + assert.strictEqual( + prettyAnsi(ansiEscapes.cursorMove(10, -8)), "\n\n", ); }); test("cursorMove(-5, 18)", () => { - expect(prettyAnsi(ansiEscapes.cursorMove(-5, 18))).to.equal( + assert.strictEqual( + prettyAnsi(ansiEscapes.cursorMove(-5, 18)), "\n\n", ); }); test("cursorMove(-17, -2)", () => { - expect(prettyAnsi(ansiEscapes.cursorMove(-21, -9))).to.equal( + assert.strictEqual( + prettyAnsi(ansiEscapes.cursorMove(-21, -9)), "\n\n", ); }); diff --git a/test/ansi-styles.test.js b/test/ansi-styles.test.js index ebb7ea2..af6c52a 100644 --- a/test/ansi-styles.test.js +++ b/test/ansi-styles.test.js @@ -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}`), " foo content ", ); }); 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}`), " foo content ", ); }); 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(" foo content"); + assert.strictEqual(prettyAnsi(`${ansiStyle.bold.open} foo content`), " foo content"); }); test("supports style.dim", () => { - expect(prettyAnsi(`${ansiStyle.dim.open} foo content`)).to.equal(" foo content"); + assert.strictEqual(prettyAnsi(`${ansiStyle.dim.open} foo content`), " 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}`), " foo content ", ); }); diff --git a/test/color-and-style.test.js b/test/color-and-style.test.js index c67de98..069b359 100644 --- a/test/color-and-style.test.js +++ b/test/color-and-style.test.js @@ -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", () => { @@ -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); }); }); }); diff --git a/test/cursor-and-erase.test.js b/test/cursor-and-erase.test.js index e3726d1..2eff401 100644 --- a/test/cursor-and-erase.test.js +++ b/test/cursor-and-erase.test.js @@ -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", () => { @@ -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("[a1b2c3"); - expect(prettyAnsi("\u001bd4e5f6")).to.equal("d4e5f6"); + assert.strictEqual(prettyAnsi("\u001b[a1b2c3"), "[a1b2c3"); + assert.strictEqual(prettyAnsi("\u001bd4e5f6"), "d4e5f6"); }); }); @@ -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`); }); }); });