mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 02:22:06 +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 "";
|
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 {
|
function mapUserDisplayName(item: Record<string, unknown>): string {
|
||||||
const firstName = readOptionalString(item, "firstName", "FirstName");
|
const firstName = readOptionalString(item, "firstName", "FirstName");
|
||||||
const lastName = readOptionalString(item, "lastName", "LastName");
|
const lastName = readOptionalString(item, "lastName", "LastName");
|
||||||
|
|
|
||||||
|
|
@ -204,10 +204,7 @@ const GET_USER_SERIALIZED_DIRECTORY = {
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
Id: "s1",
|
Id: "s1",
|
||||||
Name: "Alex",
|
Name: "Alex Smith",
|
||||||
FirstName: "Alex",
|
|
||||||
LastName: "Smith",
|
|
||||||
UserName: "alex.smith",
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
@ -217,7 +214,7 @@ describe("workOrdersApi.fetchUsers", () => {
|
||||||
apiGet.mockReset();
|
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);
|
apiGet.mockResolvedValue(GET_USER_SERIALIZED_DIRECTORY);
|
||||||
|
|
||||||
const users = await workOrdersApi.fetchUsers();
|
const users = await workOrdersApi.fetchUsers();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue