Skip to content

Commit

Permalink
chore: upgrade faker
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Nov 6, 2023
1 parent 00c3562 commit c9457e9
Show file tree
Hide file tree
Showing 20 changed files with 98 additions and 100 deletions.
12 changes: 5 additions & 7 deletions packages/n4s/src/rules/__tests__/equals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import { sample } from 'lodash';

import { equals } from 'equals';

const { random, datatype } = faker;

const VALUES = [
random.word(),
datatype.number(),
{ [random.alpha()]: random.word() },
[datatype.number()],
datatype.boolean(),
faker.lorem.word(),
faker.number.int(),
{ [faker.lorem.slug()]: faker.lorem.word() },
[faker.number.int()],
faker.datatype.boolean(),
];

const LOOSE_PAIRS = [
Expand Down
18 changes: 9 additions & 9 deletions packages/n4s/src/rules/__tests__/greaterThanOrEquals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { faker } from '@faker-js/faker';

import { greaterThanOrEquals } from 'greaterThanOrEquals';

const { random, datatype } = faker;

describe('Tests greaterThanOrEquals rule', () => {
describe('Arguments are numbers', () => {
let arg0: number;
beforeEach(() => {
arg0 = datatype.number();
arg0 = faker.number.int();
});

describe('When first argument is larger', () => {
Expand Down Expand Up @@ -51,11 +49,13 @@ describe('Tests greaterThanOrEquals rule', () => {
});

describe('Arguments are non numeric', () => {
[random.word(), `${datatype.number()}`.split(''), {}].forEach(element => {
it('Should return false', () => {
// @ts-expect-error - Testing invalid input
expect(greaterThanOrEquals(element, 0)).toBe(false);
});
});
[faker.lorem.word(), `${faker.number.int()}`.split(''), {}].forEach(
element => {
it('Should return false', () => {
// @ts-expect-error - Testing invalid input
expect(greaterThanOrEquals(element, 0)).toBe(false);
});
}
);
});
});
2 changes: 1 addition & 1 deletion packages/n4s/src/rules/__tests__/isEven.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Tests isEven rule', () => {
describe('When value is non numeric', () => {
it('Should return false', () => {
[
faker.random.word(),
faker.lorem.word(),
[],
new Function(),
new Object(),
Expand Down
2 changes: 1 addition & 1 deletion packages/n4s/src/rules/__tests__/isOdd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Tests isOdd rule', () => {
describe('When value is non numeric', () => {
it('Should return false', () => {
[
faker.random.word(),
faker.lorem.word(),
[],
new Function(),
new Object(),
Expand Down
20 changes: 10 additions & 10 deletions packages/n4s/src/rules/__tests__/lessThan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { faker } from '@faker-js/faker';

import { lessThan } from 'lessThan';

const { random, datatype } = faker;

describe('Tests lessThan rule', () => {
describe('Arguments are numbers', () => {
let arg0: number = 0;
beforeEach(() => {
arg0 = datatype.number();
arg0 = faker.number.int();
});

describe('When first argument is larger', () => {
Expand All @@ -33,7 +31,7 @@ describe('Tests lessThan rule', () => {
describe('Arguments are numeric strings', () => {
let arg0: string = '0';
beforeEach(() => {
arg0 = datatype.number().toString();
arg0 = faker.number.int().toString();
});
describe('When first argument is larger', () => {
it('Should return true', () => {
Expand All @@ -55,11 +53,13 @@ describe('Tests lessThan rule', () => {
});

describe('Arguments are non numeric', () => {
[random.word(), `${datatype.number()}`.split(''), {}].forEach(element => {
it('Should return false', () => {
// @ts-expect-error - Testing invalid input
expect(lessThan(element, 0)).toBe(false);
});
});
[faker.lorem.word(), `${faker.number.int()}`.split(''), {}].forEach(
element => {
it('Should return false', () => {
// @ts-expect-error - Testing invalid input
expect(lessThan(element, 0)).toBe(false);
});
}
);
});
});
20 changes: 10 additions & 10 deletions packages/n4s/src/rules/__tests__/lessThanOrEquals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { faker } from '@faker-js/faker';

import { lessThanOrEquals } from 'lessThanOrEquals';

const { random, datatype } = faker;

describe('Tests lessThanOrEquals rule', () => {
describe('Arguments are numbers', () => {
let arg0: number;
beforeEach(() => {
arg0 = datatype.number();
arg0 = faker.number.int();
});

describe('When first argument is larger', () => {
Expand All @@ -33,7 +31,7 @@ describe('Tests lessThanOrEquals rule', () => {
describe('Arguments are numeric strings', () => {
let arg0: string;
beforeEach(() => {
arg0 = datatype.number().toString();
arg0 = faker.number.int().toString();
});
describe('When first argument is larger', () => {
it('Should return true', () => {
Expand All @@ -55,11 +53,13 @@ describe('Tests lessThanOrEquals rule', () => {
});

describe('Arguments are non numeric', () => {
[random.word(), `${datatype.number()}`.split(''), {}].forEach(element => {
it('Should return false', () => {
// @ts-expect-error - Testing invalid input
expect(lessThanOrEquals(element, 0)).toBe(false);
});
});
[faker.lorem.word(), `${faker.number.int()}`.split(''), {}].forEach(
element => {
it('Should return false', () => {
// @ts-expect-error - Testing invalid input
expect(lessThanOrEquals(element, 0)).toBe(false);
});
}
);
});
});
4 changes: 2 additions & 2 deletions packages/n4s/src/rules/__tests__/longerThanOrEquals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { faker } from '@faker-js/faker';
import { longerThanOrEquals } from 'longerThanOrEquals';

describe('Tests longerThanOrEquals rule', () => {
const length = faker.datatype.number();
const word = faker.random.word();
const length = 10;
const word = faker.lorem.word();
const boolean = faker.datatype.boolean();

describe('First argument is array or string', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/n4s/src/rules/__tests__/shorterThan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { faker } from '@faker-js/faker';
import { shorterThan } from 'shorterThan';

describe('Tests shorterThan rule', () => {
const length = faker.datatype.number();
const word = faker.random.word();
const length = 10;
const word = faker.lorem.word();
const boolean = faker.datatype.boolean();

describe('First argument is array or string', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/n4s/src/rules/__tests__/shorterThanOrEquals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { faker } from '@faker-js/faker';
import { shorterThanOrEquals } from 'shorterThanOrEquals';

describe('Tests shorterThanOrEquals rule', () => {
const length = faker.datatype.number();
const word = faker.random.word();
const length = 10;
const word = faker.lorem.word();
const boolean = faker.datatype.boolean();

describe('First argument is array or string', () => {
Expand Down
20 changes: 10 additions & 10 deletions packages/vest-utils/src/__tests__/greaterThan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import { faker } from '@faker-js/faker';

import { greaterThan } from 'greaterThan';

const { random, datatype } = faker;

describe('Tests greaterThan rule', () => {
describe('Arguments are numbers', () => {
let arg0: number;

beforeEach(() => {
arg0 = datatype.number();
arg0 = faker.number.int();
});

describe('When first argument is larger', () => {
Expand All @@ -35,7 +33,7 @@ describe('Tests greaterThan rule', () => {
let arg0: string;

beforeEach(() => {
arg0 = datatype.number().toString();
arg0 = faker.number.int().toString();
});

describe('When first argument is larger', () => {
Expand All @@ -58,11 +56,13 @@ describe('Tests greaterThan rule', () => {
});

describe('Arguments are non numeric', () => {
[random.word(), `${datatype.number()}`.split(''), {}].forEach(element => {
it('Should return false', () => {
// @ts-expect-error - testing invalid input
expect(greaterThan(element, 0)).toBe(false);
});
});
[faker.lorem.word(), `${faker.number.int()}`.split(''), {}].forEach(
element => {
it('Should return false', () => {
// @ts-expect-error - testing invalid input
expect(greaterThan(element, 0)).toBe(false);
});
}
);
});
});
4 changes: 2 additions & 2 deletions packages/vest-utils/src/__tests__/lengthEquals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { faker } from '@faker-js/faker';
import { lengthEquals } from 'lengthEquals';

describe('Tests lengthEquals rule', () => {
const length = faker.datatype.number();
const word = faker.random.word();
const length = 10;
const word = faker.lorem.word();
const boolean = faker.datatype.boolean();

describe('First argument is array or string', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/vest-utils/src/__tests__/longerThan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { faker } from '@faker-js/faker';
import { longerThan } from 'longerThan';

describe('Tests longerThan rule', () => {
const length = faker.datatype.number();
const word = faker.random.word();
const length = 10;
const word = faker.lorem.word();
const boolean = faker.datatype.boolean();

describe('First argument is array or string', () => {
Expand Down
20 changes: 10 additions & 10 deletions packages/vest-utils/src/__tests__/numberEquals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { faker } from '@faker-js/faker';

import { numberEquals } from 'numberEquals';

const { random, datatype } = faker;

describe('Tests numberEquals rule', () => {
describe('Arguments are numbers', () => {
let arg0: number;
beforeEach(() => {
arg0 = datatype.number();
arg0 = faker.number.int();
});

describe('When first argument is larger', () => {
Expand All @@ -34,7 +32,7 @@ describe('Tests numberEquals rule', () => {
let arg0: string;

beforeEach(() => {
arg0 = datatype.number().toString();
arg0 = faker.number.int().toString();
});

describe('When first argument is larger', () => {
Expand All @@ -57,11 +55,13 @@ describe('Tests numberEquals rule', () => {
});

describe('Arguments are non numeric', () => {
[random.word(), `${datatype.number()}`.split(''), {}].forEach(element => {
it('Should return false', () => {
// @ts-expect-error - testing invalid input
expect(numberEquals(element, 0)).toBe(false);
});
});
[faker.lorem.word(), `${faker.number.int()}`.split(''), {}].forEach(
element => {
it('Should return false', () => {
// @ts-expect-error - testing invalid input
expect(numberEquals(element, 0)).toBe(false);
});
}
);
});
});
8 changes: 4 additions & 4 deletions packages/vest/src/core/test/__tests__/test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("Test Vest's `test` function", () => {
it('Should be marked as warning when the warn hook gets called', () => {
vest.create(() => {
testObject = vest.test(
faker.random.word(),
faker.lorem.word(),
faker.lorem.sentence(),
() => {
vest.warn();
Expand All @@ -33,7 +33,7 @@ describe("Test Vest's `test` function", () => {
it('Should be marked as failed after a thrown error', () => {
vest.create(() => {
testObject = vest.test(
faker.random.word(),
faker.lorem.word(),
faker.lorem.sentence(),
() => {
throw new Error();
Expand All @@ -45,7 +45,7 @@ describe("Test Vest's `test` function", () => {

it('Should be marked as failed for an explicit false return', () => {
vest.create(() => {
vest.test(faker.random.word(), faker.lorem.sentence(), () => false);
vest.test(faker.lorem.word(), faker.lorem.sentence(), () => false);
})();
expect(VestTest.isFailing(testObject)).toBe(true);
});
Expand Down Expand Up @@ -126,7 +126,7 @@ describe("Test Vest's `test` function", () => {
TestPromise(done => {
vest.create(() => {
testObject = vest.test(
faker.random.word(),
faker.lorem.word(),
faker.lorem.sentence(),
() =>
new Promise((_, reject) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/vest/src/exports/__tests__/promisify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ describe('Utility: promisify', () => {
it('Passes all arguments over to tests callback', async () => {
const params = [
1,
{ [faker.random.word()]: [1, 2, 3] },
{ [faker.lorem.word()]: [1, 2, 3] },
false,
[faker.random.word()],
[faker.lorem.word()],
];

await validateAsync(...params);
Expand Down
6 changes: 3 additions & 3 deletions packages/vest/src/suite/__tests__/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Test createSuite module', () => {
expect(create(jest.fn()).get()).toMatchSnapshot();
});

it.each([faker.random.word(), null, undefined, 0, 1, true, false, NaN, ''])(
it.each([faker.lorem.word(), null, undefined, 0, 1, true, false, NaN, ''])(
'Throws an error when `tests` callback is not a function',
value => {
// @ts-expect-error - testing invalid input
Expand Down Expand Up @@ -57,9 +57,9 @@ describe('Test createSuite module', () => {
1,
2,
3,
{ [faker.random.word()]: [1, 2, 3] },
{ [faker.lorem.word()]: [1, 2, 3] },
false,
[faker.random.word()],
[faker.lorem.word()],
];
const validate = create(testsCallback);
validate(...params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { dummyTest } from '../../../testUtils/testDummy';
import * as vest from 'vest';

describe('produce method: hasFailures', () => {
const fieldName = faker.random.word();
const fieldName = faker.lorem.word();

describe(`hasErrors`, () => {
describe('When no test objects', () => {
Expand Down
Loading

2 comments on commit c9457e9

@vercel
Copy link

@vercel vercel bot commented on c9457e9 Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vest-next – ./website

vest-next.vercel.app
vest-website.vercel.app
vest-next-ealush.vercel.app
vest-next-git-latest-ealush.vercel.app

@vercel
Copy link

@vercel vercel bot commented on c9457e9 Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vest – ./website

vest-ealush.vercel.app
vest.vercel.app
www.vestjs.dev
vestjs.dev
vest-git-latest-ealush.vercel.app

Please sign in to comment.