Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
Testersssszzszszszszsz 95% go brrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr…
Browse files Browse the repository at this point in the history
…rrrrrrrr
  • Loading branch information
Kathund committed Sep 1, 2024
1 parent a3c2899 commit 24a0bd1
Show file tree
Hide file tree
Showing 41 changed files with 576 additions and 204 deletions.
4 changes: 2 additions & 2 deletions src/API/getActiveHouses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ test('getActiveHouses', async () => {
expect(house.owner).toBeDefined();
expectTypeOf(house.owner).toEqualTypeOf<string>();
expect(house.createdAtTimestamp).toBeDefined();
expectTypeOf(house.createdAtTimestamp).toEqualTypeOf<number>();
expectTypeOf(house.createdAtTimestamp).toEqualTypeOf<number | null>();
expect(house.createdAt).toBeDefined();
expectTypeOf(house.createdAt).toEqualTypeOf<Date>();
expectTypeOf(house.createdAt).toEqualTypeOf<Date | null>();
expect(house.players).toBeDefined();
expectTypeOf(house.players).toEqualTypeOf<number>();
expect(house.cookies).toBeDefined();
Expand Down
17 changes: 12 additions & 5 deletions src/API/getLeaderboards.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,23 @@ test('getLeaderboards', async () => {
expectTypeOf(data[key]).toEqualTypeOf<Leaderboard[]>();
data[key].forEach((leaderboard: Leaderboard) => {
expect(leaderboard).toBeDefined();
expect(leaderboard).instanceOf(Leaderboard);
expectTypeOf(leaderboard).toEqualTypeOf<Leaderboard>();
expect(leaderboard.name).toBeDefined();
expectTypeOf(leaderboard.name).toEqualTypeOf<string | null>();

expect(leaderboard.path).toBeDefined();
expectTypeOf(leaderboard.path).toEqualTypeOf<string>();
expect(leaderboard.prefix).toBeDefined();
expectTypeOf(leaderboard.prefix).toEqualTypeOf<string>();
expect(leaderboard.title).toBeDefined();
expectTypeOf(leaderboard.title).toEqualTypeOf<string>();
expect(leaderboard.playerCount).toBeDefined();
expectTypeOf(leaderboard.playerCount).toEqualTypeOf<number>();
expect(leaderboard.location).toBeDefined();
expectTypeOf(leaderboard.location).toEqualTypeOf<string>();
expect(leaderboard.count).toBeDefined();
expect(leaderboard.count).toBeGreaterThanOrEqual(0);
expectTypeOf(leaderboard.count).toEqualTypeOf<number>();
expect(leaderboard.leaders).toBeDefined();
expectTypeOf(leaderboard.leaders).toEqualTypeOf<string[]>();
leaderboard.leaders.forEach((leader) => {
leaderboard.leaders.forEach((leader: string) => {
expect(leader).toBeDefined();
expectTypeOf(leader).toEqualTypeOf<string>();
});
Expand Down
15 changes: 6 additions & 9 deletions src/API/getLeaderboards.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Client from '../Client';
import Constants from '../utils/Constants';
import Endpoint from '../Private/Endpoint';
import Leaderboard from '../structures/Leaderboard';
import { RequestOptions } from '../Private/Requests';
Expand All @@ -11,19 +10,17 @@ class getLeaderboards extends Endpoint {
this.client = client;
}

async execute(options?: RequestOptions): Promise<any> {
async execute(options?: RequestOptions): Promise<Record<string, Leaderboard[]>> {
const res = await this.client.requests.request('/leaderboards', options);
if (res.options.raw) return res.data;
if (!res.data.leaderboards) {
throw new Error(this.client.errors.SOMETHING_WENT_WRONG.replace(/{cause}/, 'Try again.'));
}
const lbnames = Object.create(Constants.leaderboardNames);
for (const name in lbnames) {
lbnames[name] = res.data.leaderboards[lbnames[name]].length
? res.data.leaderboards[lbnames[name]].map((lb: any) => new Leaderboard(lb))
: [];
}
return lbnames;
const leaderboards: Record<string, Leaderboard[]> = {};
Object.keys(res.data.leaderboards).forEach((key) => {
leaderboards[key] = res.data.leaderboards[key].map((l: Record<string, any>) => new Leaderboard(l));
});
return leaderboards;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/API/getPlayerHouses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ test('getPlayerHouses', async () => {
expect(house.owner).toBeDefined();
expectTypeOf(house.owner).toEqualTypeOf<string>();
expect(house.createdAtTimestamp).toBeDefined();
expectTypeOf(house.createdAtTimestamp).toEqualTypeOf<number>();
expectTypeOf(house.createdAtTimestamp).toEqualTypeOf<number | null>();
expect(house.createdAt).toBeDefined();
expectTypeOf(house.createdAt).toEqualTypeOf<Date>();
expectTypeOf(house.createdAt).toEqualTypeOf<Date | null>();
expect(house.players).toBeDefined();
expectTypeOf(house.players).toEqualTypeOf<number>();
expect(house.cookies).toBeDefined();
Expand Down
10 changes: 5 additions & 5 deletions src/API/getRecentGames.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ test('getRecentGames', async () => {
expectTypeOf(game).toEqualTypeOf<RecentGame>();
expect(game).toBeInstanceOf(RecentGame);
expect(game.game).toBeDefined();
expectTypeOf(game.game).toEqualTypeOf<Game>();
expectTypeOf(game.game).toEqualTypeOf<Game | null>();
expect(game.dateTimestamp).toBeDefined();
expectTypeOf(game.dateTimestamp).toEqualTypeOf<number | null>();
expect(game.date).toBeDefined();
expectTypeOf(game.date).toEqualTypeOf<Date | null>();
expect(game.dateAt).toBeDefined();
expectTypeOf(game.dateAt).toEqualTypeOf<Date | null>();
expect(game.mode).toBeDefined();
expectTypeOf(game.mode).toEqualTypeOf<string | null>();
expect(game.map).toBeDefined();
expectTypeOf(game.map).toEqualTypeOf<string | null>();
expect(game.ongoing).toBeDefined();
expectTypeOf(game.ongoing).toEqualTypeOf<boolean>();
expect(game.endedAt).toBeDefined();
expectTypeOf(game.endedAt).toEqualTypeOf<Date | null>();
expect(game.endedTimestamp).toBeDefined();
expectTypeOf(game.endedTimestamp).toEqualTypeOf<number | null>();
expect(game.endedAt).toBeDefined();
expectTypeOf(game.endedAt).toEqualTypeOf<Date | null>();
expect(game.toString()).toBeDefined();
expect(game.toString()).toEqual(game.mode);
expectTypeOf(game.toString()).toEqualTypeOf<string | null>();
Expand Down
2 changes: 1 addition & 1 deletion src/API/getSkyblockAuctions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ test('getSkyblockAuctions (One Page Include Item Bytes)', async () => {
client.destroy();
});

test('getSkyblockAuctions (All Pages)', async () => {
test.skip('getSkyblockAuctions (All Pages)', async () => {
const client = new Client(process.env.HYPIXEL_KEY ?? '', { cache: false, checkForUpdates: false, rateLimit: 'NONE' });
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
Expand Down
Loading

0 comments on commit 24a0bd1

Please sign in to comment.