Skip to content

Commit a4bf7e5

Browse files
committed
Replace mocha with vitest; remove staged-lint and uncessary overrides
1 parent 16031b4 commit a4bf7e5

14 files changed

+1386
-1560
lines changed

package-lock.json

Lines changed: 1066 additions & 1231 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"build": "npm run clean && npx tsc",
1616
"local": "npm run clean && nodemon src/index.ts",
1717
"pretest": "npm run build",
18-
"test": "mocha -r ts-node/register tests/**/*.spec.ts",
19-
"test:watch": "npm run test -- --watch",
18+
"test": "vitest run",
19+
"test:watch": "vitest",
2020
"lint": "oxlint",
2121
"lint:fix": "oxlint --fix",
2222
"format": "prettier . --write",
@@ -51,30 +51,14 @@
5151
],
5252
"devDependencies": {
5353
"@types/benchmark": "^2.1.5",
54-
"@types/chai": "^5.2.3",
55-
"@types/mocha": "^10.0.10",
5654
"@types/node": "^25.5.0",
5755
"axios": "^1.13.6",
5856
"benchmark": "^2.1.4",
59-
"chai": "^6.2.2",
60-
"lint-staged": "^16.4.0",
61-
"mocha": "^11.7.5",
6257
"nodemon": "^3.1.14",
6358
"oxlint": "^1.56.0",
6459
"prettier": "^3.8.1",
6560
"rimraf": "^6.1.3",
66-
"ts-node": "^10.9.2",
67-
"typescript": "^6.0.2"
68-
},
69-
"overrides": {
70-
"inflight": "^2.0.0",
71-
"glob": "^9.0.0",
72-
"rimraf": "^6.1.3",
73-
"diff": "^8.0.4",
74-
"serialize-javascript": "^7.0.4"
75-
},
76-
"lint-staged": {
77-
"*.ts": "oxlint --fix",
78-
"*": "prettier --write"
61+
"typescript": "^6.0.2",
62+
"vitest": "^4.1.1"
7963
}
8064
}

tests/import.spec.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/import.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { describe, it, expect } from "vitest";
2+
import { profanity, Profanity, CensorType, ProfanityOptions } from "../dist";
3+
4+
describe("ES Module Import", () => {
5+
it("should import profanity correctly", () => {
6+
expect(profanity).toBeInstanceOf(Profanity);
7+
});
8+
9+
it("should import Profanity class correctly", () => {
10+
expect(typeof Profanity).toBe("function");
11+
const instance = new Profanity();
12+
expect(instance).toBeInstanceOf(Profanity);
13+
});
14+
15+
it("should import CensorType enum correctly", () => {
16+
expect(typeof CensorType).toBe("object");
17+
expect(CensorType.Word).toBeDefined();
18+
expect(CensorType.FirstChar).toBeDefined();
19+
expect(CensorType.FirstVowel).toBeDefined();
20+
expect(CensorType.AllVowels).toBeDefined();
21+
});
22+
23+
it("should import ProfanityOptions class correctly", () => {
24+
expect(typeof ProfanityOptions).toBe("function");
25+
const options = new ProfanityOptions();
26+
expect(options).toBeInstanceOf(ProfanityOptions);
27+
});
28+
});
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { expect } from "chai";
1+
import { describe, it, expect } from "vitest";
22

33
import { profanity, CensorType } from "../src";
44

