mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-02 05:02:27 +08:00
test(server/utils): add tests for sanitizeSqlIdentifier
This commit is contained in:
parent
03c1128a72
commit
33346e0cee
@ -43,7 +43,28 @@ describe("#isEmptyOrWhitespace", () => {
|
||||
|
||||
});
|
||||
|
||||
describe.todo("#sanitizeSqlIdentifier", () => {});
|
||||
describe("#sanitizeSqlIdentifier", () => {
|
||||
|
||||
const testCases: TestCase<typeof utils.sanitizeSqlIdentifier>[] = [
|
||||
["w/ 'test' it should not strip anything", ["test"], "test"],
|
||||
["w/ 'test123' it should not strip anything", ["test123"], "test123"],
|
||||
["w/ 'tEst_TeSt' it should not strip anything", ["tEst_TeSt"], "tEst_TeSt"],
|
||||
["w/ 'test_test' it should not strip '_'", ["test_test"], "test_test"],
|
||||
["w/ 'test-' it should strip the '-'", ["test-"], "test"],
|
||||
["w/ 'test-test' it should strip the '-'", ["test-test"], "testtest"],
|
||||
["w/ 'test; --test' it should strip the '; --'", ["test; --test"], "testtest"],
|
||||
["w/ 'test test' it should strip the ' '", ["test test"], "testtest"],
|
||||
];
|
||||
|
||||
testCases.forEach(testCase => {
|
||||
const [desc, fnParams, expected] = testCase;
|
||||
it(desc, () => {
|
||||
const result = utils.sanitizeSqlIdentifier(...fnParams);
|
||||
expect(result).toStrictEqual(expected);
|
||||
})
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe.todo("#escapeHtml", () => {});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user