aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorShinigami <[email protected]>2024-03-12 15:51:52 +0100
committerGitHub <[email protected]>2024-03-12 14:51:52 +0000
commita672d277b883a445a852f9b6db18818104e8de7e (patch)
treef140a6802b1b281d0c14f4418c62aa32b85318d5 /test
parent19bcf886e41b13a6b77b92bac4775b18e8aa9418 (diff)
downloadfaker-a672d277b883a445a852f9b6db18818104e8de7e.tar.xz
faker-a672d277b883a445a852f9b6db18818104e8de7e.zip
refactor(number)!: remove v8 deprecated number parameter (#2738)
Diffstat (limited to 'test')
-rw-r--r--test/modules/__snapshots__/number.spec.ts.snap6
-rw-r--r--test/modules/number.spec.ts83
2 files changed, 2 insertions, 87 deletions
diff --git a/test/modules/__snapshots__/number.spec.ts.snap b/test/modules/__snapshots__/number.spec.ts.snap
index 49bd6675..8c3f5ccc 100644
--- a/test/modules/__snapshots__/number.spec.ts.snap
+++ b/test/modules/__snapshots__/number.spec.ts.snap
@@ -30,8 +30,6 @@ exports[`number > 42 > float > with min, max and fractionDigits 1`] = `-0.4261`;
exports[`number > 42 > float > with min, max and multipleOf 1`] = `-0.4261`;
-exports[`number > 42 > float > with min, max and precision 1`] = `-0.4261`;
-
exports[`number > 42 > float > with plain number 1`] = `1.49816047538945`;
exports[`number > 42 > hex > noArgs 1`] = `"5"`;
@@ -82,8 +80,6 @@ exports[`number > 1211 > float > with min, max and fractionDigits 1`] = `61.0658
exports[`number > 1211 > float > with min, max and multipleOf 1`] = `61.0658`;
-exports[`number > 1211 > float > with min, max and precision 1`] = `61.0658`;
-
exports[`number > 1211 > float > with plain number 1`] = `3.714080615610337`;
exports[`number > 1211 > hex > noArgs 1`] = `"e"`;
@@ -134,8 +130,6 @@ exports[`number > 1337 > float > with min, max and fractionDigits 1`] = `-12.915
exports[`number > 1337 > float > with min, max and multipleOf 1`] = `-12.9153`;
-exports[`number > 1337 > float > with min, max and precision 1`] = `-12.9153`;
-
exports[`number > 1337 > float > with plain number 1`] = `1.0480987000623267`;
exports[`number > 1337 > hex > noArgs 1`] = `"4"`;
diff --git a/test/modules/number.spec.ts b/test/modules/number.spec.ts
index 43d0bc99..475af30d 100644
--- a/test/modules/number.spec.ts
+++ b/test/modules/number.spec.ts
@@ -23,11 +23,6 @@ describe('number', () => {
.it('with min', { min: -42 })
.it('with max', { max: 69 })
.it('with min and max', { min: -42, max: 69 })
- .it('with min, max and precision', {
- min: -42,
- max: 69,
- precision: 0.0001,
- })
.it('with min, max and fractionDigits', {
min: -42,
max: 69,
@@ -238,22 +233,6 @@ describe('number', () => {
}
});
- it('provides numbers with a given precision of 0.5 steps', () => {
- const results = [
- ...new Set(
- Array.from({ length: 50 }, () =>
- faker.number.float({
- min: 0,
- max: 1.5,
- precision: 0.5,
- })
- )
- ),
- ].sort();
-
- expect(results).toEqual([0, 0.5, 1, 1.5]);
- });
-
it('provides numbers with a given multipleOf of 0.5 steps', () => {
const results = [
...new Set(
@@ -270,22 +249,6 @@ describe('number', () => {
expect(results).toEqual([0, 0.5, 1, 1.5]);
});
- it('provides numbers with a given precision of 0.4 steps', () => {
- const results = [
- ...new Set(
- Array.from({ length: 50 }, () =>
- faker.number.float({
- min: 0,
- max: 1.9,
- precision: 0.4,
- })
- )
- ),
- ].sort();
-
- expect(results).toEqual([0, 0.4, 0.8, 1.2, 1.6]);
- });
-
it.each(times(100))(
'provides numbers with an exact fractional digits',
() => {
@@ -325,57 +288,15 @@ describe('number', () => {
);
});
- it('provides numbers with a given precision of 0.2', () => {
- const results = [
- ...new Set(
- Array.from({ length: 50 }, () =>
- faker.number.float({
- min: 0,
- max: 0.4,
- precision: 0.2,
- })
- )
- ),
- ].sort();
-
- expect(results).toEqual([0, 0.2, 0.4]);
- });
-
- it.each(times(18))(
- `provides numbers with an exact precision of 10^-%d`,
- (exponent) => {
- for (let i = 0; i < 100; i++) {
- const actual = faker.number.float({
- min: 0.5,
- max: 0.99,
- precision: 10 ** -exponent,
- });
- expect(actual).toBe(Number(actual.toFixed(exponent)));
- }
- }
- );
-
- it('throws an error for precision 0', () => {
- expect(() => faker.number.float({ precision: 0 })).toThrow(
- new FakerError('multipleOf/precision should be greater than 0.')
- );
- });
-
it('throws an error for multipleOf 0', () => {
expect(() => faker.number.float({ multipleOf: 0 })).toThrow(
- new FakerError('multipleOf/precision should be greater than 0.')
- );
- });
-
- it('throws an error for negative precision', () => {
- expect(() => faker.number.float({ precision: -0.01 })).toThrow(
- new FakerError('multipleOf/precision should be greater than 0.')
+ new FakerError('multipleOf should be greater than 0.')
);
});
it('throws an error for negative multipleOf', () => {
expect(() => faker.number.float({ multipleOf: -0.01 })).toThrow(
- new FakerError('multipleOf/precision should be greater than 0.')
+ new FakerError('multipleOf should be greater than 0.')
);
});