Skip to content

Commit b3ce16c

Browse files
committed
test - user and utils
1 parent d0da5b0 commit b3ce16c

2 files changed

Lines changed: 1173 additions & 106 deletions

File tree

tests/__tests__/user.test.ts

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,25 @@ describe("User", () => {
3232
expect(user.deviceId).toEqual("00000000000000");
3333
});
3434

35-
it("should set default clientType if not provided", () => {
35+
it("should set default clientType to 'web' if not provided (line 22)", () => {
3636
const mockApiClient = new ApiClient("") as jest.Mocked<ApiClient>;
3737
const user = new User({
3838
apiClient: mockApiClient,
39+
deviceId: "test-device-id",
3940
});
4041

4142
expect(user.clientType).toEqual("web");
4243
});
4344

44-
it("should use provided deviceId when specified", () => {
45+
it("should use provided clientType when provided (line 22)", () => {
4546
const mockApiClient = new ApiClient("") as jest.Mocked<ApiClient>;
46-
const customDeviceId = "custom-device-id";
4747
const user = new User({
4848
apiClient: mockApiClient,
49-
deviceId: customDeviceId,
50-
clientType: "web",
51-
});
52-
53-
expect(user.deviceId).toEqual(customDeviceId);
54-
});
55-
56-
it("should use provided clientType when specified", () => {
57-
const mockApiClient = new ApiClient("") as jest.Mocked<ApiClient>;
58-
const customClientType = "mobile";
59-
const user = new User({
60-
apiClient: mockApiClient,
61-
clientType: customClientType,
49+
deviceId: "test-device-id",
50+
clientType: "mobile",
6251
});
6352

64-
expect(user.clientType).toEqual(customClientType);
53+
expect(user.clientType).toEqual("mobile");
6554
});
6655
});
6756

@@ -70,20 +59,6 @@ describe("User", () => {
7059
const result = user.toString();
7160
expect(result).toEqual("User (unknown) (deviceId 00000000000000)");
7261
});
73-
74-
it("should show username when user is connected", async () => {
75-
const responseData = {
76-
username: "testuser",
77-
token: "abc123",
78-
id: 123,
79-
};
80-
81-
mockApiClient.post.mockResolvedValue(responseData);
82-
await user.connect();
83-
84-
const result = user.toString();
85-
expect(result).toEqual("User testuser (deviceId 00000000000000)");
86-
});
8762
});
8863

8964
describe("connect", () => {
@@ -148,16 +123,5 @@ describe("User", () => {
148123
);
149124
expect(result).toEqual(responseData);
150125
});
151-
152-
it("should handle errors when updating user", async () => {
153-
const partialUserData = {
154-
first_name: "John",
155-
last_name: "Doe",
156-
};
157-
158-
mockApiClient.patch.mockRejectedValue(new Error("Update failed"));
159-
160-
await expect(user.updateUser(partialUserData)).rejects.toThrow("Update failed");
161-
});
162126
});
163127
});

0 commit comments

Comments
 (0)