Skip to content

Commit 456637a

Browse files
committed
chore: say goodbye to chai.js
1 parent bc96454 commit 456637a

File tree

6 files changed

+45
-138
lines changed

6 files changed

+45
-138
lines changed

package-lock.json

-83
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,9 @@
7878
"@testing-library/dom": "^10.4.0",
7979
"@testing-library/react": "^16.0.1",
8080
"@testing-library/user-event": "^14.5.2",
81-
"@types/chai": "^5.0.1",
8281
"@types/node": "^22.9.1",
8382
"@types/react": "^18.3.12",
8483
"@types/react-dom": "^18.3.1",
85-
"chai": "^5.1.1",
8684
"cheerio": "^1.0.0",
8785
"confusing-browser-globals": "^1.0.11",
8886
"rich-assert": "^0.0.3",

packages/keybr-content-words/lib/words.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { test } from "node:test";
22
import { Language } from "@keybr/keyboard";
3-
import { assert } from "chai";
4-
import { fail } from "rich-assert";
3+
import { fail, isTrue } from "rich-assert";
54
import { loadWordList } from "./load.ts";
65

76
for (const language of Language.ALL) {
87
test(`words:${language}`, async () => {
98
const words = await loadWordList(language);
10-
assert.isAbove(words.length, 1500);
9+
isTrue(words.length > 1500);
1110
const unique = new Set();
1211
for (const word of words) {
1312
if (!language.test(word)) {

packages/keybr-database/lib/model.test.ts

+29-34
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import { test } from "node:test";
22
import { PublicId } from "@keybr/publicid";
3-
import { expect } from "chai";
43
import { ValidationError } from "objection";
5-
import { deepEqual, equal, isNotNull, isNull, like } from "rich-assert";
4+
import {
5+
deepEqual,
6+
doesNotThrow,
7+
equal,
8+
isNotNull,
9+
isNull,
10+
like,
11+
throws,
12+
} from "rich-assert";
613
import { User, UserExternalId, UserLoginRequest } from "./model.ts";
714
import { useDatabase } from "./testing.ts";
815
import { Random } from "./util.ts";
@@ -14,87 +21,75 @@ const now = new Date("2001-02-03T04:05:06Z");
1421
test("validate models", (ctx) => {
1522
ctx.mock.timers.enable({ apis: ["Date"], now });
1623

17-
expect(() => {
24+
throws(() => {
1825
User.fromJson({});
19-
})
20-
.to.throw(ValidationError)
21-
.to.have.property("data");
26+
}, ValidationError);
2227

23-
expect(() => {
28+
throws(() => {
2429
User.fromJson({
2530
name: null,
2631
email: null,
2732
});
28-
})
29-
.to.throw(ValidationError)
30-
.to.have.property("data");
33+
}, ValidationError);
3134

32-
expect(() => {
35+
throws(() => {
3336
User.fromJson({
3437
name: "",
3538
email: "",
3639
});
37-
})
38-
.to.throw(ValidationError)
39-
.to.have.property("data");
40+
}, ValidationError);
4041

41-
expect(() => {
42+
doesNotThrow(() => {
4243
User.fromJson({
4344
name: "name",
4445
email: "email",
4546
});
46-
}).to.not.throw();
47+
});
4748

48-
expect(() => {
49+
throws(() => {
4950
UserExternalId.fromJson({});
50-
})
51-
.to.throw(ValidationError)
52-
.to.have.property("data");
51+
}, ValidationError);
5352

54-
expect(() => {
53+
throws(() => {
5554
UserExternalId.fromJson({
5655
provider: null,
5756
externalId: null,
5857
});
59-
})
60-
.to.throw(ValidationError)
61-
.to.have.property("data");
58+
}, ValidationError);
6259

63-
expect(() => {
60+
throws(() => {
6461
UserExternalId.fromJson({
6562
provider: "",
6663
externalId: "",
6764
});
68-
})
69-
.to.throw(ValidationError)
70-
.to.have.property("data");
65+
}, ValidationError);
7166

72-
expect(() => {
67+
doesNotThrow(() => {
7368
UserExternalId.fromJson({
7469
provider: "provider",
7570
externalId: "externalId",
7671
});
77-
}).to.not.throw();
72+
});
7873

79-
expect(() => {
74+
doesNotThrow(() => {
8075
UserExternalId.fromJson({
8176
provider: "provider",
8277
externalId: "externalId",
8378
name: null,
8479
url: null,
8580
imageUrl: null,
8681
});
87-
}).to.not.throw();
82+
});
8883

89-
expect(() => {
84+
doesNotThrow(() => {
9085
UserExternalId.fromJson({
9186
provider: "provider",
9287
externalId: "externalId",
9388
name: "name",
9489
url: "url",
9590
imageUrl: "imageUrl",
9691
});
97-
}).to.not.throw();
92+
});
9893
});
9994

10095
test("automatically populate createdAt", async (ctx) => {

packages/keybr-intl/lib/displaynames.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { test } from "node:test";
2-
import { assert } from "chai";
32
import { createIntl } from "react-intl";
4-
import { equal } from "rich-assert";
3+
import { equal, isNotEmpty } from "rich-assert";
54
import { makeIntlDisplayNames } from "./displaynames.ts";
65
import { allLocales } from "./locale.ts";
76

@@ -71,7 +70,7 @@ test("format all language names in all locales", () => {
7170
createIntl({ locale: outer }),
7271
);
7372
for (const inner of allLocales) {
74-
assert.isAbove(formatLanguageName(inner).length, 0);
73+
isNotEmpty(formatLanguageName(inner));
7574
}
7675
}
7776
});

packages/keybr-intl/lib/translations.test.ts

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { readFileSync } from "node:fs";
22
import { test } from "node:test";
3-
import { assert } from "chai";
4-
import { deepEqual } from "rich-assert";
3+
import { deepEqual, doesNotMatch } from "rich-assert";
54
import { allLocales, defaultLocale } from "./locale.ts";
65

76
for (const locale of allLocales) {
@@ -27,33 +26,33 @@ for (const locale of allLocales) {
2726
test(`typography [${locale}]`, () => {
2827
const messages = loadTranslations(locale);
2928
for (const [id, message] of Object.entries(messages)) {
30-
assert.notMatch(message, /^\s/, `Message ${id} starts with whitespace`);
31-
assert.notMatch(message, /\s$/, `Message ${id} ends with whitespace`);
32-
assert.notMatch(message, /\s\s/, `Message ${id} has repeated whitespace`);
33-
assert.notMatch(message, /\t/, `Message ${id} has tab whitespace`);
34-
assert.notMatch(
29+
doesNotMatch(message, /^\s/, `Message ${id} starts with whitespace`);
30+
doesNotMatch(message, /\s$/, `Message ${id} ends with whitespace`);
31+
doesNotMatch(message, /\s\s/, `Message ${id} has repeated whitespace`);
32+
doesNotMatch(message, /\t/, `Message ${id} has tab whitespace`);
33+
doesNotMatch(
3534
message,
3635
/[\u2000-\u200B\u2028\u2029]/,
3736
`Message ${id} has irregular whitespace`,
3837
);
39-
assert.notMatch(
38+
doesNotMatch(
4039
message,
4140
/\s[.,:;!?]/,
4241
`Message ${id} has whitespace before punctuation`,
4342
);
44-
assert.notMatch(message, /'/, `Message ${id} has straight single quote`);
45-
assert.notMatch(message, /"/, `Message ${id} has straight double quote`);
46-
assert.notMatch(
43+
doesNotMatch(message, /'/, `Message ${id} has straight single quote`);
44+
doesNotMatch(message, /"/, `Message ${id} has straight double quote`);
45+
doesNotMatch(
4746
message,
4847
/\s\u002D\s/,
4948
`Message ${id} uses Hyphen-Minus as Dash`,
5049
);
51-
assert.notMatch(
50+
doesNotMatch(
5251
message,
5352
/\s\u2010|\u2010\s/,
5453
`Message ${id} has space around Hyphen`,
5554
);
56-
assert.notMatch(
55+
doesNotMatch(
5756
message,
5857
/\s\u2011|\u2011\s/,
5958
`Message ${id} has space around Non-Breaking Hyphen`,

0 commit comments

Comments
 (0)