Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
fix(adeli): fix adeli number sanitizing
Browse files Browse the repository at this point in the history
  • Loading branch information
cberthou committed May 3, 2022
1 parent 1d4fdd8 commit 1f7a264
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/services/__tests__/adeli-resquest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { requestAdeli } from "../adeli/request";
jest.mock("axios");
describe("requestAdeli", () => {
beforeEach(() => {
(axios.get as jest.Mock).mockReset();
// @ts-ignore
axios.get.mockImplementation(() => Promise.resolve({ data: { rows: [] } }));
});
Expand All @@ -23,6 +24,7 @@ describe("requestAdeli", () => {
${"123"}
${"1 2 3"}
${"1.2...3"}
${"00/00/01/23"}
`("should call api endpoint if adeli is $input", async ({ input }) => {
const result = await requestAdeli(input);
expect(axios.get).toHaveBeenCalledWith(
Expand Down
2 changes: 1 addition & 1 deletion src/services/adeli/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { zip } from "../../utils/array";
import config from "../config";

const formatRequestedAdeli = (adeliId: string) =>
adeliId.replace(".", "").replace(" ", "").replace("/", "").padStart(10, "0");
adeliId.replace(/\./g, "").replace(/ /g, "").replace(/\//g, "").padStart(10, "0");

const rowColumnsToObject = <Column>(row: string[], columns: Column[]) =>
Object.fromEntries(zip(columns, row));
Expand Down

0 comments on commit 1f7a264

Please sign in to comment.