From e7fc782b1c3ae4f9cb18b08d8bf734e0c2e18462 Mon Sep 17 00:00:00 2001 From: Nathan Vasse Date: Fri, 12 May 2023 14:35:59 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(react)=20migrate=20faker=20a?= =?UTF-8?q?pi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit faker-js introduced breaking changes in their APIs, so we needed to migrate our usages. --- .../src/components/DataGrid/DataList.spec.tsx | 4 +- .../DataGrid/SimpleDataGrid.spec.tsx | 40 +++++++++---------- .../src/components/DataGrid/index.spec.tsx | 24 +++++------ .../src/components/DataGrid/index.stories.tsx | 18 ++++----- .../components/Forms/Select/mono.stories.tsx | 2 +- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/packages/react/src/components/DataGrid/DataList.spec.tsx b/packages/react/src/components/DataGrid/DataList.spec.tsx index ef59a41..4ba5e2d 100644 --- a/packages/react/src/components/DataGrid/DataList.spec.tsx +++ b/packages/react/src/components/DataGrid/DataList.spec.tsx @@ -10,8 +10,8 @@ describe("", () => { it("should render a DataList", async () => { const rows = Array.from(Array(3)).map((_value, index) => ({ id: `list key for element ${index}`, - firstName: faker.name.firstName(), - lastName: faker.name.lastName(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), })); render( diff --git a/packages/react/src/components/DataGrid/SimpleDataGrid.spec.tsx b/packages/react/src/components/DataGrid/SimpleDataGrid.spec.tsx index 0cb35c3..45959a7 100644 --- a/packages/react/src/components/DataGrid/SimpleDataGrid.spec.tsx +++ b/packages/react/src/components/DataGrid/SimpleDataGrid.spec.tsx @@ -13,11 +13,11 @@ import { Row } from ":/components/DataGrid/index"; describe("", () => { it("should render a grid without pagination", async () => { const rows = Array.from(Array(23)).map(() => ({ - id: faker.datatype.uuid(), - firstName: faker.name.firstName(), - lastName: faker.name.lastName(), + id: faker.string.uuid(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), email: faker.internet.email(), - address: faker.address.streetAddress(), + address: faker.location.streetAddress(), })); render( @@ -67,11 +67,11 @@ describe("", () => { it("should render a grid with working pagination", async () => { const rows = Array.from(Array(23)) .map(() => ({ - id: faker.datatype.uuid(), - firstName: faker.name.firstName(), - lastName: faker.name.lastName(), + id: faker.string.uuid(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), email: faker.internet.email(), - address: faker.address.streetAddress(), + address: faker.location.streetAddress(), })) .sort((a, b) => a.firstName.localeCompare(b.firstName)); render( @@ -187,11 +187,11 @@ describe("", () => { it("should render a grid with working rows selection", async () => { const rows = Array.from(Array(23)) .map(() => ({ - id: faker.datatype.uuid(), - firstName: faker.name.firstName(), - lastName: faker.name.lastName(), + id: faker.string.uuid(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), email: faker.internet.email(), - address: faker.address.streetAddress(), + address: faker.location.streetAddress(), })) .sort((a, b) => a.firstName.localeCompare(b.firstName)); @@ -270,11 +270,11 @@ describe("", () => { it("should render a grid with working sortable columns", async () => { const rows = Array.from(Array(23)) .map(() => ({ - id: faker.datatype.uuid(), - firstName: faker.name.firstName(), - lastName: faker.name.lastName(), + id: faker.string.uuid(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), email: faker.internet.email(), - address: faker.address.streetAddress(), + address: faker.location.streetAddress(), })) .sort((a, b) => a.firstName.localeCompare(b.firstName)); render( @@ -421,11 +421,11 @@ describe("", () => { it("should render a grid with non-sortable columns", async () => { const rows = Array.from(Array(23)) .map(() => ({ - id: faker.datatype.uuid(), - firstName: faker.name.firstName(), - lastName: faker.name.lastName(), + id: faker.string.uuid(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), email: faker.internet.email(), - address: faker.address.streetAddress(), + address: faker.location.streetAddress(), })) .sort((a, b) => a.firstName.localeCompare(b.firstName)); render( diff --git a/packages/react/src/components/DataGrid/index.spec.tsx b/packages/react/src/components/DataGrid/index.spec.tsx index 802f190..50e8e12 100644 --- a/packages/react/src/components/DataGrid/index.spec.tsx +++ b/packages/react/src/components/DataGrid/index.spec.tsx @@ -15,11 +15,11 @@ describe("", () => { it("should render a grid with server-side loading", async () => { const database = Array.from(Array(23)).map(() => ({ - id: faker.datatype.uuid(), - firstName: faker.name.firstName(), - lastName: faker.name.lastName(), + id: faker.string.uuid(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), email: faker.internet.email(), - address: faker.address.streetAddress(), + address: faker.location.streetAddress(), })); const Component = () => { @@ -216,11 +216,11 @@ describe("", () => { }); it("should render custom cells", async () => { const database = Array.from(Array(10)).map(() => ({ - id: faker.datatype.uuid(), - firstName: faker.name.firstName(), - lastName: faker.name.lastName(), + id: faker.string.uuid(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), email: faker.internet.email(), - address: faker.address.streetAddress(), + address: faker.location.streetAddress(), })); const Component = () => { @@ -263,11 +263,11 @@ describe("", () => { }); it("should render highlighted column", async () => { const database = Array.from(Array(10)).map(() => ({ - id: faker.datatype.uuid(), - firstName: faker.name.firstName(), - lastName: faker.name.lastName(), + id: faker.string.uuid(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), email: faker.internet.email(), - address: faker.address.streetAddress(), + address: faker.location.streetAddress(), })); const Component = () => { diff --git a/packages/react/src/components/DataGrid/index.stories.tsx b/packages/react/src/components/DataGrid/index.stories.tsx index 13487f2..5ae6f16 100644 --- a/packages/react/src/components/DataGrid/index.stories.tsx +++ b/packages/react/src/components/DataGrid/index.stories.tsx @@ -52,11 +52,11 @@ export const ClientSideWithoutPagination = () => { const database = useMemo( () => Array.from(Array(23)).map(() => ({ - id: faker.datatype.uuid(), - firstName: faker.name.firstName(), - lastName: faker.name.lastName(), + id: faker.string.uuid(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), email: faker.internet.email(), - address: faker.address.streetAddress(), + address: faker.location.streetAddress(), })), [] ); @@ -104,7 +104,7 @@ export const ClientSideWithPagination = () => { const database = useMemo( () => Array.from(Array(23)).map(() => ({ - id: faker.datatype.uuid(), + id: faker.string.uuid(), carName: faker.company.name(), year: faker.date.past().getFullYear(), price: +faker.commerce.price(5000, 5005), @@ -156,11 +156,11 @@ export const FullServerSide = () => { const database = useMemo( () => Array.from(Array(191)).map(() => ({ - id: faker.datatype.uuid(), - firstName: faker.name.firstName(), - lastName: faker.name.lastName(), + id: faker.string.uuid(), + firstName: faker.person.firstName(), + lastName: faker.person.lastName(), email: faker.internet.email(), - address: faker.address.streetAddress(), + address: faker.location.streetAddress(), })), [] ); diff --git a/packages/react/src/components/Forms/Select/mono.stories.tsx b/packages/react/src/components/Forms/Select/mono.stories.tsx index 746eb0f..b7f13b5 100644 --- a/packages/react/src/components/Forms/Select/mono.stories.tsx +++ b/packages/react/src/components/Forms/Select/mono.stories.tsx @@ -18,7 +18,7 @@ const Template: ComponentStory = (args) => ( ); -const CITIES = Array.from({ length: 10 }).map(() => faker.address.city()); +const CITIES = Array.from({ length: 10 }).map(() => faker.location.city()); const OPTIONS = CITIES.map((city) => ({ label: city, value: city.toLowerCase(),