Skip to content

Commit e7b068a

Browse files
authored
Merge pull request #92 from miorel/whoami
Try getting the `whoami` API to work again
2 parents d7e7367 + 1976524 commit e7b068a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/_tests/leetcode.test.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ describe("LeetCode", { timeout: 15_000 }, () => {
2626
await res.clone().json();
2727
});
2828

29-
it("should be able to get user profile", async () => {
29+
it("should be able to get a user's profile", async () => {
3030
const user = await lc.user("jacoblincool");
3131
expect(user.matchedUser?.username.toLowerCase()).toBe("jacoblincool");
3232
});
3333

34-
it("should be able to get user's recent submissions", async () => {
34+
it("should be able to get a user's recent submissions", async () => {
3535
const recent_submissions = await lc.recent_submissions("jacoblincool", 10);
3636
expect(recent_submissions.length).toBe(10);
3737
});
@@ -52,11 +52,18 @@ describe("LeetCode", { timeout: 15_000 }, () => {
5252
expect(data.allQuestionsCount.length).toBe(4);
5353
});
5454

55-
it("should be not able to get user's submissions", async () => {
55+
it("should be not able to get own submissions", async () => {
5656
await expect(lc.submissions({ limit: 30, offset: 0 })).rejects.toThrow();
5757
});
5858

59-
it("should be able to get user's contest informations", async () => {
59+
it("should be able to get own information", async () => {
60+
const user = await lc.whoami();
61+
expect(user.userId).toBe(null);
62+
expect(user.username).toBe("");
63+
expect(user.isSignedIn).toBe(false);
64+
});
65+
66+
it("should be able to get a user's contest informations", async () => {
6067
const contests = await lc.user_contest_info("lapor");
6168
expect(contests.userContestRanking.rating).toBeGreaterThan(1500);
6269
expect(contests.userContestRankingHistory.length).toBeGreaterThan(0);
@@ -92,15 +99,15 @@ describe("LeetCode", { timeout: 15_000 }, () => {
9299
});
93100

94101
it.skipIf(!process.env["TEST_LEETCODE_SESSION"])(
95-
"should be able to get user's submissions",
102+
"should be able to get own submissions",
96103
async () => {
97104
const submissions = await lc.submissions({ limit: 100, offset: 0 });
98105
expect(submissions.length).toBe(100);
99106
},
100107
);
101108

102109
it.skipIf(!process.env["TEST_LEETCODE_SESSION"])(
103-
"should be able to get user's information",
110+
"should be able to get own information",
104111
async () => {
105112
const user = await lc.whoami();
106113
expect(typeof user.userId).toBe("number");

src/leetcode.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ export class LeetCode extends EventEmitter {
330330
public async whoami(): Promise<Whoami> {
331331
await this.initialized;
332332
const { data } = await this.graphql({
333-
operationName: "globalData",
334333
variables: {},
335334
query: WHOAMI,
336335
});

0 commit comments

Comments
 (0)