Skip to content

Commit

Permalink
test: rm underscores from test result assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-anderson committed Jun 17, 2024
1 parent 038d9ed commit 024d2a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/sanitize/id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("sanitize: id", () => {
test("removes all non-ID characters", () => {
const input = `ab c${ZERO_WIDTH_SPACE}1 23${NULL_CONTROL_CHAR}~!@#$%^&*()_+-={}|:"<>?[]\\;',./`;
const result = sanitizeID(input);
expect(result).toBe("abc123#_-");
expect(result).toBe("abc123#-");
expect(result).not.toMatch(ZERO_WIDTH_AND_CONTROL_CHAR_REGEX);
});
});
10 changes: 6 additions & 4 deletions src/validate/id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { isValidID } from "./id.js";
describe("validate: id", () => {
// POSITIVE TEST CASES:

test(`returns true when given a string containing only alphanumeric characters, "-", "_", and/or "#"`, () => {
expect(isValidID("fake-id#abc_123")).toBe(true);
test(`returns true when given a string containing only alphanumeric characters, "#", and/or "-"`, () => {
expect(isValidID("fake-id#abc123")).toBe(true);
});

// NEGATIVE TEST CASES:
Expand All @@ -19,9 +19,11 @@ describe("validate: id", () => {
expect(isValidID("fake-id#abc 123")).toBe(false);
});
test("returns false when given a string containing a disallowed special character", () => {
expect(isValidID("fake-id#abc_123.456!")).toBe(false);
expect(isValidID("fake-id#abc123_456")).toBe(false);
expect(isValidID("fake-id#abc123.456")).toBe(false);
expect(isValidID("fake-id#abc123456!")).toBe(false);
});
test("returns false when given a string containing a null unicode character", () => {
expect(isValidID("fake-id#abc_123\u0000")).toBe(false);
expect(isValidID("fake-id#abc123\u0000")).toBe(false);
});
});

0 comments on commit 024d2a4

Please sign in to comment.