diff options
| author | Andrew Titmuss <[email protected]> | 2022-08-05 00:52:40 +1000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-08-04 14:52:40 +0000 |
| commit | 5979f82e17d4f9adf80fa795afb668d57b33411f (patch) | |
| tree | 4c72e46b71d273c7b01e9553819d22cc398d61b2 /test/system.spec.ts | |
| parent | 407466f3cbb7e9d4575c9df342ceb489633d5379 (diff) | |
| download | faker-5979f82e17d4f9adf80fa795afb668d57b33411f.tar.xz faker-5979f82e17d4f9adf80fa795afb668d57b33411f.zip | |
feat(system.networkInterface): add networkInterface faker (#1133)
Co-authored-by: Shinigami <[email protected]>
Diffstat (limited to 'test/system.spec.ts')
| -rw-r--r-- | test/system.spec.ts | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/test/system.spec.ts b/test/system.spec.ts index 8a44201d..05e2c53d 100644 --- a/test/system.spec.ts +++ b/test/system.spec.ts @@ -16,6 +16,7 @@ const functionNames = [ 'filePath', 'fileType', 'mimeType', + 'networkInterface', 'semver', ]; @@ -46,6 +47,24 @@ describe('system', () => { t.describe('fileExt', (t) => { t.it('noArgs').it('with mimeType', 'application/json'); }); + + t.describe('networkInterface', (t) => { + t.it('noArgs'); + for (const interfaceSchema of [ + undefined, + 'index', + 'slot', + 'mac', + 'pci', + ] as const) { + for (const interfaceType of [undefined, 'en', 'wl', 'ww'] as const) { + t.it(`with ${JSON.stringify({ interfaceType, interfaceSchema })}`, { + interfaceType, + interfaceSchema, + }); + } + } + }); }); for (const seed of seededRuns) { @@ -76,6 +95,7 @@ describe('system', () => { 'jpg', 'm1v', 'm2a', + 'm1v', 'm2v', 'm3a', 'mp2', @@ -283,6 +303,88 @@ describe('system', () => { ).toSatisfy(validator.isSemVer); }); }); + + describe('networkInterface()', () => { + it('should return network interface', () => { + const networkInterface = faker.system.networkInterface(); + + expect( + networkInterface, + `generated network interface should be valid network interface.` + ).toMatch( + /^(?:P\d)?(?:en|wl|ww)(?:o\d|s\d(?:f\d)?(?:d\d)?|x[a-f\d]{12}|p\ds\d(?:f\d)?(?:d\d)?)$/ + ); + }); + + it('should return a network interface with a given type', () => { + const networkInterface = faker.system.networkInterface({ + interfaceType: 'wl', + }); + + expect( + networkInterface, + `generated network interface should be valid network interface.` + ).toMatch( + /^(?:P\d)?wl(?:o\d|s\d(?:f\d)?(?:d\d)?|x[a-f\d]{12}|p\ds\d(?:f\d)?(?:d\d)?)$/ + ); + }); + + it('should return a network interface with an index schema', () => { + const networkInterface = faker.system.networkInterface({ + interfaceSchema: 'index', + }); + + expect( + networkInterface, + `generated network interface should be valid network interface.` + ).toMatch(/^(?:en|wl|ww)o\d$/); + }); + + it('should return a network interface with a slot schema', () => { + const networkInterface = faker.system.networkInterface({ + interfaceSchema: 'slot', + }); + + expect( + networkInterface, + `generated network interface should be valid network interface.` + ).toMatch(/^(?:en|wl|ww)s\d(?:f\d)?(?:d\d)?$/); + }); + + it('should return a network interface with a mac schema', () => { + const networkInterface = faker.system.networkInterface({ + interfaceSchema: 'mac', + }); + + expect( + networkInterface, + `generated network interface should be valid network interface.` + ).toMatch(/^(?:en|wl|ww)x[a-f\d]{12}$/); + }); + + it('should return a network interface with a pci schema', () => { + const networkInterface = faker.system.networkInterface({ + interfaceSchema: 'pci', + }); + + expect( + networkInterface, + `generated network interface should be valid network interface.` + ).toMatch(/^(?:P\d)?(?:en|wl|ww)p\ds\d(?:f\d)?(?:d\d)?$/); + }); + + it('should return a network interface with a given type and schema', () => { + const networkInterface = faker.system.networkInterface({ + interfaceType: 'en', + interfaceSchema: 'mac', + }); + + expect( + networkInterface, + `generated network interface should be valid network interface.` + ).toMatch(/^enx[a-f\d]{12}$/); + }); + }); } }); |
