Skip to content

Commit

Permalink
add faker js for fake emails in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdikhody committed Oct 10, 2024
1 parent e05cff6 commit bf83816
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
21 changes: 19 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"test": "vitest ."
},
"devDependencies": {
"@faker-js/faker": "^9.0.3",
"@types/node": "^20.16.11",
"@types/qs": "^6.9.11",
"@typescript-eslint/eslint-plugin": "^6.13.2",
Expand Down
5 changes: 3 additions & 2 deletions tests/utils/addClient.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ClientOptions } from "3x-ui";
import { randomUUID, randomBytes, randomInt } from "crypto";
import { randomUUID, randomInt } from "crypto";
import { faker } from "@faker-js/faker";
import { api } from "./api";

export const addClient = async (inboundId: number) => {
const email = `${randomBytes(10).toString("hex")}@example.com`;
const email = faker.internet.email();
const id = randomUUID();
const expiryTime = Date.now() + randomInt(-864000, 31104000);
const enable = randomInt(0, 10) > 3;
Expand Down
5 changes: 3 additions & 2 deletions tests/utils/addInbound.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { ClientOptions } from "3x-ui";
import { randomBytes, randomUUID, randomInt } from "crypto";
import { faker } from "@faker-js/faker";
import { api } from "./api";

let port = randomInt(10000, 90000);

export const addInbound = async (prefix: string) => {
port++;
const remark = `${prefix} - ${randomBytes(10).toString("hex")}`;
const email = `${randomBytes(10).toString("hex")}@example.com`;
const remark = `${prefix} - ${randomBytes(5).toString("hex")}`;
const email = faker.internet.email();

return api.addInbound({
enable: true,
Expand Down

0 comments on commit bf83816

Please sign in to comment.