1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import { describe, expect, it } from 'vitest';
import { faker } from '../src';
import { luhnCheck } from '../src/modules/helpers/luhn-check';
import { seededTests } from './support/seededRuns';
const NON_SEEDED_BASED_RUN = 25;
describe('phone', () => {
seededTests(faker, 'phone', (t) => {
t.it('imei');
t.describe('number', (t) => {
t.it('noArgs').it('format', '###-###-####');
});
});
describe(`random seeded tests for seed ${faker.seed()}`, () => {
for (let i = 1; i <= NON_SEEDED_BASED_RUN; i++) {
describe('number()', () => {
it('should return a random phoneNumber with a random format', () => {
const phoneNumber = faker.phone.number();
expect(phoneNumber).toMatch(/\d/);
});
});
describe('imei()', () => {
it('should return a string', () => {
const imei = faker.phone.imei();
expect(imei).toBeTypeOf('string');
});
it('should have a length of 18', () => {
const imei = faker.phone.imei();
expect(imei).toHaveLength(18);
});
it('should be Luhn-valid', () => {
const imei = faker.phone.imei();
expect(imei).toSatisfy(luhnCheck);
});
});
}
});
});
|