diff options
| author | Piotr Kuczynski <[email protected]> | 2022-03-31 19:48:24 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-03-31 17:48:24 +0000 |
| commit | 03041201c21ad599bbe1874c375f4f41b94961ba (patch) | |
| tree | cd4de61bc8d8bfa40984ef60fbc224391ebc01e4 /test | |
| parent | 0b350f929624a1247f35549c61148ec93e5f0c0a (diff) | |
| download | faker-03041201c21ad599bbe1874c375f4f41b94961ba.tar.xz faker-03041201c21ad599bbe1874c375f4f41b94961ba.zip | |
fix: datatype.number when min = max + precision, throw when max > min (#664)
Diffstat (limited to 'test')
| -rw-r--r-- | test/address.spec.ts | 2 | ||||
| -rw-r--r-- | test/datatype.spec.ts | 23 | ||||
| -rw-r--r-- | test/system.spec.ts | 20 | ||||
| -rw-r--r-- | test/word.spec.ts | 48 |
4 files changed, 53 insertions, 40 deletions
diff --git a/test/address.spec.ts b/test/address.spec.ts index 729d9190..5929f462 100644 --- a/test/address.spec.ts +++ b/test/address.spec.ts @@ -411,7 +411,7 @@ describe('address', () => { it('returns latitude with min and max and default precision', () => { for (let i = 0; i < 100; i++) { - const latitude = faker.address.latitude(-5, 5); + const latitude = faker.address.latitude(5, -5); expect(latitude).toBeTypeOf('string'); expect( diff --git a/test/datatype.spec.ts b/test/datatype.spec.ts index 902cf9ba..e4d69fe6 100644 --- a/test/datatype.spec.ts +++ b/test/datatype.spec.ts @@ -8,7 +8,7 @@ const seededRuns = [ number: { noArgs: 37454, numbers: [2, 5, 6, 1, 5], - withMin: 37427, + withMin: 37412, withMinAndMax: -1, withMax: 26, withMinAndMaxAndPrecision: -0.43, @@ -16,7 +16,7 @@ const seededRuns = [ float: { noArgs: 37453.64, numbers: [37452, 79656, 95076, 18342, 73200], - withMin: 37427.37, + withMin: 37411.64, withMinAndMax: -0.43, withMax: 25.84, withMinAndMaxAndPrecision: -0.4261, @@ -80,7 +80,7 @@ const seededRuns = [ number: { noArgs: 26202, numbers: [1, 3, 1, 1, 1], - withMin: 26171, + withMin: 26160, withMinAndMax: -13, withMax: 18, withMinAndMaxAndPrecision: -12.92, @@ -88,7 +88,7 @@ const seededRuns = [ float: { noArgs: 26202.2, numbers: [26202, 56052, 15864, 21258, 27810], - withMin: 26171.21, + withMin: 26160.2, withMinAndMax: -12.92, withMax: 18.08, withMinAndMaxAndPrecision: -12.9153, @@ -152,7 +152,7 @@ const seededRuns = [ number: { noArgs: 92852, numbers: [6, 3, 6, 5, 1], - withMin: 92849, + withMin: 92810, withMinAndMax: 61, withMax: 64, withMinAndMaxAndPrecision: 61.07, @@ -160,7 +160,7 @@ const seededRuns = [ float: { noArgs: 92851.09, numbers: [92856, 45900, 89346, 77826, 22554], - withMin: 92848.09, + withMin: 92809.09, withMinAndMax: 61.07, withMax: 64.07, withMinAndMaxAndPrecision: 61.0658, @@ -288,6 +288,17 @@ describe('datatype', () => { }); expect(actual).toEqual(expectations.number.withMinAndMaxAndPrecision); }); + + it('should throw when min > max', () => { + const min = 10; + const max = 9; + + faker.seed(seed); + + expect(() => { + faker.datatype.number({ min, max }); + }).toThrowError(`Max ${max} should be larger then min ${min}`); + }); }); describe('float', () => { diff --git a/test/system.spec.ts b/test/system.spec.ts index e9eee506..e3e7f692 100644 --- a/test/system.spec.ts +++ b/test/system.spec.ts @@ -7,45 +7,45 @@ const seededRuns = [ { seed: 42, expectations: { - fileName: 'mobile_application.wad', - commonFileName: 'mobile_application.gif', + fileName: 'mobile_fish.gif', + commonFileName: 'mobile_fish.mpe', mimeType: 'application/vnd.marlin.drm.license+xml', commonFileType: 'audio', commonFileExt: 'png', fileType: 'image', fileExt: 'chm', directoryPath: '/opt/bin', - filePath: '/opt/bin/directives_savings_computer.qwd', + filePath: '/opt/bin/directives_application_home.paw', semver: '3.7.9', }, }, { seed: 1337, expectations: { - fileName: 'delaware.vcg', - commonFileName: 'delaware.wav', + fileName: 'delaware.uvvt', + commonFileName: 'delaware.mp2', mimeType: 'application/vnd.dxr', commonFileType: 'audio', commonFileExt: 'wav', fileType: 'font', fileExt: 'gxt', directoryPath: '/Library', - filePath: '/Library/bike_kiribati.kpr', + filePath: '/Library/bike_interactive.qwt', semver: '2.5.1', }, }, { seed: 1211, expectations: { - fileName: 'turnpike_supervisor_chicken.mka', - commonFileName: 'turnpike_supervisor_chicken.mp4v', + fileName: 'turnpike_frozen_handcrafted.mka', + commonFileName: 'turnpike_frozen_handcrafted.mp4v', mimeType: 'text/vnd.fmi.flexstor', commonFileType: 'application', commonFileExt: 'htm', fileType: 'x-shader', fileExt: 'opml', directoryPath: '/var/log', - filePath: '/var/log/forward_frozen.swf', + filePath: '/var/log/forward_supervisor.swf', semver: '9.4.8', }, }, @@ -101,6 +101,8 @@ describe('system', () => { 'jpeg', 'm2a', 'm2v', + 'mp2', + 'mp3', 'mp4', 'mp4v', 'mpeg', diff --git a/test/word.spec.ts b/test/word.spec.ts index ac40c8a5..d236f564 100644 --- a/test/word.spec.ts +++ b/test/word.spec.ts @@ -8,37 +8,37 @@ const seededRuns = [ adjective: { noArgs: 'harmonious', length10: 'gregarious', - length20: 'stable', + length20: 'harmonious', }, adverb: { noArgs: 'jealously', length10: 'generously', - length20: 'swiftly', + length20: 'jealously', }, conjunction: { noArgs: 'however', length10: 'as much as', - length20: 'since', + length20: 'however', }, interjection: { noArgs: 'yahoo', - length10: 'ack', - length20: 'ack', + length10: 'yahoo', + length20: 'yahoo', }, noun: { noArgs: 'gale', length10: 'exposition', - length20: 'shift', + length20: 'gale', }, preposition: { noArgs: 'concerning', length10: 'throughout', - length20: 'than', + length20: 'concerning', }, verb: { noArgs: 'function', length10: 'exasperate', - length20: 'shred', + length20: 'function', }, }, }, @@ -48,37 +48,37 @@ const seededRuns = [ adjective: { noArgs: 'fabulous', length10: 'enchanting', - length20: 'neat', + length20: 'fabulous', }, adverb: { noArgs: 'frankly', length10: 'enormously', - length20: 'overconfidently', + length20: 'frankly', }, conjunction: { noArgs: 'even if', length10: 'as long as', - length20: 'instead', + length20: 'even if', }, interjection: { noArgs: 'ew', - length10: 'yippee', - length20: 'yippee', + length10: 'ew', + length20: 'ew', }, noun: { noArgs: 'digit', length10: 'depressive', - length20: 'might', + length20: 'digit', }, preposition: { noArgs: 'barring', length10: 'concerning', - length20: 'midst', + length20: 'barring', }, verb: { noArgs: 'dispense', length10: 'demoralize', - length20: 'nearest', + length20: 'dispense', }, }, }, @@ -88,37 +88,37 @@ const seededRuns = [ adjective: { noArgs: 'verifiable', length10: 'unfinished', - length20: 'joyous', + length20: 'verifiable', }, adverb: { noArgs: 'viciously', length10: 'unbearably', - length20: 'loudly', + length20: 'viciously', }, conjunction: { noArgs: 'whereas', length10: 'as soon as', - length20: 'in addition', + length20: 'whereas', }, interjection: { noArgs: 'er', - length10: 'gah', - length20: 'gah', + length10: 'er', + length20: 'er', }, noun: { noArgs: 'trick', length10: 'trafficker', - length20: 'infection', + length20: 'trick', }, preposition: { noArgs: 'upon', length10: 'underneath', - length20: 'for', + length20: 'upon', }, verb: { noArgs: 'trick', length10: 'trampoline', - length20: 'intercede', + length20: 'trick', }, }, }, |
