-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3da28e6
commit 4cb2b6f
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './user'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {faker} from '@faker-js/faker'; | ||
|
||
import {getRandom} from './util'; | ||
|
||
import {birthType, roles} from '@/constants'; | ||
import type {Member} from '@/types'; | ||
import {formatDate} from '@/utils'; | ||
|
||
export function createUser(isHost: boolean): Member { | ||
return { | ||
nickName: faker.person.fullName(), | ||
groupRole: getRandom(roles), | ||
birth: formatDate(faker.date.birthdate()), | ||
birthType: getRandom(birthType), | ||
email: faker.internet.email(), | ||
signUpDate: faker.date.past(), | ||
isHost, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function getRandomInt(min: number, max: number): number { | ||
min = Math.ceil(min); | ||
max = Math.floor(max); | ||
return Math.floor(Math.random() * (max - min + 1)) + min; | ||
} | ||
|
||
export function getRandom<T>(source: readonly T[]): T { | ||
return source[getRandomInt(0, source.length - 1)]; | ||
} |