55
describe("censor", () => {
66
describe("Default censoring (CensorType.Word)", () => {
77
it("should replace multiple profane words within a sentence with grawlix", () => {
88
const censored = profanity.censor("I like big butts (aka arses) and I cannot lie");
9-
expect(censored).to.equal(`I like big ${profanity.options.grawlix} (aka ${profanity.options.grawlix}) and I cannot lie`);
9+
expect(censored).toBe(`I like big ${profanity.options.grawlix} (aka ${profanity.options.grawlix}) and I cannot lie`);
1010
});
1111

1212
it("should replace profane words within a multi-line sentence with grawlix", () => {
@@ -15,7 +15,7 @@ describe("censor", () => {
1515
Censoring butt on line 2.
1616
Nothing profane on line 3.
1717
`);
18-
expect(censored).to.equal(`
18+
expect(censored).toBe(`
1919
Nothing profane on line 1.
2020
Censoring ${profanity.options.grawlix} on line 2.
2121
Nothing profane on line 3.
@@ -24,161 +24,159 @@ describe("censor", () => {
2424

2525
it("sentences without profanity should not be altered", () => {
2626
const original = "I like big glutes and I cannot lie";
27-
expect(profanity.censor(original)).to.equal(original);
27+
expect(profanity.censor(original)).toBe(original);
2828
});
2929

3030
it("should censor profanity at the beginning of a sentence", () => {
31-
expect(profanity.censor("Butt is a profane word")).to.equal(`${profanity.options.grawlix} is a profane word`);
31+
expect(profanity.censor("Butt is a profane word")).toBe(`${profanity.options.grawlix} is a profane word`);
3232
});
3333

3434
it("should censor profanity at the end of a sentence", () => {
35-
expect(profanity.censor("Don't be a butt")).to.equal(`Don't be a ${profanity.options.grawlix}`);
35+
expect(profanity.censor("Don't be a butt")).toBe(`Don't be a ${profanity.options.grawlix}`);
3636
});
3737
it("should censor multiple occurrences of the same profane word", () => {
38-
expect(profanity.censor("Butt, butt, butt!")).to.equal(
39-
`${profanity.options.grawlix}, ${profanity.options.grawlix}, ${profanity.options.grawlix}!`,
40-
);
38+
expect(profanity.censor("Butt, butt, butt!")).toBe(`${profanity.options.grawlix}, ${profanity.options.grawlix}, ${profanity.options.grawlix}!`);
4139
});
4240

4341
it("should not censor parts of words that contain profanity", () => {
44-
expect(profanity.censor("I need to assess the situation")).to.equal("I need to assess the situation");
42+
expect(profanity.censor("I need to assess the situation")).toBe("I need to assess the situation");
4543
});
4644

4745
it("should censor profanity separated by hyphens", () => {
48-
expect(profanity.censor("Don't be a butt-head")).to.equal(`Don't be a ${profanity.options.grawlix}-head`);
46+
expect(profanity.censor("Don't be a butt-head")).toBe(`Don't be a ${profanity.options.grawlix}-head`);
4947
});
5048

5149
it("should censor profanity separated by underscores", () => {
52-
expect(profanity.censor("Don't be a butt_head")).to.equal(`Don't be a ${profanity.options.grawlix}_head`);
50+
expect(profanity.censor("Don't be a butt_head")).toBe(`Don't be a ${profanity.options.grawlix}_head`);
5351
});
5452

5553
it("should censor profanity surrounded by emoji", () => {
56-
expect(profanity.censor("That's 💩butt💩")).to.equal(`That's 💩${profanity.options.grawlix}💩`);
54+
expect(profanity.censor("That's 💩butt💩")).toBe(`That's 💩${profanity.options.grawlix}💩`);
5755
});
5856
});
5957

6058
describe("CensorType.FirstChar", () => {
6159
it("should replace first character of each profane word with grawlix character", () => {
6260
const censored = profanity.censor("I like big butts (aka arses) and I cannot lie", CensorType.FirstChar);
63-
expect(censored).to.equal(`I like big ${profanity.options.grawlixChar}utts (aka ${profanity.options.grawlixChar}rses) and I cannot lie`);
61+
expect(censored).toBe(`I like big ${profanity.options.grawlixChar}utts (aka ${profanity.options.grawlixChar}rses) and I cannot lie`);
6462
});
6563

6664
it("should preserve case when censoring first character", () => {
67-
expect(profanity.censor("Don't be a BuTt", CensorType.FirstChar)).to.equal(`Don't be a ${profanity.options.grawlixChar}uTt`);
65+
expect(profanity.censor("Don't be a BuTt", CensorType.FirstChar)).toBe(`Don't be a ${profanity.options.grawlixChar}uTt`);
6866
});
6967

7068
it("should censor first character of profanity at the beginning of a sentence", () => {
71-
expect(profanity.censor("Butt is a profane word", CensorType.FirstChar)).to.equal(`${profanity.options.grawlixChar}utt is a profane word`);
69+
expect(profanity.censor("Butt is a profane word", CensorType.FirstChar)).toBe(`${profanity.options.grawlixChar}utt is a profane word`);
7270
});
7371

7472
it("should censor first character of profanity at the end of a sentence", () => {
75-
expect(profanity.censor("Don't be a butt.", CensorType.FirstChar)).to.equal(`Don't be a ${profanity.options.grawlixChar}utt.`);
73+
expect(profanity.censor("Don't be a butt.", CensorType.FirstChar)).toBe(`Don't be a ${profanity.options.grawlixChar}utt.`);
7674
});
7775

7876
it("should censor first character of profanity separated by hyphens", () => {
79-
expect(profanity.censor("Don't be a butt-head", CensorType.FirstChar)).to.equal(`Don't be a ${profanity.options.grawlixChar}utt-head`);
77+
expect(profanity.censor("Don't be a butt-head", CensorType.FirstChar)).toBe(`Don't be a ${profanity.options.grawlixChar}utt-head`);
8078
});
8179

8280
it("should censor first character of profanity separated by underscores", () => {
83-
expect(profanity.censor("Don't be a butt_head", CensorType.FirstChar)).to.equal(`Don't be a ${profanity.options.grawlixChar}utt_head`);
81+
expect(profanity.censor("Don't be a butt_head", CensorType.FirstChar)).toBe(`Don't be a ${profanity.options.grawlixChar}utt_head`);
8482
});
8583
});
8684
describe("CensorType.FirstVowel", () => {
8785
it("should replace first vowel of each profane word with grawlix character", () => {
8886
const censored = profanity.censor("I like big butts (aka arses) and I cannot lie", CensorType.FirstVowel);
89-
expect(censored).to.equal(`I like big b${profanity.options.grawlixChar}tts (aka ${profanity.options.grawlixChar}rses) and I cannot lie`);
87+
expect(censored).toBe(`I like big b${profanity.options.grawlixChar}tts (aka ${profanity.options.grawlixChar}rses) and I cannot lie`);
9088
});
9189

9290
it("should not censor if no vowels are present", () => {
93-
expect(profanity.censor("tsk tsk", CensorType.FirstVowel)).to.equal("tsk tsk");
91+
expect(profanity.censor("tsk tsk", CensorType.FirstVowel)).toBe("tsk tsk");
9492
});
9593

9694
it("should censor first vowel of profanity at the beginning of a sentence", () => {
97-
expect(profanity.censor("Butt is a profane word", CensorType.FirstVowel)).to.equal(`B${profanity.options.grawlixChar}tt is a profane word`);
95+
expect(profanity.censor("Butt is a profane word", CensorType.FirstVowel)).toBe(`B${profanity.options.grawlixChar}tt is a profane word`);
9896
});
9997

10098
it("should censor first vowel of profanity at the end of a sentence", () => {
101-
expect(profanity.censor("Don't be a butt.", CensorType.FirstVowel)).to.equal(`Don't be a b${profanity.options.grawlixChar}tt.`);
99+
expect(profanity.censor("Don't be a butt.", CensorType.FirstVowel)).toBe(`Don't be a b${profanity.options.grawlixChar}tt.`);
102100
});
103101

104102
it("should handle profane words with no vowels", () => {
105-
expect(profanity.censor("Don't say tsk", CensorType.FirstVowel)).to.equal("Don't say tsk");
103+
expect(profanity.censor("Don't say tsk", CensorType.FirstVowel)).toBe("Don't say tsk");
106104
});
107105

108106
it("should censor first vowel of profanity separated by hyphens", () => {
109-
expect(profanity.censor("Don't be a butt-head", CensorType.FirstVowel)).to.equal(`Don't be a b${profanity.options.grawlixChar}tt-head`);
107+
expect(profanity.censor("Don't be a butt-head", CensorType.FirstVowel)).toBe(`Don't be a b${profanity.options.grawlixChar}tt-head`);
110108
});
111109
it("should censor first vowel of profanity separated by underscores", () => {
112-
expect(profanity.censor("Don't be a butt_head", CensorType.FirstVowel)).to.equal(`Don't be a b${profanity.options.grawlixChar}tt_head`);
110+
expect(profanity.censor("Don't be a butt_head", CensorType.FirstVowel)).toBe(`Don't be a b${profanity.options.grawlixChar}tt_head`);
113111
});
114112
});
115113

116114
describe("CensorType.AllVowels", () => {
117115
it("should replace all vowels within each profane word with grawlix character", () => {
118116
const censored = profanity.censor("I like big butts (aka arses) and I cannot lie", CensorType.AllVowels);
119-
expect(censored).to.equal(
117+
expect(censored).toBe(
120118
`I like big b${profanity.options.grawlixChar}tts (aka ${profanity.options.grawlixChar}rs${profanity.options.grawlixChar}s) and I cannot lie`,
121119
);
122120
});
123121

124122
it("should preserve case when censoring all vowels", () => {
125-
expect(profanity.censor("BuTt", CensorType.AllVowels)).to.equal(`B${profanity.options.grawlixChar}Tt`);
123+
expect(profanity.censor("BuTt", CensorType.AllVowels)).toBe(`B${profanity.options.grawlixChar}Tt`);
126124
});
127125

128126
it("should censor all vowels of profanity at the beginning of a sentence", () => {
129-
expect(profanity.censor("Butt is a profane word", CensorType.AllVowels)).to.equal(`B${profanity.options.grawlixChar}tt is a profane word`);
127+
expect(profanity.censor("Butt is a profane word", CensorType.AllVowels)).toBe(`B${profanity.options.grawlixChar}tt is a profane word`);
130128
});
131129

132130
it("should censor all vowels of profanity at the end of a sentence", () => {
133-
expect(profanity.censor("Don't be a butt.", CensorType.AllVowels)).to.equal(`Don't be a b${profanity.options.grawlixChar}tt.`);
131+
expect(profanity.censor("Don't be a butt.", CensorType.AllVowels)).toBe(`Don't be a b${profanity.options.grawlixChar}tt.`);
134132
});
135133

136134
it("should handle profane words with no vowels", () => {
137-
expect(profanity.censor("Don't say tsk", CensorType.AllVowels)).to.equal("Don't say tsk");
135+
expect(profanity.censor("Don't say tsk", CensorType.AllVowels)).toBe("Don't say tsk");
138136
});
139137
});
140138
describe("Case sensitivity", () => {
141139
it("should censor while preserving case", () => {
142-
expect(profanity.censor("Don't be a BuTt")).to.equal("Don't be a @#$%&!");
140+
expect(profanity.censor("Don't be a BuTt")).toBe("Don't be a @#$%&!");
143141
});
144142

145143
it("should censor all uppercase profanity", () => {
146-
expect(profanity.censor("DON'T BE A BUTT")).to.equal("DON'T BE A @#$%&!");
144+
expect(profanity.censor("DON'T BE A BUTT")).toBe("DON'T BE A @#$%&!");
147145
});
148146

149147
it("should censor mixed case profanity", () => {
150-
expect(profanity.censor("Don't Be A bUtT")).to.equal("Don't Be A @#$%&!");
148+
expect(profanity.censor("Don't Be A bUtT")).toBe("Don't Be A @#$%&!");
151149
});
152150

153151
it("should censor profanity with alternating case", () => {
154-
expect(profanity.censor("dOn'T bE a BuTt")).to.equal("dOn'T bE a @#$%&!");
152+
expect(profanity.censor("dOn'T bE a BuTt")).toBe("dOn'T bE a @#$%&!");
155153
});
156154
});
157155

158156
describe("Multi-word profanities", () => {
159157
it("should censor multi-word profanities", () => {
160-
expect(profanity.censor("He's a fudge packer")).to.equal(`He's a ${profanity.options.grawlix}`);
161-
expect(profanity.censor("That's a blow job")).to.equal(`That's a ${profanity.options.grawlix}`);
162-
expect(profanity.censor("Don't be a son-of-a-bitch")).to.equal(`Don't be a ${profanity.options.grawlix}`);
158+
expect(profanity.censor("He's a fudge packer")).toBe(`He's a ${profanity.options.grawlix}`);
159+
expect(profanity.censor("That's a blow job")).toBe(`That's a ${profanity.options.grawlix}`);
160+
expect(profanity.censor("Don't be a son-of-a-bitch")).toBe(`Don't be a ${profanity.options.grawlix}`);
163161
});
164162

165163
it("should handle multi-word profanities with different censor types", () => {
166-
expect(profanity.censor("He's a fudge packer", CensorType.FirstChar)).to.equal(`He's a ${profanity.options.grawlixChar}udge packer`);
167-
expect(profanity.censor("That's a blow job", CensorType.FirstVowel)).to.equal(`That's a bl${profanity.options.grawlixChar}w job`);
168-
expect(profanity.censor("Don't be a son-of-a-bitch", CensorType.AllVowels)).to.equal(
164+
expect(profanity.censor("He's a fudge packer", CensorType.FirstChar)).toBe(`He's a ${profanity.options.grawlixChar}udge packer`);
165+
expect(profanity.censor("That's a blow job", CensorType.FirstVowel)).toBe(`That's a bl${profanity.options.grawlixChar}w job`);
166+
expect(profanity.censor("Don't be a son-of-a-bitch", CensorType.AllVowels)).toBe(
169167
`Don't be a s${profanity.options.grawlixChar}n-${profanity.options.grawlixChar}f-${profanity.options.grawlixChar}-b${profanity.options.grawlixChar}tch`,
170168
);
171169
});
172170
});
173171

174172
describe("Input type handling", () => {
175173
it("should return original input for non-string input", () => {
176-
expect(profanity.censor(null as any)).to.be.null;
177-
expect(profanity.censor(undefined as any)).to.be.undefined;
178-
expect(profanity.censor(123 as any)).to.equal(123);
179-
expect(profanity.censor(true as any)).to.be.true;
180-
expect(profanity.censor({} as any)).to.deep.equal({});
181-
expect(profanity.censor([] as any)).to.deep.equal([]);
174+
expect(profanity.censor(null as any)).toBeNull();
175+
expect(profanity.censor(undefined as any)).toBeUndefined();
176+
expect(profanity.censor(123 as any)).toBe(123);
177+
expect(profanity.censor(true as any)).toBe(true);
178+
expect(profanity.censor({} as any)).toEqual({});
179+
expect(profanity.censor([] as any)).toEqual([]);
182180
});
183181
});
184182
});

0 commit comments

Comments
 (0)