-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle multiple phone number formats in search (#2232)
* Scattershot approach to phone numbers * Update integration test copy * Add phone number search to API side * Name test * Update copy on e2e test
- Loading branch information
Showing
11 changed files
with
227 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,11 @@ | |
"value": "+18184195968", | ||
"use": "home" | ||
}, | ||
{ | ||
"system": "phone", | ||
"value": "123-456-7890", | ||
"use": "mobile" | ||
}, | ||
{ | ||
"system": "email", | ||
"value": "[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
containers/tefca-viewer/src/app/tests/unit/query-service.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { GetPhoneQueryFormats } from "@/app/query-service"; | ||
|
||
describe("GetPhoneQueryFormats", () => { | ||
it("should fail gracefully on partial phone number inputs", async () => { | ||
const partialPhone = "456 7890"; | ||
const expectedResult = ["456+7890"]; | ||
expect(await GetPhoneQueryFormats(partialPhone)).toEqual(expectedResult); | ||
}); | ||
it("should fail gracefully on given phones with separators remaining", async () => { | ||
const phoneWithStuff = "+44.202.456.7890"; | ||
const expectedResult = ["+44.202.456.7890"]; | ||
expect(await GetPhoneQueryFormats(phoneWithStuff)).toEqual(expectedResult); | ||
}); | ||
it("should fully process ten-digit input strings", async () => { | ||
const inputPhone = "1234567890"; | ||
const expectedResult = [ | ||
"1234567890", | ||
"123-456-7890", | ||
"123+456+7890", | ||
"(123)+456+7890", | ||
"(123)-456-7890", | ||
"(123)456-7890", | ||
"1(123)456-7890", | ||
]; | ||
expect(await GetPhoneQueryFormats(inputPhone)).toEqual(expectedResult); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { FormatPhoneAsDigits } from "@/app/utils"; | ||
|
||
describe("FormatPhoneAsDigits", () => { | ||
it("should handle dashes, spacecs, and dot delimiters", () => { | ||
const dashInput = "123-456-7890"; | ||
const expectedResult = "1234567890"; | ||
expect(FormatPhoneAsDigits(dashInput)).toEqual(expectedResult); | ||
|
||
const spaceInput = "123 456 7890"; | ||
expect(FormatPhoneAsDigits(spaceInput)).toEqual(expectedResult); | ||
|
||
const dotInput = "123.456.7890"; | ||
expect(FormatPhoneAsDigits(dotInput)).toEqual(expectedResult); | ||
}); | ||
it("should handle parentheticals around area codes", () => { | ||
const expectedResult = "1234567890"; | ||
let parentheticalInput = "(123) 456 7890"; | ||
expect(FormatPhoneAsDigits(parentheticalInput)).toEqual(expectedResult); | ||
|
||
parentheticalInput = "(123)456-7890"; | ||
expect(FormatPhoneAsDigits(parentheticalInput)).toEqual(expectedResult); | ||
}); | ||
it("should handle extraneous white spaces regardless of position", () => { | ||
const expectedResult = "1234567890"; | ||
const weirdSpaceNumber = " 123 - 456 7 8 9 0 "; | ||
expect(FormatPhoneAsDigits(weirdSpaceNumber)).toEqual(expectedResult); | ||
}); | ||
it("should gracefully fail if provided a partial number", () => { | ||
const givenPhone = "456-7890"; | ||
const expectedResult = "456-7890"; | ||
expect(FormatPhoneAsDigits(givenPhone)).toEqual(expectedResult); | ||
}); | ||
it("should gracefully fail if given a country code", () => { | ||
const givenPhone = "+44 202 555 8736"; | ||
const expectedResult = "+44 202 555 8736"; | ||
expect(FormatPhoneAsDigits(givenPhone)).toEqual(expectedResult); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters