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

Commit

Permalink
Meow
Browse files Browse the repository at this point in the history
  • Loading branch information
Kathund committed Aug 27, 2024
1 parent c6718ac commit fa06472
Show file tree
Hide file tree
Showing 14 changed files with 517 additions and 327 deletions.
7 changes: 5 additions & 2 deletions src/API/getRecentGames.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('getRecentGames (raw)', 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
const data = await client.getRecentGames('14727faefbdc4aff848cd2713eb9939e', { raw: true });
const data = await client.getRecentGames('add71246c46e455c8345c129ea6f146c', { raw: true });
expect(data).toBeDefined();
expectTypeOf(data).toEqualTypeOf<object>();
client.destroy();
Expand All @@ -25,7 +25,7 @@ test('getRecentGames', 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
const data = await client.getRecentGames('14727faefbdc4aff848cd2713eb9939e');
const data = await client.getRecentGames('add71246c46e455c8345c129ea6f146c');
expect(data).toBeDefined();
expectTypeOf(data).toEqualTypeOf<RecentGame[]>();
data.forEach((game: RecentGame) => {
Expand All @@ -48,6 +48,9 @@ test('getRecentGames', async () => {
expectTypeOf(game.endedAt).toEqualTypeOf<Date | null>();
expect(game.endedTimestamp).toBeDefined();
expectTypeOf(game.endedTimestamp).toEqualTypeOf<number | null>();
expect(game.toString()).toBeDefined();
expect(game.toString()).toEqual(game.mode);
expectTypeOf(game.toString()).toEqualTypeOf<string | null>();
});
client.destroy();
});
32 changes: 16 additions & 16 deletions src/API/getSkyblockAuction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test('getSkyblockAuction (No Query)', () => {
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
expect(() => client.getSkyblockAuction('player')).rejects.toThrowError(client.errors.NO_NICKNAME_UUID);
expect(() => client.getSkyblockAuction('player', '')).rejects.toThrowError(client.errors.NO_NICKNAME_UUID);
client.destroy();
});

Expand Down Expand Up @@ -103,18 +103,18 @@ test('getSkyblockAuction (Auction)', async () => {
expect(bid).toBeInstanceOf(Bid);
expectTypeOf(bid).toEqualTypeOf<Bid>();
expect(bid.auctionId).toBeDefined();
expectTypeOf(bid.auctionId).toEqualTypeOf<string | null>();
expectTypeOf(bid.auctionId).toEqualTypeOf<string>();
expect(bid.profileId).toBeDefined();
expectTypeOf(bid.profileId).toEqualTypeOf<string | null>();
expectTypeOf(bid.profileId).toEqualTypeOf<string>();
expect(bid.amount).toBeDefined();
expect(bid.amount).greaterThanOrEqual(0);
expectTypeOf(bid.amount).toEqualTypeOf<number>();
expect(bid.timestamp).toBeDefined();
expectTypeOf(bid.timestamp).toEqualTypeOf<number | null>();
expectTypeOf(bid.timestamp).toEqualTypeOf<number>();
expect(bid.at).toBeDefined();
expectTypeOf(bid.at).toEqualTypeOf<Date | null>();
expectTypeOf(bid.at).toEqualTypeOf<Date>();
expect(bid.bidder).toBeDefined();
expectTypeOf(bid.bidder).toEqualTypeOf<string | null>();
expectTypeOf(bid.bidder).toEqualTypeOf<string>();
expect(bid.toString()).toBeDefined();
expect(bid.toString()).toBe(`${bid.bidder} bid ${bid.amount} coins`);
expectTypeOf(bid.toString()).toEqualTypeOf<string>();
Expand Down Expand Up @@ -199,18 +199,18 @@ test('getSkyblockAuction (Player)', async () => {
expect(bid).toBeInstanceOf(Bid);
expectTypeOf(bid).toEqualTypeOf<Bid>();
expect(bid.auctionId).toBeDefined();
expectTypeOf(bid.auctionId).toEqualTypeOf<string | null>();
expectTypeOf(bid.auctionId).toEqualTypeOf<string>();
expect(bid.profileId).toBeDefined();
expectTypeOf(bid.profileId).toEqualTypeOf<string | null>();
expectTypeOf(bid.profileId).toEqualTypeOf<string>();
expect(bid.amount).toBeDefined();
expect(bid.amount).greaterThanOrEqual(0);
expectTypeOf(bid.amount).toEqualTypeOf<number>();
expect(bid.timestamp).toBeDefined();
expectTypeOf(bid.timestamp).toEqualTypeOf<number | null>();
expectTypeOf(bid.timestamp).toEqualTypeOf<number>();
expect(bid.at).toBeDefined();
expectTypeOf(bid.at).toEqualTypeOf<Date | null>();
expectTypeOf(bid.at).toEqualTypeOf<Date>();
expect(bid.bidder).toBeDefined();
expectTypeOf(bid.bidder).toEqualTypeOf<string | null>();
expectTypeOf(bid.bidder).toEqualTypeOf<string>();
expect(bid.toString()).toBeDefined();
expect(bid.toString()).toBe(`${bid.bidder} bid ${bid.amount} coins`);
expectTypeOf(bid.toString()).toEqualTypeOf<string>();
Expand Down Expand Up @@ -295,18 +295,18 @@ test('getSkyblockAuction (Profile)', async () => {
expect(bid).toBeInstanceOf(Bid);
expectTypeOf(bid).toEqualTypeOf<Bid>();
expect(bid.auctionId).toBeDefined();
expectTypeOf(bid.auctionId).toEqualTypeOf<string | null>();
expectTypeOf(bid.auctionId).toEqualTypeOf<string>();
expect(bid.profileId).toBeDefined();
expectTypeOf(bid.profileId).toEqualTypeOf<string | null>();
expectTypeOf(bid.profileId).toEqualTypeOf<string>();
expect(bid.amount).toBeDefined();
expect(bid.amount).greaterThanOrEqual(0);
expectTypeOf(bid.amount).toEqualTypeOf<number>();
expect(bid.timestamp).toBeDefined();
expectTypeOf(bid.timestamp).toEqualTypeOf<number | null>();
expectTypeOf(bid.timestamp).toEqualTypeOf<number>();
expect(bid.at).toBeDefined();
expectTypeOf(bid.at).toEqualTypeOf<Date | null>();
expectTypeOf(bid.at).toEqualTypeOf<Date>();
expect(bid.bidder).toBeDefined();
expectTypeOf(bid.bidder).toEqualTypeOf<string | null>();
expectTypeOf(bid.bidder).toEqualTypeOf<string>();
expect(bid.toString()).toBeDefined();
expect(bid.toString()).toBe(`${bid.bidder} bid ${bid.amount} coins`);
expectTypeOf(bid.toString()).toEqualTypeOf<string>();
Expand Down
27 changes: 25 additions & 2 deletions src/API/getSkyblockAuction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,38 @@ class getSkyblockAction extends Endpoint {
let filter;
if ('profile' === type) {
filter = 'profile';
} else if ('player' === type) {
} else if ('player' === type && query) {
query = await this.client.requests.toUUID(query);
filter = 'player';
} else if ('auction' === type) {
filter = 'uuid';
} else {
throw new Error(this.client.errors.BAD_AUCTION_FILTER);
}
if (!query) throw new Error(this.client.errors.NO_NICKNAME_UUID);
if (!query) {
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');

Check failure on line 30 in src/API/getSkyblockAuction.ts

View workflow job for this annotation

GitHub Actions / check linting (eslint)

Unexpected console statement
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');

Check failure on line 31 in src/API/getSkyblockAuction.ts

View workflow job for this annotation

GitHub Actions / check linting (eslint)

Unexpected console statement
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');

Check failure on line 32 in src/API/getSkyblockAuction.ts

View workflow job for this annotation

GitHub Actions / check linting (eslint)

Unexpected console statement
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');

Check failure on line 33 in src/API/getSkyblockAuction.ts

View workflow job for this annotation

GitHub Actions / check linting (eslint)

Unexpected console statement
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');

Check failure on line 34 in src/API/getSkyblockAuction.ts

View workflow job for this annotation

GitHub Actions / check linting (eslint)

Unexpected console statement
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');

Check failure on line 35 in src/API/getSkyblockAuction.ts

View workflow job for this annotation

GitHub Actions / check linting (eslint)

Unexpected console statement
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');

Check failure on line 36 in src/API/getSkyblockAuction.ts

View workflow job for this annotation

GitHub Actions / check linting (eslint)

Unexpected console statement
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');

Check failure on line 37 in src/API/getSkyblockAuction.ts

View workflow job for this annotation

GitHub Actions / check linting (eslint)

Unexpected console statement
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');

Check failure on line 38 in src/API/getSkyblockAuction.ts

View workflow job for this annotation

GitHub Actions / check linting (eslint)

Unexpected console statement
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');

Check failure on line 39 in src/API/getSkyblockAuction.ts

View workflow job for this annotation

GitHub Actions / check linting (eslint)

Unexpected console statement
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');
console.log('aaaaaaaaaaaaaaaaaaaaaaaaa');
throw new Error(this.client.errors.NO_NICKNAME_UUID);
}
const res = await this.client.requests.request(`/skyblock/auction?${filter}=${query}`, options);
if (res.options.raw) return res.data;
return res.data.auctions.map((a: any) => new Auction(a, options?.includeItemBytes ?? false));
Expand Down
30 changes: 15 additions & 15 deletions src/API/getSkyblockAuctions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ test('getSkyblockAuctions (One Page)', async () => {
expect(bid).toBeInstanceOf(Bid);
expectTypeOf(bid).toEqualTypeOf<Bid>();
expect(bid.auctionId).toBeDefined();
expectTypeOf(bid.auctionId).toEqualTypeOf<string | null>();
expectTypeOf(bid.auctionId).toEqualTypeOf<string>();
expect(bid.profileId).toBeDefined();
expectTypeOf(bid.profileId).toEqualTypeOf<string | null>();
expectTypeOf(bid.profileId).toEqualTypeOf<string>();
expect(bid.amount).toBeDefined();
expect(bid.amount).greaterThanOrEqual(0);
expectTypeOf(bid.amount).toEqualTypeOf<number>();
expect(bid.timestamp).toBeDefined();
expectTypeOf(bid.timestamp).toEqualTypeOf<number | null>();
expectTypeOf(bid.timestamp).toEqualTypeOf<number>();
expect(bid.at).toBeDefined();
expectTypeOf(bid.at).toEqualTypeOf<Date | null>();
expectTypeOf(bid.at).toEqualTypeOf<Date>();
expect(bid.bidder).toBeDefined();
expectTypeOf(bid.bidder).toEqualTypeOf<string | null>();
expectTypeOf(bid.bidder).toEqualTypeOf<string>();
expect(bid.toString()).toBeDefined();
expect(bid.toString()).toBe(`${bid.bidder} bid ${bid.amount} coins`);
expectTypeOf(bid.toString()).toEqualTypeOf<string>();
Expand Down Expand Up @@ -239,18 +239,18 @@ test('getSkyblockAuctions (One Page Include Item Bytes)', async () => {
expect(bid).toBeInstanceOf(Bid);
expectTypeOf(bid).toEqualTypeOf<Bid>();
expect(bid.auctionId).toBeDefined();
expectTypeOf(bid.auctionId).toEqualTypeOf<string | null>();
expectTypeOf(bid.auctionId).toEqualTypeOf<string>();
expect(bid.profileId).toBeDefined();
expectTypeOf(bid.profileId).toEqualTypeOf<string | null>();
expectTypeOf(bid.profileId).toEqualTypeOf<string>();
expect(bid.amount).toBeDefined();
expect(bid.amount).greaterThanOrEqual(0);
expectTypeOf(bid.amount).toEqualTypeOf<number>();
expect(bid.timestamp).toBeDefined();
expectTypeOf(bid.timestamp).toEqualTypeOf<number | null>();
expectTypeOf(bid.timestamp).toEqualTypeOf<number>();
expect(bid.at).toBeDefined();
expectTypeOf(bid.at).toEqualTypeOf<Date | null>();
expectTypeOf(bid.at).toEqualTypeOf<Date>();
expect(bid.bidder).toBeDefined();
expectTypeOf(bid.bidder).toEqualTypeOf<string | null>();
expectTypeOf(bid.bidder).toEqualTypeOf<string>();
expect(bid.toString()).toBeDefined();
expect(bid.toString()).toBe(`${bid.bidder} bid ${bid.amount} coins`);
expectTypeOf(bid.toString()).toEqualTypeOf<string>();
Expand Down Expand Up @@ -348,18 +348,18 @@ test('getSkyblockAuctions (All Pages)', async () => {
expect(bid).toBeInstanceOf(Bid);
expectTypeOf(bid).toEqualTypeOf<Bid>();
expect(bid.auctionId).toBeDefined();
expectTypeOf(bid.auctionId).toEqualTypeOf<string | null>();
expectTypeOf(bid.auctionId).toEqualTypeOf<string>();
expect(bid.profileId).toBeDefined();
expectTypeOf(bid.profileId).toEqualTypeOf<string | null>();
expectTypeOf(bid.profileId).toEqualTypeOf<string>();
expect(bid.amount).toBeDefined();
expect(bid.amount).greaterThanOrEqual(0);
expectTypeOf(bid.amount).toEqualTypeOf<number>();
expect(bid.timestamp).toBeDefined();
expectTypeOf(bid.timestamp).toEqualTypeOf<number | null>();
expectTypeOf(bid.timestamp).toEqualTypeOf<number>();
expect(bid.at).toBeDefined();
expectTypeOf(bid.at).toEqualTypeOf<Date | null>();
expectTypeOf(bid.at).toEqualTypeOf<Date>();
expect(bid.bidder).toBeDefined();
expectTypeOf(bid.bidder).toEqualTypeOf<string | null>();
expectTypeOf(bid.bidder).toEqualTypeOf<string>();
expect(bid.toString()).toBeDefined();
expect(bid.toString()).toBe(`${bid.bidder} bid ${bid.amount} coins`);
expectTypeOf(bid.toString()).toEqualTypeOf<string>();
Expand Down
34 changes: 10 additions & 24 deletions src/API/getSkyblockAuctionsByPlayer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,26 +108,19 @@ test('getSkyblockAuctionsByPlayer', async () => {
expect(bid).toBeDefined();
expect(bid).toBeInstanceOf(Bid);
expectTypeOf(bid).toEqualTypeOf<Bid>();

expect(bid.auctionId).toBeDefined();
expectTypeOf(bid.auctionId).toEqualTypeOf<string | null>();

expectTypeOf(bid.auctionId).toEqualTypeOf<string>();
expect(bid.profileId).toBeDefined();
expectTypeOf(bid.profileId).toEqualTypeOf<string | null>();

expectTypeOf(bid.profileId).toEqualTypeOf<string>();
expect(bid.amount).toBeDefined();
expect(bid.amount).greaterThanOrEqual(0);
expectTypeOf(bid.amount).toEqualTypeOf<number>();

expect(bid.timestamp).toBeDefined();
expectTypeOf(bid.timestamp).toEqualTypeOf<number | null>();

expectTypeOf(bid.timestamp).toEqualTypeOf<number>();
expect(bid.at).toBeDefined();
expectTypeOf(bid.at).toEqualTypeOf<Date | null>();

expectTypeOf(bid.at).toEqualTypeOf<Date>();
expect(bid.bidder).toBeDefined();
expectTypeOf(bid.bidder).toEqualTypeOf<string | null>();

expectTypeOf(bid.bidder).toEqualTypeOf<string>();
expect(bid.toString()).toBeDefined();
expect(bid.toString()).toBe(`${bid.bidder} bid ${bid.amount} coins`);
expectTypeOf(bid.toString()).toEqualTypeOf<string>();
Expand Down Expand Up @@ -230,26 +223,19 @@ test('getSkyblockAuctionsByPlayer (Item Bytes)', async () => {
expect(bid).toBeDefined();
expect(bid).toBeInstanceOf(Bid);
expectTypeOf(bid).toEqualTypeOf<Bid>();

expect(bid.auctionId).toBeDefined();
expectTypeOf(bid.auctionId).toEqualTypeOf<string | null>();

expectTypeOf(bid.auctionId).toEqualTypeOf<string>();
expect(bid.profileId).toBeDefined();
expectTypeOf(bid.profileId).toEqualTypeOf<string | null>();

expectTypeOf(bid.profileId).toEqualTypeOf<string>();
expect(bid.amount).toBeDefined();
expect(bid.amount).greaterThanOrEqual(0);
expectTypeOf(bid.amount).toEqualTypeOf<number>();

expect(bid.timestamp).toBeDefined();
expectTypeOf(bid.timestamp).toEqualTypeOf<number | null>();

expectTypeOf(bid.timestamp).toEqualTypeOf<number>();
expect(bid.at).toBeDefined();
expectTypeOf(bid.at).toEqualTypeOf<Date | null>();

expectTypeOf(bid.at).toEqualTypeOf<Date>();
expect(bid.bidder).toBeDefined();
expectTypeOf(bid.bidder).toEqualTypeOf<string | null>();

expectTypeOf(bid.bidder).toEqualTypeOf<string>();
expect(bid.toString()).toBeDefined();
expect(bid.toString()).toBe(`${bid.bidder} bid ${bid.amount} coins`);
expectTypeOf(bid.toString()).toEqualTypeOf<string>();
Expand Down
Loading

0 comments on commit fa06472

Please sign in to comment.