Skip to content

Commit

Permalink
randexp as faker regexGenerator
Browse files Browse the repository at this point in the history
Update kubb to version that supports randexp option
Configure to use randexp
Update tests to leverage randexp

closes #42
  • Loading branch information
TangoYankee committed Jul 15, 2024
1 parent 45ebcc1 commit fdd56b8
Show file tree
Hide file tree
Showing 54 changed files with 3,082 additions and 1,590 deletions.
7 changes: 1 addition & 6 deletions app/components/AdminDropdown/BoroughDropdown.test.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { Borough, createBorough } from "~/gen";
import RandExp from "randexp";
import { BoroughDropdown } from "./BoroughDropdown";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";

describe("BoroughDropdown", () => {
let boroughs: Array<Borough> = [];
beforeAll(() => {
boroughs = Array.from(Array(1), () =>
createBorough({
id: new RandExp("^([0-9])$").gen(),
}),
);
boroughs = Array.from(Array(1), () => createBorough());
});

it("should render borough form details and options", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render, screen } from "@testing-library/react";
import RandExp from "randexp";
import { CityCouncilDistrict, createCityCouncilDistrict } from "~/gen";
import { CityCouncilDistrictDropdown } from "./CityCouncilDistrictDropdown";
import userEvent from "@testing-library/user-event";
Expand All @@ -9,9 +8,7 @@ describe("CityCouncilDistrictDropdown", () => {

beforeAll(() => {
cityCouncilDistricts = Array.from(Array(1), () =>
createCityCouncilDistrict({
id: new RandExp("^([0-9]{1,2})$").gen(),
}),
createCityCouncilDistrict(),
);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { render, screen } from "@testing-library/react";
import { CommunityDistrictDropdown } from "./CommunityDistrictDropdown";
import { CommunityDistrict, createCommunityDistrict } from "~/gen";
import RandExp from "randexp";
import userEvent from "@testing-library/user-event";

describe("CommunityDistrictDropdown", () => {
Expand All @@ -10,7 +9,6 @@ describe("CommunityDistrictDropdown", () => {
beforeAll(() => {
communityDistricts = Array.from(Array(1), () =>
createCommunityDistrict({
id: new RandExp("^([0-9]{2})$").gen(),
boroughId,
}),
);
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createAgency.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import type { Agency } from "../types/Agency";

export function createAgency(
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createBadRequest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createError } from "./createError";
import RandExp from "randexp";
import type { BadRequest } from "../types/BadRequest";

export function createBadRequest(): NonNullable<BadRequest> {
Expand Down
3 changes: 2 additions & 1 deletion app/gen/mocks/createBorough.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import type { Borough } from "../types/Borough";

export function createBorough(
Expand All @@ -8,7 +9,7 @@ export function createBorough(
...{
id: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9])$")),
new RandExp("^([0-9])$").gen(),
]),
title: faker.string.alpha(),
abbr: faker.string.alpha(),
Expand Down
3 changes: 2 additions & 1 deletion app/gen/mocks/createCapitalCommitment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import type { CapitalCommitment } from "../types/CapitalCommitment";

export function createCapitalCommitment(
Expand All @@ -12,7 +13,7 @@ export function createCapitalCommitment(
]),
type: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([A-z]{4})$")),
new RandExp("^([A-z]{4})$").gen(),
]),
plannedDate: faker.date.anytime().toString(),
budgetLineCode: faker.string.alpha(),
Expand Down
3 changes: 2 additions & 1 deletion app/gen/mocks/createCapitalProject.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createCapitalProjectCategory } from "./createCapitalProjectCategory";
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import type { CapitalProject } from "../types/CapitalProject";

export function createCapitalProject(
Expand All @@ -11,7 +12,7 @@ export function createCapitalProject(
description: faker.string.alpha(),
managingCode: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9]{3})$")),
new RandExp("^([0-9]{3})$").gen(),
]),
managingAgency: faker.string.alpha(),
minDate: faker.date.anytime().toString(),
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createCapitalProjectBudgeted.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createCapitalProject } from "./createCapitalProject";
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import type { CapitalProjectBudgeted } from "../types/CapitalProjectBudgeted";

export function createCapitalProjectBudgeted(
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createCapitalProjectCategory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import type { CapitalProjectCategory } from "../types/CapitalProjectCategory";

/**
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createCapitalProjectPage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createPage } from "./createPage";
import { createCapitalProject } from "./createCapitalProject";
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import type { CapitalProjectPage } from "../types/CapitalProjectPage";

export function createCapitalProjectPage(
Expand Down
3 changes: 2 additions & 1 deletion app/gen/mocks/createCityCouncilDistrict.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import type { CityCouncilDistrict } from "../types/CityCouncilDistrict";

export function createCityCouncilDistrict(
Expand All @@ -8,7 +9,7 @@ export function createCityCouncilDistrict(
...{
id: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9]{1,2})$")),
new RandExp("^([0-9]{1,2})$").gen(),
]),
},
...data,
Expand Down
5 changes: 3 additions & 2 deletions app/gen/mocks/createCommunityDistrict.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import type { CommunityDistrict } from "../types/CommunityDistrict";

export function createCommunityDistrict(
Expand All @@ -8,11 +9,11 @@ export function createCommunityDistrict(
...{
id: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9]{2})$")),
new RandExp("^([0-9]{2})$").gen(),
]),
boroughId: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9])$")),
new RandExp("^([0-9])$").gen(),
]),
},
...data,
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createError.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import type { Error } from "../types/Error";

export function createError(
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createFindAgencies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createAgency } from "./createAgency";
import { createError } from "./createError";
import type {
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createFindBoroughs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createBorough } from "./createBorough";
import { createError } from "./createError";
import type {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createCapitalCommitment } from "./createCapitalCommitment";
import { createError } from "./createError";
import type {
Expand All @@ -14,7 +15,7 @@ export function createFindCapitalCommitmentsByManagingCodeCapitalProjectIdPathPa
return {
managingCode: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9]{3})$")),
new RandExp("^([0-9]{3})$").gen(),
]),
capitalProjectId: faker.string.alpha(),
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createCapitalProjectBudgeted } from "./createCapitalProjectBudgeted";
import { createError } from "./createError";
import type {
Expand All @@ -14,7 +15,7 @@ export function createFindCapitalProjectByManagingCodeCapitalProjectIdPathParams
return {
managingCode: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9]{3})$")),
new RandExp("^([0-9]{3})$").gen(),
]),
capitalProjectId: faker.string.alpha(),
};
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createFindCapitalProjectTiles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createError } from "./createError";
import type {
FindCapitalProjectTilesPathParams,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createCapitalProjectPage } from "./createCapitalProjectPage";
import { createError } from "./createError";
import type {
Expand All @@ -15,11 +16,11 @@ export function createFindCapitalProjectsByBoroughIdCommunityDistrictIdPathParam
return {
boroughId: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9]{1})$")),
new RandExp("^([0-9]{1})$").gen(),
]),
communityDistrictId: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9]{2})$")),
new RandExp("^([0-9]{2})$").gen(),
]),
};
}
Expand Down
3 changes: 2 additions & 1 deletion app/gen/mocks/createFindCapitalProjectsByCityCouncilId.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createCapitalProjectPage } from "./createCapitalProjectPage";
import { createError } from "./createError";
import type {
Expand All @@ -15,7 +16,7 @@ export function createFindCapitalProjectsByCityCouncilIdPathParams(): NonNullabl
return {
cityCouncilDistrictId: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9]{1,2})$")),
new RandExp("^([0-9]{1,2})$").gen(),
]),
};
}
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createFindCityCouncilDistrictTiles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createError } from "./createError";
import type {
FindCityCouncilDistrictTilesPathParams,
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createFindCityCouncilDistricts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createCityCouncilDistrict } from "./createCityCouncilDistrict";
import { createError } from "./createError";
import type {
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createFindCommunityDistrictTiles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createError } from "./createError";
import type {
FindCommunityDistrictTilesPathParams,
Expand Down
3 changes: 2 additions & 1 deletion app/gen/mocks/createFindCommunityDistrictsByBoroughId.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createCommunityDistrict } from "./createCommunityDistrict";
import { createError } from "./createError";
import type {
Expand All @@ -14,7 +15,7 @@ export function createFindCommunityDistrictsByBoroughIdPathParams(): NonNullable
return {
boroughId: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9]{1})$")),
new RandExp("^([0-9]{1})$").gen(),
]),
};
}
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createFindLandUses.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createLandUse } from "./createLandUse";
import { createError } from "./createError";
import type {
Expand Down
3 changes: 2 additions & 1 deletion app/gen/mocks/createFindTaxLotByBbl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createTaxLot } from "./createTaxLot";
import { createError } from "./createError";
import type {
Expand All @@ -14,7 +15,7 @@ export function createFindTaxLotByBblPathParams(): NonNullable<FindTaxLotByBblPa
return {
bbl: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9]{10})$")),
new RandExp("^([0-9]{10})$").gen(),
]),
};
}
Expand Down
3 changes: 2 additions & 1 deletion app/gen/mocks/createFindTaxLotGeoJsonByBbl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createTaxLotGeoJson } from "./createTaxLotGeoJson";
import { createError } from "./createError";
import type {
Expand All @@ -14,7 +15,7 @@ export function createFindTaxLotGeoJsonByBblPathParams(): NonNullable<FindTaxLot
return {
bbl: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9]{10})$")),
new RandExp("^([0-9]{10})$").gen(),
]),
};
}
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createFindTaxLots.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createTaxLotBasicPage } from "./createTaxLotBasicPage";
import { createError } from "./createError";
import type {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createZoningDistrict } from "./createZoningDistrict";
import { createError } from "./createError";
import type {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createZoningDistrictClass } from "./createZoningDistrictClass";
import { createError } from "./createError";
import type {
Expand All @@ -14,7 +15,7 @@ export function createFindZoningDistrictClassByZoningDistrictClassIdPathParams()
return {
id: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^[A-z][0-9]+$")),
new RandExp("^[A-z][0-9]+$").gen(),
]),
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createZoningDistrictClassCategoryColor } from "./createZoningDistrictClassCategoryColor";
import { createError } from "./createError";
import type {
Expand Down
1 change: 1 addition & 0 deletions app/gen/mocks/createFindZoningDistrictClasses.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createZoningDistrictClass } from "./createZoningDistrictClass";
import { createError } from "./createError";
import type {
Expand Down
3 changes: 2 additions & 1 deletion app/gen/mocks/createFindZoningDistrictClassesByTaxLotBbl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createZoningDistrictClass } from "./createZoningDistrictClass";
import { createError } from "./createError";
import type {
Expand All @@ -14,7 +15,7 @@ export function createFindZoningDistrictClassesByTaxLotBblPathParams(): NonNulla
return {
bbl: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9]{10})$")),
new RandExp("^([0-9]{10})$").gen(),
]),
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createZoningDistrictClass } from "./createZoningDistrictClass";
import { createError } from "./createError";
import type {
Expand Down
3 changes: 2 additions & 1 deletion app/gen/mocks/createFindZoningDistrictsByTaxLotBbl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faker } from "@faker-js/faker";
import RandExp from "randexp";
import { createZoningDistrict } from "./createZoningDistrict";
import { createError } from "./createError";
import type {
Expand All @@ -14,7 +15,7 @@ export function createFindZoningDistrictsByTaxLotBblPathParams(): NonNullable<Fi
return {
bbl: faker.helpers.arrayElement<any>([
faker.string.alpha(),
faker.helpers.fromRegExp(new RegExp("^([0-9]{10})$")),
new RandExp("^([0-9]{10})$").gen(),
]),
};
}
Expand Down
Loading

0 comments on commit fdd56b8

Please sign in to comment.