aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEric Cheng <[email protected]>2022-04-10 12:38:45 -0400
committerGitHub <[email protected]>2022-04-10 18:38:45 +0200
commitc25ecd08ec57fae5967148bee14fec1c4be99472 (patch)
treef417493f2c3a93c43f4ff2e8348496fdb6c2df36 /test
parent301ad541154648bb8e72eb2e3d33ec5ac581e3ef (diff)
downloadfaker-c25ecd08ec57fae5967148bee14fec1c4be99472.tar.xz
faker-c25ecd08ec57fae5967148bee14fec1c4be99472.zip
feat: phone IMEI (#829)
Diffstat (limited to 'test')
-rw-r--r--test/phone.spec.ts34
1 files changed, 33 insertions, 1 deletions
diff --git a/test/phone.spec.ts b/test/phone.spec.ts
index 0f80f038..162de031 100644
--- a/test/phone.spec.ts
+++ b/test/phone.spec.ts
@@ -1,5 +1,6 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { faker } from '../src';
+import { luhnCheck } from './support/luhnCheck';
const seededRuns = [
{
@@ -15,6 +16,9 @@ const seededRuns = [
phoneFormats: {
noArgs: '!##.!##.####',
},
+ imei: {
+ noArgs: '37-917755-141004-5',
+ },
},
},
{
@@ -30,6 +34,9 @@ const seededRuns = [
phoneFormats: {
noArgs: '(!##) !##-####',
},
+ imei: {
+ noArgs: '25-122540-325523-6',
+ },
},
},
{
@@ -45,11 +52,19 @@ const seededRuns = [
phoneFormats: {
noArgs: '1-!##-!##-#### x#####',
},
+ imei: {
+ noArgs: '94-872190-616274-6',
+ },
},
},
];
-const functionNames = ['phoneNumber', 'phoneNumberFormat', 'phoneFormats'];
+const functionNames = [
+ 'phoneNumber',
+ 'phoneNumberFormat',
+ 'phoneFormats',
+ 'imei',
+];
const NON_SEEDED_BASED_RUN = 25;
@@ -125,6 +140,23 @@ describe('phone', () => {
expect(faker.definitions.phone_number.formats).contain(phoneFormat);
});
});
+
+ 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).satisfy(luhnCheck);
+ });
+ });
}
});
});