refactor: rename remaining recipient references to person/people
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
} from "@/schemas/assignment.schema"
|
||||
|
||||
const schemaCopy = {
|
||||
recipientRequired: "El destinatario es obligatorio",
|
||||
personRequired: "La persona es obligatoria",
|
||||
itemIdRequired: "El artículo es obligatorio",
|
||||
quantityMinOne: "La cantidad debe ser al menos 1",
|
||||
assetIdRequired: "El activo es obligatorio cuando se especifica el artículo",
|
||||
@@ -16,7 +16,7 @@ const schemaCopy = {
|
||||
describe("assignment schema localization", () => {
|
||||
it("uses localized create validation messages for missing required fields", () => {
|
||||
const result = buildCreateAssignmentSchema(schemaCopy).safeParse({
|
||||
recipientId: "",
|
||||
personId: "",
|
||||
quantity: 0,
|
||||
})
|
||||
|
||||
@@ -24,7 +24,7 @@ describe("assignment schema localization", () => {
|
||||
if (!result.success) {
|
||||
const errors = result.error.flatten().fieldErrors
|
||||
|
||||
expect(errors.recipientId).toContain(schemaCopy.recipientRequired)
|
||||
expect(errors.personId).toContain(schemaCopy.personRequired)
|
||||
expect(errors.quantity).toContain(schemaCopy.quantityMinOne)
|
||||
}
|
||||
})
|
||||
@@ -33,7 +33,7 @@ describe("assignment schema localization", () => {
|
||||
const result = buildUpdateAssignmentSchema(schemaCopy).safeParse({
|
||||
id: "",
|
||||
itemId: "item-1",
|
||||
recipientId: "recipient-1",
|
||||
personId: "person-1",
|
||||
quantity: 1,
|
||||
assetId: "",
|
||||
})
|
||||
@@ -49,20 +49,20 @@ describe("assignment schema localization", () => {
|
||||
|
||||
it("preserves valid create and update payloads without errors", () => {
|
||||
const createResult = buildCreateAssignmentSchema(schemaCopy).safeParse({
|
||||
recipientId: "recipient-1",
|
||||
personId: "person-1",
|
||||
itemId: "item-1",
|
||||
quantity: 2,
|
||||
})
|
||||
|
||||
expect(createResult.success).toBe(true)
|
||||
if (createResult.success) {
|
||||
expect(createResult.data.recipientId).toBe("recipient-1")
|
||||
expect(createResult.data.personId).toBe("person-1")
|
||||
expect(createResult.data.quantity).toBe(2)
|
||||
}
|
||||
|
||||
const updateResult = buildUpdateAssignmentSchema(schemaCopy).safeParse({
|
||||
id: "assignment-1",
|
||||
recipientId: "recipient-1",
|
||||
personId: "person-1",
|
||||
itemId: "item-1",
|
||||
assetId: "asset-1",
|
||||
quantity: 1,
|
||||
@@ -76,7 +76,7 @@ describe("assignment schema localization", () => {
|
||||
|
||||
it("keeps optional assignment fields optional in create", () => {
|
||||
const result = buildCreateAssignmentSchema(schemaCopy).safeParse({
|
||||
recipientId: "recipient-1",
|
||||
personId: "person-1",
|
||||
quantity: 1,
|
||||
})
|
||||
|
||||
@@ -86,7 +86,7 @@ describe("assignment schema localization", () => {
|
||||
it("allows update without itemId when no assetId is required", () => {
|
||||
const result = buildUpdateAssignmentSchema(schemaCopy).safeParse({
|
||||
id: "assignment-1",
|
||||
recipientId: "recipient-1",
|
||||
personId: "person-1",
|
||||
quantity: 1,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user