mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 15:24:55 +00:00
fix slug and faker
This commit is contained in:
parent
e2f885b11b
commit
0978c5a2b8
@ -2,7 +2,7 @@ import Headers from '../../../Types/API/Headers';
|
||||
import Faker from '../../../Utils/Faker';
|
||||
describe('Headers', () => {
|
||||
test('should compile', () => {
|
||||
const apiKey: string = Faker.random16Numbers();
|
||||
const apiKey: string = Faker.randomNumbers(16);
|
||||
const headers: Headers = {
|
||||
accept: 'application/json',
|
||||
'x-api-key': apiKey,
|
||||
|
@ -5,15 +5,14 @@ import Phone from '../Types/Phone';
|
||||
|
||||
export default class Faker {
|
||||
public static generateName(): string {
|
||||
return faker.person.fullName();
|
||||
return faker.string.alphanumeric(10);
|
||||
}
|
||||
|
||||
public static generateCompanyName(): string {
|
||||
return faker.company.name();
|
||||
}
|
||||
|
||||
public static random16Numbers(): string {
|
||||
const count: number = 16;
|
||||
public static randomNumbers(count: number): string {
|
||||
const randomNumbers: Array<number> = [];
|
||||
for (let i: number = 0; i < count; i++) {
|
||||
randomNumbers.push(Math.floor(Math.random() * 10)); // You can adjust the range as needed
|
||||
|
@ -1,6 +1,4 @@
|
||||
import slugify from 'slugify';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
import { numbers } from 'nanoid-dictionary';
|
||||
import Faker from './Faker';
|
||||
|
||||
export default class Slug {
|
||||
@ -15,7 +13,7 @@ export default class Slug {
|
||||
}
|
||||
|
||||
let slug: string = slugify(name, { remove: /[&*+~.,\\/()|'"!:@]+/g });
|
||||
slug = `${slug}-${customAlphabet(numbers, 10)()}`;
|
||||
slug = `${slug}-${Faker.randomNumbers(7)}`;
|
||||
slug = slug.toLowerCase();
|
||||
|
||||
return slug;
|
||||
|
@ -49,7 +49,7 @@ export const testDataSourceOptions: DataSourceOptions = {
|
||||
port: DatabasePort.toNumber(),
|
||||
username: DatabaseUsername,
|
||||
password: DatabasePassword,
|
||||
database: DatabaseName + Faker.random16Numbers(),
|
||||
database: DatabaseName + Faker.randomNumbers(16),
|
||||
entities: Entities,
|
||||
synchronize:
|
||||
Env === AppEnvironment.Test || Env === AppEnvironment.Development,
|
||||
|
Loading…
Reference in New Issue
Block a user