Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

95% code test coverage #51

Merged
merged 56 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
23f7c8d
tests
Kathund Aug 23, 2024
5c85542
firesale
Kathund Aug 23, 2024
f69a8f5
fix
Kathund Aug 23, 2024
0df61db
im going to die
Kathund Aug 24, 2024
e22f498
fix
Kathund Aug 24, 2024
ffadfad
fix
Kathund Aug 24, 2024
31c4acb
Games
Kathund Aug 24, 2024
427dc76
Color
Kathund Aug 24, 2024
0d7ec2d
misc change
Kathund Aug 24, 2024
45c937f
coco -> cocoa
Kathund Aug 24, 2024
a31314a
Rewrite Member Stats
Kathund Aug 24, 2024
9dc09ad
feat(getPlayer): add getplayer never logged in test
Zickles Aug 25, 2024
159016b
Clean tests
Kathund Aug 26, 2024
8ffb639
Check coverage
Kathund Aug 26, 2024
d223f94
Merge branch 'master' into test
Kathund Aug 26, 2024
ea82d55
fix
Kathund Aug 26, 2024
81539e1
better testing
Kathund Aug 26, 2024
c6718ac
Merge branch 'master' into test
Kathund Aug 27, 2024
fa06472
Meow
Kathund Aug 27, 2024
13c99fb
code
Kathund Aug 27, 2024
5c58074
fix formatting
Kathund Aug 28, 2024
f563304
Booster Test
Kathund Aug 28, 2024
aa5d33d
meow
Kathund Aug 28, 2024
97ad8e8
MeowWWW
Kathund Aug 28, 2024
00f16c5
Test
Kathund Aug 28, 2024
a74acc5
Merge branch 'master' into test
Kathund Aug 28, 2024
9ab6c15
meow meow meow
Kathund Aug 29, 2024
1d0b71d
Testers
Kathund Aug 30, 2024
c6a1533
fix
Kathund Aug 30, 2024
d95ee42
feat(tests): add mock data for firesales
Zickles Aug 30, 2024
f435ef8
90% testers
Kathund Aug 30, 2024
5d4f6f1
Merge branch 'test' of https://github.com/hypixel-api-reborn/reborn-t…
Kathund Aug 30, 2024
56aeac1
Change Data
Kathund Aug 30, 2024
3c4c0a9
Move WatchdogStats
Kathund Aug 30, 2024
69ba633
fix idiot
Kathund Aug 30, 2024
213f623
Bazaar
Kathund Aug 30, 2024
8f7a13a
Replace Usernames With UUID
Kathund Aug 31, 2024
95a8274
Move coverageCheck.ts
Kathund Aug 31, 2024
da17826
Merge branch 'master' into test
Kathund Aug 31, 2024
5991166
Coverage Check change
Kathund Aug 31, 2024
5a5b3fc
i hate my life. Please end it now fucking cunt
Kathund Aug 31, 2024
c3e9991
update(skills): taming cap
Zickles Aug 31, 2024
f7a8be8
Merge branch 'master' into test
Kathund Sep 1, 2024
a3c2899
Tests
Kathund Sep 1, 2024
24a0bd1
Testersssszzszszszszsz 95% go brrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr…
Kathund Sep 1, 2024
c0e325b
Merge branch 'master' into test
Kathund Sep 2, 2024
4323d3a
Merge branch 'master' into test
Kathund Sep 3, 2024
ed2c234
Merge branch 'master' into test
Kathund Sep 3, 2024
ffe9e4b
Merge branch 'master' into test
Kathund Sep 4, 2024
5e32966
code i think
Kathund Sep 4, 2024
b9d704a
Fix Urls
Kathund Sep 4, 2024
4c4d589
Merge branch 'master' into test
Kathund Sep 6, 2024
d65e5c5
Run coverage with tests
Kathund Sep 6, 2024
3c80edb
WoolGames
Kathund Sep 6, 2024
c83dee3
Merge branch 'master' into test
Kathund Sep 7, 2024
93e7d41
Ducky So Skilled
Kathund Sep 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/checkCoverage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { parseString } from 'xml2js';
import { readFile } from 'fs';

