mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 08:03:13 +00:00
fix(work-orders): assert GET User full display name
This commit is contained in:
parent
e9e17dadec
commit
8031357dfa
2 changed files with 3 additions and 6 deletions
|
|
@ -120,7 +120,7 @@ function readOptionalString(item: Record<string, unknown>, ...keys: string[]): s
|
|||
return "";
|
||||
}
|
||||
|
||||
/** GET User exposes `Name` as first name only; prefer FirstName + LastName when present. */
|
||||
/** GET User serializes `Name` as FirstName + LastName; compose those fields if present. */
|
||||
function mapUserDisplayName(item: Record<string, unknown>): string {
|
||||
const firstName = readOptionalString(item, "firstName", "FirstName");
|
||||
const lastName = readOptionalString(item, "lastName", "LastName");
|
||||
|
|
|
|||
|
|
@ -204,10 +204,7 @@ const GET_USER_SERIALIZED_DIRECTORY = {
|
|||
data: [
|
||||
{
|
||||
Id: "s1",
|
||||
Name: "Alex",
|
||||
FirstName: "Alex",
|
||||
LastName: "Smith",
|
||||
UserName: "alex.smith",
|
||||
Name: "Alex Smith",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
@ -217,7 +214,7 @@ describe("workOrdersApi.fetchUsers", () => {
|
|||
apiGet.mockReset();
|
||||
});
|
||||
|
||||
it("composes a full display name from the serialized GET User shape", async () => {
|
||||
it("maps the serialized GET User Name as the full display name", async () => {
|
||||
apiGet.mockResolvedValue(GET_USER_SERIALIZED_DIRECTORY);
|
||||
|
||||
const users = await workOrdersApi.fetchUsers();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue