-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build!: migrate from jest to native node:test (#24)
* build!: migrate from jest to native node:test BREAKING CHANGE: requires node 20 for testcontext assert * ci(cd): stop removal of jest property from package
- Loading branch information
Showing
5 changed files
with
38 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,60 +27,39 @@ | |
"author": "Frazer Smith <[email protected]>", | ||
"funding": "https://github.com/sponsors/Fdawgs", | ||
"engines": { | ||
"node": ">=18" | ||
"node": ">=20" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"jest": "jest", | ||
"jest:coverage": "jest --coverage", | ||
"lint": "eslint . --cache --ext js,jsx --ignore-path .gitignore", | ||
"lint:fix": "npm run lint -- --fix", | ||
"lint:licenses": "node scripts/license-checker.js", | ||
"lint:prettier": "prettier . -c -u", | ||
"lint:prettier:fix": "prettier . -w -u", | ||
"prepare": "husky", | ||
"test": "npm run lint && npm run lint:prettier && npm run jest" | ||
"test": "npm run lint && npm run lint:prettier && npm run test:unit", | ||
"test:unit": "node --test", | ||
"test:unit:coverage": "c8 --100 --all --src='src/' -r=lcovonly -r=text npm run test:unit" | ||
}, | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"jest": { | ||
"collectCoverageFrom": [ | ||
"src/**/*.js" | ||
], | ||
"coverageReporters": [ | ||
"text", | ||
"lcovonly" | ||
], | ||
"coverageThreshold": { | ||
"global": { | ||
"branches": 100, | ||
"functions": 100, | ||
"lines": 100, | ||
"statements": 100 | ||
} | ||
}, | ||
"testEnvironment": "node", | ||
"testTimeout": 10000 | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^19.6.1", | ||
"@commitlint/config-conventional": "^19.6.0", | ||
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1", | ||
"@types/jest": "^29.5.14", | ||
"c8": "^10.1.3", | ||
"eslint": "^8.57.1", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-import": "^2.31.0", | ||
"eslint-plugin-jest": "^28.10.0", | ||
"eslint-plugin-jsdoc": "^50.6.1", | ||
"eslint-plugin-promise": "^7.2.1", | ||
"eslint-plugin-regexp": "^2.7.0", | ||
"eslint-plugin-security": "^3.0.1", | ||
"husky": "^9.1.7", | ||
"jest": "^29.7.0", | ||
"license-checker": "^25.0.1", | ||
"prettier": "^3.4.2", | ||
"spdx-copyleft": "^1.0.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
"use strict"; | ||
|
||
const { describe, it } = require("node:test"); | ||
const { fixLatin1ToUtf8, replacements } = require("./index"); | ||
|
||
describe("fixLatin1ToUtf8", () => { | ||
it.each(Object.entries(replacements))( | ||
"Replaces %s with %s", | ||
(actual, expected) => { | ||
expect(fixLatin1ToUtf8(actual)).toBe(expected); | ||
} | ||
); | ||
for (const [actual, expected] of Object.entries(replacements)) { | ||
it(`Replaces ${actual} with ${expected}`, (t) => { | ||
t.plan(1); | ||
t.assert.strictEqual(fixLatin1ToUtf8(actual), expected); | ||
}); | ||
} | ||
|
||
it("Replaces multiple characters", () => { | ||
expect(fixLatin1ToUtf8("‚ƒ„…â€\u00A0")).toBe("‚ƒ„…†"); | ||
it("Replaces multiple characters", (t) => { | ||
t.plan(1); | ||
t.assert.strictEqual(fixLatin1ToUtf8("‚ƒ„…â€\u00A0"), "‚ƒ„…†"); | ||
}); | ||
|
||
it("Does not mutate a string without Latin-1 characters", () => { | ||
it("Does not mutate a string without Latin-1 characters", (t) => { | ||
t.plan(1); | ||
const str = "Hello, world!"; | ||
expect(fixLatin1ToUtf8(str)).toBe(str); | ||
t.assert.strictEqual(fixLatin1ToUtf8(str), str); | ||
}); | ||
|
||
it("Throws an error if the argument is not a string", () => { | ||
expect(() => fixLatin1ToUtf8(123)).toThrow(TypeError); | ||
it("Throws an error if the argument is not a string", (t) => { | ||
t.plan(1); | ||
t.assert.throws(() => fixLatin1ToUtf8(123), TypeError); | ||
}); | ||
}); |