Skip to content

Commit 8f04b48

Browse files
committed
feat: update test
1 parent 15a9b6a commit 8f04b48

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/datatype.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Faker } from '.';
2+
import { FakerError } from './errors/faker-error';
23
import { deprecated } from './internal/deprecated';
34

45
/**
@@ -290,7 +291,7 @@ export class Datatype {
290291
* @param options.min Lower bound for generated bigint. Defaults to `0n`.
291292
* @param options.max Upper bound for generated bigint. Defaults to `min + 999999999999999n`.
292293
*
293-
* @throws When options define `max < min`
294+
* @throws When options define `max < min`.
294295
*
295296
* @example
296297
* faker.datatype.bigInt() // 55422n
@@ -326,9 +327,10 @@ export class Datatype {
326327
}
327328

328329
if (max < min) {
329-
throw new Error(`Max ${max} should be larger then min ${min}`);
330+
throw new FakerError(`Max ${max} should be larger then min ${min}.`);
330331
}
331332

333+
// TODO @Shinigami92 2022-04-07: Use faker.random.numeric() from https://github.com/faker-js/faker/pull/797
332334
const generateRandomBigInt = (length: number) =>
333335
BigInt(
334336
Array.from(

test/datatype.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it, vi } from 'vitest';
2-
import { faker } from '../src';
2+
import { faker, FakerError } from '../src';
33

44
const seededRuns = [
55
{
@@ -426,7 +426,9 @@ describe('datatype', () => {
426426

427427
expect(() => {
428428
faker.datatype.bigInt({ min, max });
429-
}).toThrowError(`Max ${max} should be larger then min ${min}`);
429+
}).toThrowError(
430+
new FakerError(`Max ${max} should be larger then min ${min}.`)
431+
);
430432
});
431433
});
432434
});

0 commit comments

Comments
 (0)