Skip to content

Commit d49728f

Browse files
committed
Fix tests and add jose to allowed transform pattenrs in jest config
1 parent ffb6d85 commit d49728f

2 files changed

Lines changed: 3 additions & 26 deletions

File tree

jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default {
1515
"^.+\\.js$": ["@swc/jest"],
1616
},
1717
transformIgnorePatterns: [
18-
"node_modules/(?!(nanoid|@jsep|fastpriorityqueue|@datastructures-js)/)",
18+
"node_modules/(?!(nanoid|@jsep|fastpriorityqueue|@datastructures-js|jose)/)",
1919
],
2020
collectCoverageFrom: ["src/**/*.ts", "!src/**/*.d.ts"],
2121
coverageThreshold: {

tests/Censor.test.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ import {
3535
fixProfaneUsername,
3636
isProfaneUsername,
3737
MAX_USERNAME_LENGTH,
38-
MIN_USERNAME_LENGTH,
39-
sanitizeUsername,
4038
validateUsername,
4139
} from "../src/core/validations/username";
4240

@@ -105,30 +103,9 @@ describe("username.ts functions", () => {
105103
const res = validateUsername("Good_Name123");
106104
expect(res.isValid).toBe(true);
107105
});
108-
test("accepts allowed Unicode like 🐈 or ü", () => {
109-
const res = validateUsername("Cat🐈Üser");
106+
test("accepts allowed Unicode like ü", () => {
107+
const res = validateUsername("Üser");
110108
expect(res.isValid).toBe(true);
111109
});
112110
});
113-
114-
describe("sanitizeUsername", () => {
115-
test.each([
116-
{ input: "GoodName", expected: "GoodName" },
117-
{ input: "a!", expected: "axx" },
118-
{ input: "a$%b", expected: "abx" },
119-
{
120-
input: "abc".repeat(10),
121-
expected: "abc"
122-
.repeat(Math.floor(MAX_USERNAME_LENGTH / 3))
123-
.slice(0, MAX_USERNAME_LENGTH),
124-
},
125-
{ input: "", expected: "xxx" },
126-
{ input: "Ünicode🐈Test!", expected: "Ünicode🐈Test" },
127-
])('sanitizeUsername("%s") → "%s"', ({ input, expected }) => {
128-
const out = sanitizeUsername(input);
129-
expect(out).toBe(expected);
130-
expect(out.length).toBeGreaterThanOrEqual(MIN_USERNAME_LENGTH);
131-
expect(out.length).toBeLessThanOrEqual(MAX_USERNAME_LENGTH);
132-
});
133-
});
134111
});

0 commit comments

Comments
 (0)