Skip to content

Commit

Permalink
test: get filters above 80% line and branch coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilR8 committed Dec 19, 2024
1 parent 0fcb619 commit a3328bc
Show file tree
Hide file tree
Showing 2 changed files with 377 additions and 100 deletions.
21 changes: 19 additions & 2 deletions solution/ui/regulations/utilities/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,48 @@
* @returns {string} - a date string in Month D/DD, YYYY format
*/
const formatDate = (dateString) => {
if (!dateString || typeof dateString !== "string") {
return "Invalid Date";
}

if (dateString.includes("/")) {
return dateString;
}

const date = new Date(dateString);

if (date.toString() === "Invalid Date") {
return date.toString();
}

let options = { year: "numeric", timeZone: "UTC" };
const raw_date = dateString.split("-");

if (raw_date.length > 1) {
options.month = "long";
}
if (raw_date.length > 2) {
options.day = "numeric";
}

const format = new Intl.DateTimeFormat("en-US", options);
return format.format(date);
};

/**
*
* @param {Object} location - a Subpart or Section of the Regs
* @param {string} location.title - the title number of the location (ex: 42)
* @param {string} location.type - the type of location (ex: Subpart, Section)
* @param {string} location.part - the part number for the location
* @param {?string} location.section_id - the section number
* @param {?string} location.subpart_id - the subpart name
* @returns {string} - a properly formatted label
*/
const locationLabel = ({ type, part, section_id, subpart_id }) => {
return type.toLowerCase() === "section"
if (!type || typeof type !== "string") {
return "Invalid Location";
}
return type?.toLowerCase() === "section"
? `${part}.${section_id}`
: `${part} Subpart ${subpart_id}`;
};
Expand Down
Loading

0 comments on commit a3328bc

Please sign in to comment.