chore: 补充单元测试

This commit is contained in:
xiaojunnuo
2026-05-05 18:44:43 +08:00
parent 7c1d92ff4b
commit e0143fa540
5 changed files with 273 additions and 0 deletions
@@ -0,0 +1,18 @@
/// <reference types="mocha" />
import { expect } from "chai";
import { randomNumber, simpleNanoId } from "./util.id.js";
describe("id utils", () => {
it("generates a four digit random number string", () => {
expect(randomNumber()).to.match(/^\d{4}$/);
});
it("generates a twelve character simple nano id", () => {
const id = simpleNanoId();
expect(id).to.have.length(12);
expect(id).to.match(/^[0-9a-zA-Z]+$/);
});
});