Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRDCDH-1774 Ignore casing when comparing name/abbr #492

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/utils/formUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ describe("formatFullStudyName cases", () => {
expect(result).toBe("Study Name");
});

it("should ignore casing when comparing the study name and abbreviation", () => {
const equalValuesWithDifferentCasing = utils.formatFullStudyName("study name", "STUDY NAME");
expect(equalValuesWithDifferentCasing).toBe("study name");

const equalValuesWithDifferentCasing2 = utils.formatFullStudyName("STUDY NAME", "study name");
expect(equalValuesWithDifferentCasing2).toBe("STUDY NAME");
});

it("should remove extra spaces from the study name", () => {
const studyName = " Study Name ";
const result = utils.formatFullStudyName(studyName, "");
Expand Down
2 changes: 1 addition & 1 deletion src/utils/formUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const formatFullStudyName = (studyName: string, studyAbbreviation: string
if (typeof studyName !== "string") {
return "";
}
if (studyAbbreviation === studyName) {
if (studyAbbreviation?.toLowerCase() === studyName?.toLowerCase()) {
return studyName.trim();
}
if (studyAbbreviation && studyAbbreviation.length > 0) {
Expand Down