Skip to content

Commit

Permalink
Merge pull request #520 from bcgov/feature/SPDBCSC-652
Browse files Browse the repository at this point in the history
added genderTxtMap to handle diverse and unknown
  • Loading branch information
TayGov authored Aug 1, 2023
2 parents 924876d + b812252 commit 53a2237
Show file tree
Hide file tree
Showing 3 changed files with 2,707 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,13 @@ export default function ApplicationForm({
loader: { width: "100%", textAlign: "center", display: "inline-block" },
content: { display: "none" }
});

// Create a gender text Map
const genderTxtMap = new Map([
["female", "F"],
["male", "M"],
["diverse", "U"],
["unknown", "U"]
]);
const location = useLocation();

const getAge = birthdateString => {
Expand Down Expand Up @@ -228,7 +234,7 @@ export default function ApplicationForm({
}

// Convert gender text
const formatGender = gender === "female" ? "F" : "M";
const formatGender = genderTxtMap.get(gender.toLowerCase());

const age = getAge(birthdate);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,88 @@ describe("ApplicationForm Component", () => {
expect(asFragment()).toMatchSnapshot();
});

test("Matches the snapshot with gender being diverse", async () => {
const newApplicant = {
...applicant,
genderTxt: "Diverse"
};

const newPage = {
...page,
applicant: newApplicant
};

const updatePayload = {
userInfo: {
birthdate: "04/04/04",
address: {
street_address: "123 addy",
locality: "local",
region: "British Columbia",
postal_code: "v9n1d4"
},
gender: "U",
given_name: "given",
given_names: "givens",
family_name: "fam",
identity_assurance_level: 3
},
authorities: ["Authorized"]
};
const token = generateJWTToken(updatePayload);

mock.onGet(API_REQUEST_JWT).reply(200, token);

const { asFragment } = render(
<MemoryRouter initialEntries={["/applicationform?code=code"]}>
<ApplicationForm page={newPage} />
</MemoryRouter>
);

expect(asFragment()).toMatchSnapshot();
});

test("Matches the snapshot with gender being unknown", async () => {
const newApplicant = {
...applicant,
genderTxt: "Unknown"
};

const newPage = {
...page,
applicant: newApplicant
};

const updatePayload = {
userInfo: {
birthdate: "04/04/04",
address: {
street_address: "123 addy",
locality: "local",
region: "British Columbia",
postal_code: "v9n1d4"
},
gender: "U",
given_name: "given",
given_names: "givens",
family_name: "fam",
identity_assurance_level: 3
},
authorities: ["Authorized"]
};
const token = generateJWTToken(updatePayload);

mock.onGet(API_REQUEST_JWT).reply(200, token);

const { asFragment } = render(
<MemoryRouter initialEntries={["/applicationform?code=code"]}>
<ApplicationForm page={newPage} />
</MemoryRouter>
);

expect(asFragment()).toMatchSnapshot();
});

test("Matches the snapshot with valid region/province", async () => {
const updatePayload = {
userInfo: {
Expand Down
Loading

0 comments on commit 53a2237

Please sign in to comment.