function parseXMLFile(): Promise<any> {
return new Promise((resolve, reject) => {
readFile('.github/coverageData.xml', 'utf8', (err, data) => {
if (err) {
reject('File Dose not exist!');
return;
}

parseString(data, (err, result) => {
if (err) {
reject('Something Went wrong!');
return;
}

resolve(result);
});
});
});
}

const data = await parseXMLFile();
const codeStats = data.coverage.project[0].metrics[0].$;
const info = {
statements: Number(codeStats.statements),
coveredstatements: Number(codeStats.coveredstatements),
conditionals: Number(codeStats.conditionals),
coveredconditionals: Number(codeStats.coveredconditionals),
methods: Number(codeStats.methods),
coveredmethods: Number(codeStats.coveredmethods)
};

if (95 > (info.coveredstatements / info.statements) * 100) {
throw new Error('Statements is required to be 95% or higher');
}

if (95 > (info.coveredconditionals / info.conditionals) * 100) {
throw new Error('Conditionals is required to be 95% or higher');
}

if (95 > (info.coveredmethods / info.methods) * 100) {
throw new Error('Methods is required to be 95% or higher');
}

if (
95 >
((info.coveredstatements + info.coveredconditionals + info.coveredmethods) /
(info.statements + info.conditionals + info.methods)) *
100
) {
throw new Error('Everythng Combinded is required to be 95% or higher');
}
8 changes: 7 additions & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,10 @@ jobs:
- name: Check tests
env:
HYPIXEL_KEY: ${{ secrets.HYPIXEL_KEY }}
run: pnpm test
run: pnpm test:coverage

- name: Move Coverage Data
run: mv coverage/clover.xml .github/coverageData.xml

- name: Check Coverage
run: npx tsx .github/checkCoverage.ts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ oldreborn/
dist/
.eslintcache
coverage/
.github/coverageData.xml
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ oldreborn/
.eslintcache
.git
.gitignore
coverage/
coverage/
.github/coverageData.xml
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"prettier": "npx prettier --write src/",
"build": "npx tsc",
"test": "npx vitest run",
"test:coverage": "npx vitest --ui --coverage"
"test:coverage": "npx vitest run --coverage",
"test:ui": "npx vitest --ui --coverage"
},
"engines": {
"node": ">=20.16.0"
Expand Down Expand Up @@ -52,6 +53,7 @@
"@j4cobi/eslint-plugin-sort-imports": "^1.0.2",
"@types/eslint": "^9.6.1",
"@types/node": "^20.16.5",
"@types/xml2js": "^0.4.14",
"@vitest/coverage-v8": "^2.0.5",
"@vitest/ui": "^2.0.5",
"dotenv": "^16.4.5",
Expand All @@ -61,6 +63,7 @@
"prettier": "^3.3.3",
"typescript": "^5.5.4",
"typescript-eslint": "^8.4.0",
"vitest": "^2.0.5"
"vitest": "^2.0.5",
"xml2js": "^0.6.2"
}
}
22 changes: 22 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/API/API.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ export interface SkyblockRequestOptions extends RequestOptions {
garden?: boolean;
museum?: boolean;
}

export type GuildFetchOptions = 'id' | 'name' | 'player';
4 changes: 2 additions & 2 deletions src/API/getAchievements.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { StaticGameNames } from '../typings';
import { expect, expectTypeOf, test } from 'vitest';

