Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix tests

Steven Tey9812cced18de
diff --git a/apps/web/tests/customers/index.test.ts b/apps/web/tests/customers/index.test.ts
index 9451d960d2..bb2362c8b7 100644
--- a/apps/web/tests/customers/index.test.ts
+++ b/apps/web/tests/customers/index.test.ts
@@ -1,4 +1,5 @@
import { Customer } from "@/lib/types";
+import { CustomerSchema } from "@/lib/zod/schemas/customers";
import { afterAll, describe, expect, test } from "vitest";
import { randomId } from "../utils/helpers";
import { IntegrationHarness } from "../utils/integration";
@@ -18,7 +19,7 @@ const expectedCustomer = {
name: customerRecord.name,
email: customerRecord.email,
avatar: customerRecord.avatar,
- country: expect.any([expect.any(String), null]),
+ country: null,
createdAt: expect.any(String),
};
@@ -33,24 +34,24 @@ describe.sequential("/customers/**", async () => {
});
test("POST /customers", async () => {
- const { status, data: customer } = await http.post<Customer>({
+ const { status, data: createdCustomer } = await http.post<Customer>({
path: "/customers",
body: customerRecord,
});
expect(status).toEqual(201);
- expect(customer).toStrictEqual(expectedCustomer);
+ expect(createdCustomer).toStrictEqual(expectedCustomer);
- customerId = customer.id;
+ customerId = createdCustomer.id;
});
test("GET /customers/{id}", async () => {
- const { status, data: customer } = await http.get<Customer>({
+ const { status, data: retrievedCustomer } = await http.get<Customer>({
path: `/customers/${customerId}`,
});
expect(status).toEqual(200);
- expect(customer).toStrictEqual(expectedCustomer);
+ expect(retrievedCustomer).toStrictEqual(expectedCustomer);
});
test("GET /customers", async () => {
@@ -58,13 +59,12 @@ describe.sequential("/customers/**", async () => {
path: "/customers",
});
- const customerFound = customers.find(
- (c) => c.externalId === customerRecord.externalId,
- );
-
expect(status).toEqual(200);
expect(customers.length).toBeGreaterThanOrEqual(1);
- expect(customerFound).toStrictEqual(expectedCustomer);
+ customers.forEach((customer) => {
+ const result = CustomerSchema.safeParse(customer);
+ expect(result.success).toBe(true);
+ });
});
test("PATCH /customers/{id}", async () => {