Skip to content

Commit

Permalink
feat(faker): update deprecated methods (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMierzwa authored Oct 30, 2023
1 parent c19e35c commit c357c13
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 61 deletions.
10 changes: 5 additions & 5 deletions docs/src/pages/reference/configuration/full-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ module.exports = {
mock: {
properties: () => {
return {
id: () => faker.datatype.number({ min: 1, max: 99999 }),
id: () => faker.number.int({ min: 1, max: 99999 }),
};
},
},
},
showPetById: {
mock: {
data: () => ({
id: faker.datatype.number({ min: 1, max: 99 }),
name: faker.name.firstName(),
id: faker.number.int({ min: 1, max: 99 }),
name: faker.person.firstName(),
tag: faker.helpers.arrayElement([
faker.random.word(),
faker.word.sample(),
undefined,
]),
}),
Expand All @@ -41,7 +41,7 @@ module.exports = {
},
mock: {
properties: {
'/tag|name/': () => faker.name.lastName(),
'/tag|name/': () => faker.person.lastName(),
},
delay: 500,
},
Expand Down
8 changes: 4 additions & 4 deletions docs/src/pages/reference/configuration/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -888,18 +888,18 @@ module.exports = {
mock: {
properties: () => {
return {
id: () => faker.datatype.number({ min: 1, max: 99999 }),
id: () => faker.number.int({ min: 1, max: 99999 }),
};
},
},
},
showPetById: {
mock: {
data: () => ({
id: faker.datatype.number({ min: 1, max: 99 }),
name: faker.name.firstName(),
id: faker.number.int({ min: 1, max: 99 }),
name: faker.person.firstName(),
tag: faker.helpers.arrayElement([
faker.random.word(),
faker.word.sample(),
undefined,
]),
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/msw/src/getters/scalar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export const getMockScalar = ({

return {
value:
`Array.from({ length: faker.datatype.number({ ` +
`Array.from({ length: faker.number.int({ ` +
`min: ${mockOptions?.arrayMin}, ` +
`max: ${mockOptions?.arrayMax} }) ` +
`}, (_, i) => i + 1).map(() => (${mapValue}))`,
Expand Down
10 changes: 5 additions & 5 deletions samples/angular-app/orval.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ export default defineConfig({
mock: {
properties: () => {
return {
id: () => faker.datatype.number({ min: 1, max: 99999 }),
id: () => faker.number.int({ min: 1, max: 99999 }),
};
},
},
},
showPetById: {
mock: {
data: () => ({
id: faker.datatype.number({ min: 1, max: 99 }),
name: faker.name.firstName(),
id: faker.number.int({ min: 1, max: 99 }),
name: faker.person.firstName(),
tag: faker.helpers.arrayElement([
faker.random.word(),
faker.word.sample(),
undefined,
]),
}),
Expand All @@ -38,7 +38,7 @@ export default defineConfig({
},
mock: {
properties: {
'/tag|name/': () => faker.name.lastName(),
'/tag|name/': () => faker.person.lastName(),
},
},
},
Expand Down
12 changes: 6 additions & 6 deletions samples/angular-app/src/api/endpoints/pets/pets.msw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import { rest } from 'msw';

export const getListPetsMock = () =>
Array.from(
{ length: faker.datatype.number({ min: 1, max: 10 }) },
{ length: faker.number.int({ min: 1, max: 10 }) },
(_, i) => i + 1,
).map(() => ({
id: faker.number.int({ min: undefined, max: undefined }),
name: (() => faker.name.lastName())(),
tag: (() => faker.name.lastName())(),
name: (() => faker.person.lastName())(),
tag: (() => faker.person.lastName())(),
}));

export const getShowPetByIdMock = () =>
(() => ({
id: faker.datatype.number({ min: 1, max: 99 }),
name: faker.name.firstName(),
tag: faker.helpers.arrayElement([faker.random.word(), void 0]),
id: faker.number.int({ min: 1, max: 99 }),
name: faker.person.firstName(),
tag: faker.helpers.arrayElement([faker.word.sample(), void 0]),
}))();

export const getPetsMSW = () => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export type ShowPetByIdResult = AxiosResponse<Pet>;

export const getListPetsMock = () =>
Array.from(
{ length: faker.datatype.number({ min: 1, max: 10 }) },
{ length: faker.number.int({ min: 1, max: 10 }) },
(_, i) => i + 1,
).map(() => ({
id: faker.number.int({ min: undefined, max: undefined }),
Expand All @@ -64,9 +64,9 @@ export const getListPetsMock = () =>

export const getShowPetByIdMock = () =>
(() => ({
id: faker.datatype.number({ min: 1, max: 99 }),
name: faker.name.firstName(),
tag: faker.helpers.arrayElement([faker.random.word(), void 0]),
id: faker.number.int({ min: 1, max: 99 }),
name: faker.person.firstName(),
tag: faker.helpers.arrayElement([faker.word.sample(), void 0]),
}))();

export const getSwaggerPetstoreMSW = () => [
Expand Down
8 changes: 4 additions & 4 deletions samples/basic/orval.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ export default defineConfig({
mock: {
properties: () => {
return {
id: faker.datatype.number({ min: 1, max: 9 }),
id: faker.number.int({ min: 1, max: 9 }),
};
},
},
},
showPetById: {
mock: {
data: () => ({
id: faker.datatype.number({ min: 1, max: 99 }),
name: faker.name.firstName(),
id: faker.number.int({ min: 1, max: 99 }),
name: faker.person.firstName(),
tag: faker.helpers.arrayElement([
faker.random.word(),
faker.word.sample(),
undefined,
]),
}),
Expand Down
8 changes: 4 additions & 4 deletions samples/nx-fastify-react/apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ app.ready(async () => {
});

export const getGetPetsMock = () =>
[...Array(faker.datatype.number({ min: 1, max: 10 }))].map(() => ({
id: faker.datatype.number(),
name: faker.random.word(),
tag: faker.random.word(),
[...Array(faker.number.int({ min: 1, max: 10 }))].map(() => ({
id: faker.number.int(),
name: faker.word.sample(),
tag: faker.word.sample(),
}));

app.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { rest } from 'msw';

export const getListPetsMock = () =>
Array.from(
{ length: faker.datatype.number({ min: 1, max: 10 }) },
{ length: faker.number.int({ min: 1, max: 10 }) },
(_, i) => i + 1,
).map(() => ({
'@id': faker.helpers.arrayElement([faker.word.sample(), undefined]),
Expand Down
10 changes: 5 additions & 5 deletions samples/react-app/orval.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ export default defineConfig({
mock: {
properties: () => {
return {
'[].id': () => faker.datatype.number({ min: 1, max: 99999 }),
'[].id': () => faker.number.int({ min: 1, max: 99999 }),
};
},
},
},
showPetById: {
mock: {
data: () => ({
id: faker.datatype.number({ min: 1, max: 99 }),
name: faker.name.firstName(),
id: faker.number.int({ min: 1, max: 99 }),
name: faker.person.firstName(),
tag: faker.helpers.arrayElement([
faker.random.word(),
faker.word.sample(),
undefined,
]),
}),
Expand All @@ -39,7 +39,7 @@ export default defineConfig({
},
mock: {
properties: {
'/tag|name/': () => faker.name.lastName(),
'/tag|name/': () => faker.person.lastName(),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import { rest } from 'msw';

export const getListPetsMock = () =>
Array.from(
{ length: faker.datatype.number({ min: 1, max: 10 }) },
{ length: faker.number.int({ min: 1, max: 10 }) },
(_, i) => i + 1,
).map(() => ({
id: (() => faker.datatype.number({ min: 1, max: 99999 }))(),
name: (() => faker.name.lastName())(),
tag: (() => faker.name.lastName())(),
id: (() => faker.number.int({ min: 1, max: 99999 }))(),
name: (() => faker.person.lastName())(),
tag: (() => faker.person.lastName())(),
}));

export const getShowPetByIdMock = () =>
(() => ({
id: faker.datatype.number({ min: 1, max: 99 }),
name: faker.name.firstName(),
tag: faker.helpers.arrayElement([faker.random.word(), void 0]),
id: faker.number.int({ min: 1, max: 99 }),
name: faker.person.firstName(),
tag: faker.helpers.arrayElement([faker.word.sample(), void 0]),
}))();

export const getSwaggerPetstoreMSW = () => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { rest } from 'msw';

export const getListPetsMock = () =>
Array.from(
{ length: faker.datatype.number({ min: 1, max: 10 }) },
{ length: faker.number.int({ min: 1, max: 10 }) },
(_, i) => i + 1,
).map(() =>
faker.helpers.arrayElement([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { rest } from 'msw';

export const getListPetsMock = () =>
Array.from(
{ length: faker.datatype.number({ min: 1, max: 10 }) },
{ length: faker.number.int({ min: 1, max: 10 }) },
(_, i) => i + 1,
).map(() => ({
'@id': faker.helpers.arrayElement([faker.word.sample(), undefined]),
Expand Down
10 changes: 5 additions & 5 deletions samples/svelte-query/orval.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ export default defineConfig({
mock: {
properties: () => {
return {
'[].id': () => faker.datatype.number({ min: 1, max: 99999 }),
'[].id': () => faker.number.int({ min: 1, max: 99999 }),
};
},
},
},
showPetById: {
mock: {
data: () => ({
id: faker.datatype.number({ min: 1, max: 99 }),
name: faker.name.firstName(),
id: faker.number.int({ min: 1, max: 99 }),
name: faker.person.firstName(),
tag: faker.helpers.arrayElement([
faker.datatype.string(),
faker.string.sample(),
undefined,
]),
}),
Expand All @@ -40,7 +40,7 @@ export default defineConfig({
},
mock: {
properties: {
'/tag|name/': () => faker.name.lastName(),
'/tag|name/': () => faker.person.lastName(),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import { rest } from 'msw';

export const getListPetsMock = () =>
Array.from(
{ length: faker.datatype.number({ min: 1, max: 10 }) },
{ length: faker.number.int({ min: 1, max: 10 }) },
(_, i) => i + 1,
).map(() => ({
id: (() => faker.datatype.number({ min: 1, max: 99999 }))(),
name: (() => faker.name.lastName())(),
tag: (() => faker.name.lastName())(),
id: (() => faker.number.int({ min: 1, max: 99999 }))(),
name: (() => faker.person.lastName())(),
tag: (() => faker.person.lastName())(),
}));

export const getShowPetByIdMock = () =>
(() => ({
id: faker.datatype.number({ min: 1, max: 99 }),
name: faker.name.firstName(),
tag: faker.helpers.arrayElement([faker.datatype.string(), void 0]),
id: faker.number.int({ min: 1, max: 99 }),
name: faker.person.firstName(),
tag: faker.helpers.arrayElement([faker.string.sample(), void 0]),
}))();

export const getSwaggerPetstoreMSW = () => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { rest } from 'msw';

export const getListPetsMock = () =>
Array.from(
{ length: faker.datatype.number({ min: 1, max: 10 }) },
{ length: faker.number.int({ min: 1, max: 10 }) },
(_, i) => i + 1,
).map(() => ({
email: faker.helpers.arrayElement([faker.internet.email(), undefined]),
Expand Down

0 comments on commit c357c13

Please sign in to comment.