Skip to content

Commit 89851e7

Browse files
committed
test: fixes
1 parent d56e4c7 commit 89851e7

File tree

6 files changed

+17
-18
lines changed

6 files changed

+17
-18
lines changed

src/address.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ export class Address {
407407
latitude(max: number = 90, min: number = -90, precision: number = 4): string {
408408
return this.faker.datatype
409409
.number({
410-
max: max,
411-
min: min,
410+
max,
411+
min,
412412
precision: parseFloat((0.0).toPrecision(precision) + '1'),
413413
})
414414
.toFixed(precision);

src/datatype.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ export class Datatype {
4141
const precision = typeof opts.precision === 'number' ? opts.precision : 1;
4242

4343
if (max < min) {
44-
throw new Error(`Max should be larger then min: ${max} > ${min}`);
45-
}
46-
47-
if (max === min) {
48-
return max;
44+
throw new Error(`Max ${max} should be larger then min ${min}`);
4945
}
5046

5147
// Make the range inclusive of the max value

src/locales/ro/address/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ const address = {
2525
secondary_address,
2626
state,
2727
state_abbr,
28-
streets,
2928
street_address,
3029
street_name,
3130
street_suffix,
31+
streets,
3232
} as Partial<AddressDefinitions>;
3333

3434
export default address;

test/address.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ describe('address', () => {
411411

412412
it('returns latitude with min and max and default precision', () => {
413413
for (let i = 0; i < 100; i++) {
414-
const latitude = faker.address.latitude(-5, 5);
414+
const latitude = faker.address.latitude(5, -5);
415415

416416
expect(latitude).toBeTypeOf('string');
417417
expect(

test/datatype.spec.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ const seededRuns = [
88
number: {
99
noArgs: 37454,
1010
numbers: [2, 5, 6, 1, 5],
11-
withMin: 37427,
11+
withMin: 37412,
1212
withMinAndMax: -1,
1313
withMax: 26,
1414
withMinAndMaxAndPrecision: -0.43,
1515
},
1616
float: {
1717
noArgs: 37453.64,
1818
numbers: [37452, 79656, 95076, 18342, 73200],
19-
withMin: 37427.37,
19+
withMin: 37411.64,
2020
withMinAndMax: -0.43,
2121
withMax: 25.84,
2222
withMinAndMaxAndPrecision: -0.4261,
@@ -80,15 +80,15 @@ const seededRuns = [
8080
number: {
8181
noArgs: 26202,
8282
numbers: [1, 3, 1, 1, 1],
83-
withMin: 26171,
83+
withMin: 26160,
8484
withMinAndMax: -13,
8585
withMax: 18,
8686
withMinAndMaxAndPrecision: -12.92,
8787
},
8888
float: {
8989
noArgs: 26202.2,
9090
numbers: [26202, 56052, 15864, 21258, 27810],
91-
withMin: 26171.21,
91+
withMin: 26160.2,
9292
withMinAndMax: -12.92,
9393
withMax: 18.08,
9494
withMinAndMaxAndPrecision: -12.9153,
@@ -152,15 +152,15 @@ const seededRuns = [
152152
number: {
153153
noArgs: 92852,
154154
numbers: [6, 3, 6, 5, 1],
155-
withMin: 92849,
155+
withMin: 92810,
156156
withMinAndMax: 61,
157157
withMax: 64,
158158
withMinAndMaxAndPrecision: 61.07,
159159
},
160160
float: {
161161
noArgs: 92851.09,
162162
numbers: [92856, 45900, 89346, 77826, 22554],
163-
withMin: 92848.09,
163+
withMin: 92809.09,
164164
withMinAndMax: 61.07,
165165
withMax: 64.07,
166166
withMinAndMaxAndPrecision: 61.0658,
@@ -290,11 +290,14 @@ describe('datatype', () => {
290290
});
291291

292292
it('should throw when min > max', () => {
293+
const min = 10;
294+
const max = 9;
295+
293296
faker.seed(seed);
294297

295298
expect(() => {
296-
faker.datatype.number({ min: 10, max: 9 });
297-
}).toThrowError(`Max should be larger then min: 9 > 10`);
299+
faker.datatype.number({ min, max });
300+
}).toThrowError(`Max ${max} should be larger then min ${min}`);
298301
});
299302
});
300303

test/system.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const seededRuns = [
3838
seed: 1211,
3939
expectations: {
4040
fileName: 'turnpike_frozen_handcrafted.mka',
41-
commonFileName: 'turnpike_frozen_handcrafted.mka',
41+
commonFileName: 'turnpike_frozen_handcrafted.mp4v',
4242
mimeType: 'text/vnd.fmi.flexstor',
4343
commonFileType: 'application',
4444
commonFileExt: 'htm',

0 commit comments

Comments
 (0)