From 7b50c2f0126ac865d4e4efea360b8ba71f0cb7c6 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Sat, 10 Dec 2022 20:18:01 +0100 Subject: [PATCH] feat(number): adjust hex default (#1649) --- src/modules/number/index.ts | 8 ++++---- test/__snapshots__/number.spec.ts.snap | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/number/index.ts b/src/modules/number/index.ts index cef0b27c5aa..62036ab1752 100644 --- a/src/modules/number/index.ts +++ b/src/modules/number/index.ts @@ -117,12 +117,12 @@ export class NumberModule { * * @param options Maximum value or options object. Defaults to `{}`. * @param options.min Lower bound for generated number. Defaults to `0`. - * @param options.max Upper bound for generated number. Defaults to `min + 16`. + * @param options.max Upper bound for generated number. Defaults to `15`. * * @example * faker.number.hex() // 'b' - * faker.number.hex(16) // '9' - * faker.number.hex({ min: 0, max: 65536 }) // 'af17' + * faker.number.hex(255) // '9d' + * faker.number.hex({ min: 0, max: 65535 }) // 'af17' * * @since 8.0.0 */ @@ -131,7 +131,7 @@ export class NumberModule { options = { max: options }; } - const { min = 0, max = min + 16 } = options; + const { min = 0, max = 15 } = options; return this.int({ max, diff --git a/test/__snapshots__/number.spec.ts.snap b/test/__snapshots__/number.spec.ts.snap index 14b16521ee5..91295faad18 100644 --- a/test/__snapshots__/number.spec.ts.snap +++ b/test/__snapshots__/number.spec.ts.snap @@ -24,7 +24,7 @@ exports[`number > 42 > float > with min, max and precision 1`] = `-0.4261`; exports[`number > 42 > float > with plain number 1`] = `1.5`; -exports[`number > 42 > hex > noArgs 1`] = `"6"`; +exports[`number > 42 > hex > noArgs 1`] = `"5"`; exports[`number > 42 > hex > with options 1`] = `"4"`; @@ -60,7 +60,7 @@ exports[`number > 1211 > float > with min, max and precision 1`] = `61.0658`; exports[`number > 1211 > float > with plain number 1`] = `3.72`; -exports[`number > 1211 > hex > noArgs 1`] = `"f"`; +exports[`number > 1211 > hex > noArgs 1`] = `"e"`; exports[`number > 1211 > hex > with options 1`] = `"a"`;