test('getAchievements (raw)', async () => {
const client = new Client(process.env.HYPIXEL_KEY ?? '', { cache: false, checkForUpdates: false });
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.getAchievements({ raw: true });
Expand All @@ -17,7 +17,7 @@ test('getAchievements (raw)', async () => {
});

test('getAchievements', async () => {
const client = new Client(process.env.HYPIXEL_KEY ?? '', { cache: false, checkForUpdates: false });
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.getAchievements();
Expand Down
8 changes: 4 additions & 4 deletions src/API/getActiveHouses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import House from '../structures/House';
import { expect, expectTypeOf, test } from 'vitest';

test('getActiveHouses (raw)', async () => {
const client = new Client(process.env.HYPIXEL_KEY ?? '', { cache: false, checkForUpdates: false });
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.getActiveHouses({ raw: true });
Expand All @@ -13,7 +13,7 @@ test('getActiveHouses (raw)', async () => {
});

test('getActiveHouses', async () => {
const client = new Client(process.env.HYPIXEL_KEY ?? '', { cache: false, checkForUpdates: false });
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.getActiveHouses();
Expand All @@ -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
29 changes: 25 additions & 4 deletions src/API/getBoosters.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Booster from '../structures/Boosters/Booster';
import Client from '../Client';
import Game from '../structures/Game';
import Game, { GameCode, GameID, GameString } from '../structures/Game';
import { expect, expectTypeOf, test } from 'vitest';

test('getBoosters (raw)', async () => {
const client = new Client(process.env.HYPIXEL_KEY ?? '', { cache: false, checkForUpdates: false });
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.getBoosters({ raw: true });
Expand All @@ -14,7 +14,7 @@ test('getBoosters (raw)', async () => {
});

test('getBoosters', async () => {
const client = new Client(process.env.HYPIXEL_KEY ?? '', { cache: false, checkForUpdates: false });
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.getBoosters();
Expand All @@ -37,7 +37,28 @@ test('getBoosters', async () => {
expect(booster.activated).toBeDefined();
expectTypeOf(booster.activated).toEqualTypeOf<Date>();
expect(booster.game).toBeDefined();
expectTypeOf(booster.game).toEqualTypeOf<Game | null>();
expectTypeOf(booster.game).toEqualTypeOf<Game>();
expect(booster.game).toBeDefined();
expectTypeOf(booster.game).toEqualTypeOf<Game>();
expect(booster.game.game).toBeDefined();
expectTypeOf(booster.game.game).toEqualTypeOf<GameID | GameCode>();
expect(booster.game.id).toBeDefined();
expectTypeOf(booster.game.id).toEqualTypeOf<GameID | null>();
expect(booster.game.code).toBeDefined();
expectTypeOf(booster.game.code).toEqualTypeOf<GameCode | null>();
expect(booster.game.name).toBeDefined();
expectTypeOf(booster.game.name).toEqualTypeOf<GameString | null>();
expect(booster.game.found).toBeDefined();
expectTypeOf(booster.game.found).toEqualTypeOf<boolean>();
expect(booster.game.toString()).toBeDefined();
expect(booster.game.toString()).toBe(booster.game.name);
expectTypeOf(booster.game.toString()).toEqualTypeOf<GameString | null>();
expect(Game.IDS).toBeDefined();
expectTypeOf(Game.IDS).toEqualTypeOf<GameID[]>();
expect(Game.CODES).toBeDefined();
expectTypeOf(Game.CODES).toEqualTypeOf<GameCode[]>();
expect(Game.NAMES).toBeDefined();
expectTypeOf(Game.NAMES).toEqualTypeOf<GameString[]>();
expect(booster.isActive).toBeDefined();
expectTypeOf(booster.isActive).toEqualTypeOf<boolean>();
expect(booster.type).toBeDefined();
Expand Down
4 changes: 2 additions & 2 deletions src/API/getChallenges.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { StaticGameNames } from '../typings';
import { expect, expectTypeOf, test } from 'vitest';

test('getChallenges (raw)', async () => {
const client = new Client(process.env.HYPIXEL_KEY ?? '', { cache: false, checkForUpdates: false });
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.getChallenges({ raw: true });
Expand All @@ -15,7 +15,7 @@ test('getChallenges (raw)', async () => {
});

test('getChallenges', async () => {
const client = new Client(process.env.HYPIXEL_KEY ?? '', { cache: false, checkForUpdates: false });
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.getChallenges();
Expand Down
4 changes: 2 additions & 2 deletions src/API/getGameCounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import GameCounts from '../structures/GameCounts';
import { expect, expectTypeOf, test } from 'vitest';

test('getGameCounts (raw)', async () => {
const client = new Client(process.env.HYPIXEL_KEY ?? '', { cache: false, checkForUpdates: false });
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.getGameCounts({ raw: true });
Expand All @@ -13,7 +13,7 @@ test('getGameCounts (raw)', async () => {
});

test('getGameCounts', async () => {
const client = new Client(process.env.HYPIXEL_KEY ?? '', { cache: false, checkForUpdates: false });
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.getGameCounts();
Expand Down
Loading
Loading