Skip to content

Commit a6d9c14

Browse files
committed
fix: formatting
1 parent d2a7ef9 commit a6d9c14

File tree

1 file changed

+67
-57
lines changed

1 file changed

+67
-57
lines changed

packages/thirdweb/src/wallets/in-app/core/users/getUser.test.ts

Lines changed: 67 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -42,84 +42,92 @@ describe("getUser", () => {
4242
it("should call the correct URL with email", async () => {
4343
mockFetch.mockResolvedValueOnce({
4444
ok: true,
45-
json: async () => [{
46-
userId: "user1",
47-
walletAddress: "0x123",
48-
49-
createdAt: "2023-01-01T00:00:00Z",
50-
linkedAccounts: []
51-
}]
45+
json: async () => [
46+
{
47+
userId: "user1",
48+
walletAddress: "0x123",
49+
50+
createdAt: "2023-01-01T00:00:00Z",
51+
linkedAccounts: [],
52+
},
53+
],
5254
});
5355

5456
const result = await getUser({
5557
client: mockClient,
56-
58+
5759
});
5860

5961
expect(mockFetch).toHaveBeenCalledWith(
60-
"https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=email&email=test%40test.com"
62+
"https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=email&email=test%40test.com",
6163
);
6264
expect(result).toEqual({
6365
userId: "user1",
6466
walletAddress: "0x123",
6567
6668
createdAt: "2023-01-01T00:00:00Z",
67-
profiles: []
69+
profiles: [],
6870
});
6971
});
7072

7173
it("should call the correct URL with phone", async () => {
7274
mockFetch.mockResolvedValueOnce({
73-
ok: true,
74-
json: async () => [{
75-
userId: "user1",
76-
walletAddress: "0x123",
77-
phone: "+1234567890",
78-
createdAt: "2023-01-01T00:00:00Z",
79-
linkedAccounts: []
80-
}]
75+
ok: true,
76+
json: async () => [
77+
{
78+
userId: "user1",
79+
walletAddress: "0x123",
80+
phone: "+1234567890",
81+
createdAt: "2023-01-01T00:00:00Z",
82+
linkedAccounts: [],
83+
},
84+
],
8185
});
8286

8387
const result = await getUser({
8488
client: mockClient,
85-
phone: "+1234567890"
89+
phone: "+1234567890",
8690
});
8791

8892
expect(mockFetch).toHaveBeenCalledWith(
89-
"https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=phone&phone=%2B1234567890"
93+
"https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=phone&phone=%2B1234567890",
9094
);
9195
expect(result).toEqual({
9296
userId: "user1",
9397
walletAddress: "0x123",
9498
phone: "+1234567890",
9599
createdAt: "2023-01-01T00:00:00Z",
96-
profiles: []
100+
profiles: [],
97101
});
98102
});
99103

100104
it("should call the correct URL with id", async () => {
101105
mockFetch.mockResolvedValueOnce({
102106
ok: true,
103-
json: async () => [{
104-
userId: "user1",
105-
walletAddress: "0x123",
106-
createdAt: "2023-01-01T00:00:00Z",
107-
linkedAccounts: [{
108-
type: "id",
109-
details: {
110-
id: "0x456"
111-
}
112-
}]
113-
}]
107+
json: async () => [
108+
{
109+
userId: "user1",
110+
walletAddress: "0x123",
111+
createdAt: "2023-01-01T00:00:00Z",
112+
linkedAccounts: [
113+
{
114+
type: "id",
115+
details: {
116+
id: "0x456",
117+
},
118+
},
119+
],
120+
},
121+
],
114122
});
115123

116124
const result = await getUser({
117125
client: mockClient,
118-
id: "user1"
126+
id: "user1",
119127
});
120128

121129
expect(mockFetch).toHaveBeenCalledWith(
122-
"https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=id&id=user1"
130+
"https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=id&id=user1",
123131
);
124132
expect(result).toEqual({
125133
userId: "user1",
@@ -129,36 +137,40 @@ describe("getUser", () => {
129137
{
130138
type: "id",
131139
details: {
132-
id: "0x456"
133-
}
134-
}
135-
]
140+
id: "0x456",
141+
},
142+
},
143+
],
136144
});
137145
});
138146

139147
it("should call the correct URL with externalWalletAddress", async () => {
140148
mockFetch.mockResolvedValueOnce({
141149
ok: true,
142-
json: async () => [{
143-
userId: "user1",
144-
walletAddress: "0x123",
145-
createdAt: "2023-01-01T00:00:00Z",
146-
linkedAccounts: [{
147-
type: "siwe",
148-
details: {
149-
address: "0x456"
150-
}
151-
}]
152-
}]
150+
json: async () => [
151+
{
152+
userId: "user1",
153+
walletAddress: "0x123",
154+
createdAt: "2023-01-01T00:00:00Z",
155+
linkedAccounts: [
156+
{
157+
type: "siwe",
158+
details: {
159+
address: "0x456",
160+
},
161+
},
162+
],
163+
},
164+
],
153165
});
154166

155167
const result = await getUser({
156168
client: mockClient,
157-
externalWalletAddress: "0x456"
169+
externalWalletAddress: "0x456",
158170
});
159171

160172
expect(mockFetch).toHaveBeenCalledWith(
161-
"https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=externalWalletAddress&externalWalletAddress=0x456"
173+
"https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=externalWalletAddress&externalWalletAddress=0x456",
162174
);
163175
expect(result).toEqual({
164176
userId: "user1",
@@ -168,15 +180,13 @@ describe("getUser", () => {
168180
{
169181
type: "wallet",
170182
details: {
171-
address: "0x456"
172-
}
173-
}
174-
]
183+
address: "0x456",
184+
},
185+
},
186+
],
175187
});
176188
});
177189

178-
179-
180190
it("should handle fetch errors", async () => {
181191
mockFetch.mockResolvedValueOnce({
182192
ok: false,

0 commit comments

Comments
 (0)