Skip to content

Commit

Permalink
feat: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Apr 7, 2022
1 parent 15a9b6a commit 8f04b48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/datatype.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Faker } from '.';
import { FakerError } from './errors/faker-error';
import { deprecated } from './internal/deprecated';

/**
Expand Down Expand Up @@ -290,7 +291,7 @@ export class Datatype {
* @param options.min Lower bound for generated bigint. Defaults to `0n`.
* @param options.max Upper bound for generated bigint. Defaults to `min + 999999999999999n`.
*
* @throws When options define `max < min`
* @throws When options define `max < min`.
*
* @example
* faker.datatype.bigInt() // 55422n
Expand Down Expand Up @@ -326,9 +327,10 @@ export class Datatype {
}

if (max < min) {
throw new Error(`Max ${max} should be larger then min ${min}`);
throw new FakerError(`Max ${max} should be larger then min ${min}.`);
}

// TODO @Shinigami92 2022-04-07: Use faker.random.numeric() from https://github.com/faker-js/faker/pull/797
const generateRandomBigInt = (length: number) =>
BigInt(
Array.from(
Expand Down
6 changes: 4 additions & 2 deletions test/datatype.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it, vi } from 'vitest';
import { faker } from '../src';
import { faker, FakerError } from '../src';

const seededRuns = [
{
Expand Down Expand Up @@ -426,7 +426,9 @@ describe('datatype', () => {

expect(() => {
faker.datatype.bigInt({ min, max });
}).toThrowError(`Max ${max} should be larger then min ${min}`);
}).toThrowError(
new FakerError(`Max ${max} should be larger then min ${min}.`)
);
});
});
});
Expand Down

0 comments on commit 8f04b48

Please sign in to comment.