Skip to content

Commit

Permalink
fix(test): replace test with describe
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabb-c committed Jan 25, 2023
1 parent 4b5d1fe commit 3a32dff
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 62 deletions.
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@

echo "Linting files 📝"
pnpm lint-staged
echo "Running tests 📝"
pnpm test:ci
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"prepare": "is-ci || husky install",
"prepublishOnly": "pnpm build",
"sort": "sort-package-json package.json",
"test:ci": "vitest --run",
"test:ci": "vitest --silent --run",
"test:coverage": "vitest run --coverage",
"test:ui": "vitest --ui --api 9527",
"test:dev": "vitest -w --logHeapUsage --inspect"
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/berry.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test, it, beforeAll } from 'vitest';
import { expect, describe, it, beforeAll } from 'vitest';
import { Berry, BerryFirmness, BerryFlavor, NamedAPIResourceList } from '../models';
import { Berries, BerryFirmnesses, BerryFlavors } from '../constants';
import { BerryClient } from '../clients';
Expand All @@ -7,7 +7,7 @@ import { StatusCodes } from 'http-status-codes';

const aHugeNumber = 62_436_346;

test('Berry Client', () => {
describe('Berry Client', () => {
let client: BerryClient;
beforeAll(() => {
client = new BerryClient();
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/contest.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect, test, it, beforeAll } from 'vitest';
import { expect, describe, it, beforeAll } from 'vitest';
import { ContestEffect, ContestType, NamedAPIResourceList, SuperContestEffect } from '../models';
import { ContestClient } from '../clients';
import { ContestTypes } from '../constants';

test('Contest Client', () => {
describe('Contest Client', () => {
let client: ContestClient;
beforeAll(() => {
client = new ContestClient();
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/encounter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test, it, beforeAll } from 'vitest';
import { expect, describe, it, beforeAll } from 'vitest';
import {
EncounterCondition,
EncounterConditionValue,
Expand All @@ -8,7 +8,7 @@ import {
import { EncounterClient } from '../clients';
import { EncounterMethods, EncounterConditions, EncounterConditionValues } from '../constants';

test('Encounter Client', () => {
describe('Encounter Client', () => {
let client: EncounterClient;
beforeAll(() => {
client = new EncounterClient();
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/evolution.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect, test, it, beforeAll } from 'vitest';
import { expect, describe, it, beforeAll } from 'vitest';
import { EvolutionChain, EvolutionTrigger, NamedAPIResourceList } from '../models';
import { EvolutionTriggers } from '../constants';
import { EvolutionClient } from '../clients';

test('Evolution Client', () => {
describe('Evolution Client', () => {
let client: EvolutionClient;
beforeAll(() => {
client = new EvolutionClient();
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/game.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect, test, it, beforeAll } from 'vitest';
import { expect, describe, it, beforeAll } from 'vitest';
import { Generation, NamedAPIResourceList, Pokedex, Version, VersionGroup } from '../models';
import { Generations, Pokedexes, Versions, VersionGroups } from '../constants';
import { GameClient } from '../clients';

test('Game Client', () => {
describe('Game Client', () => {
let client: GameClient;
beforeAll(() => {
client = new GameClient();
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/item.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test, it, beforeAll } from 'vitest';
import { expect, describe, it, beforeAll } from 'vitest';
import {
Item,
ItemAttribute,
Expand All @@ -10,7 +10,7 @@ import {
import { ItemClient } from '../clients';
import { ItemCategories, ItemFlingEffects, ItemPockets } from '../constants';

test('Item Client', () => {
describe('Item Client', () => {
let client: ItemClient;
beforeAll(() => {
client = new ItemClient();
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/location.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect, test, it, beforeAll } from 'vitest';
import { expect, it, beforeAll, describe } from 'vitest';
import { Location, LocationArea, PalParkArea, Region, NamedAPIResourceList } from '../models';
import { PalParkAreas, Regions } from '../constants';
import { LocationClient } from '../clients';

test('Location Client', () => {
describe('Location Client', () => {
let client: LocationClient;
beforeAll(() => {
client = new LocationClient();
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/machine.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, test, it, beforeAll } from 'vitest';
import { expect, it, beforeAll, describe } from 'vitest';
import { Machine, NamedAPIResourceList } from '../models';
import { MachineClient } from '../clients';

test('Machine Client', () => {
describe('Machine Client', () => {
let client: MachineClient;
beforeAll(() => {
client = new MachineClient();
Expand Down
96 changes: 59 additions & 37 deletions src/__tests__/main.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test, it, beforeAll } from 'vitest';
import { expect, it, beforeAll, expectTypeOf, describe } from 'vitest';
import {
Berry,
ContestType,
Expand All @@ -18,84 +18,106 @@ import {
EvolutionTriggers,
Generations,
} from '../constants';
import { MainClient } from '../clients';
import * as Clients from '../clients';

test('MainClient Client', () => {
let client: MainClient;
describe('MainClient Client', () => {
let client: Clients.MainClient;
beforeAll(() => {
client = new MainClient();
client = new Clients.MainClient();
});

// Berry
// Main Client
it('check if the main client was instantiated correctly', () => {
expectTypeOf(client).toMatchTypeOf<Clients.MainClient>();
expectTypeOf(client.berry).toMatchTypeOf<Clients.BerryClient>();
expectTypeOf(client.contest).toMatchTypeOf<Clients.ContestClient>();
expectTypeOf(client.encounter).toMatchTypeOf<Clients.EncounterClient>();
expectTypeOf(client.evolution).toMatchTypeOf<Clients.EvolutionClient>();
expectTypeOf(client.game).toMatchTypeOf<Clients.GameClient>();
expectTypeOf(client.item).toMatchTypeOf<Clients.ItemClient>();
expectTypeOf(client.location).toMatchTypeOf<Clients.LocationClient>();
expectTypeOf(client.machine).toMatchTypeOf<Clients.MachineClient>();
expectTypeOf(client.move).toMatchTypeOf<Clients.MoveClient>();
expectTypeOf(client.pokemon).toMatchTypeOf<Clients.PokemonClient>();
});

// Berry Client
it('check if it returns a berry passig a name', async () => {
const data = await client.berry.getBerryByName('cheri').then((response: Berry) => response);
const data = await client.berry.getBerryByName('cheri');

expectTypeOf(data).toMatchTypeOf<Berry>();
expect(data.id).toBe(Berries.CHERI);
});
// Contest

// Contest Client
it('check if it returns a contest type passig a name', async () => {
const data = await client.contest
.getContestTypeByName('cool')
.then((response: ContestType) => response);
const data = await client.contest.getContestTypeByName('cool');

expectTypeOf(data).toMatchTypeOf<ContestType>();
expect(data.id).toBe(ContestTypes.COOL);
});
// Encounter

// Encounter Client
it('check if it returns an encounter method passig a name', async () => {
const data = await client.encounter
.getEncounterMethodByName('surf')
.then((response: EncounterMethod) => response);
const data = await client.encounter.getEncounterMethodByName('surf');

expectTypeOf(data).toMatchTypeOf<EncounterMethod>();
expect(data.id).toBe(EncounterMethods.SURF);
});
// Evolution

// Evolution Client
it('check if it returns an evolution trigger method passig a name', async () => {
const data = await client.evolution
.getEvolutionTriggerByName('shed')
.then((response: EvolutionTrigger) => response);
const data = await client.evolution.getEvolutionTriggerByName('shed');

expectTypeOf(data).toMatchTypeOf<EvolutionTrigger>();
expect(data.id).toBe(EvolutionTriggers.SHED);
});
// Game

// Game Client
it('check if it returns a generation method passig a name', async () => {
const data = await client.game
.getGenerationByName('generation-i')
.then((response: Generation) => response);
const data = await client.game.getGenerationByName('generation-i');

expectTypeOf(data).toMatchTypeOf<Generation>();
expect(data.id).toBe(Generations.GENERATION_I);
});
// Item

// Item Client
it('check if it returns an item passig a name', async () => {
const data = await client.item.getItemByName('master-ball').then((response: Item) => response);
const data = await client.item.getItemByName('master-ball');

expectTypeOf(data).toMatchTypeOf<Item>();
expect(data.id).toBe(1);
});
// Location

// Location Client
it('check if it returns a location passig a name', async () => {
const data = await client.location
.getLocationByName('canalave-city')
.then((response: Location) => response);
const data = await client.location.getLocationByName('canalave-city');

expectTypeOf(data).toMatchTypeOf<Location>();
expect(data.id).toBe(1);
});
// Machine

// Machine Client
it('check if it returns a machine passig an ID', async () => {
const data = await client.machine.getMachineById(1).then((response: Machine) => response);
const data = await client.machine.getMachineById(1);

expectTypeOf(data).toMatchTypeOf<Machine>();
expect(data.id).toBe(1);
});
// Move

// Move Client
it('check if it returns a move passig a name', async () => {
const data = await client.move.getMoveByName('pound').then((response: Move) => response);
const data = await client.move.getMoveById(1);

expectTypeOf(data).toMatchTypeOf<Move>();
expect(data.id).toBe(1);
});
// Pokemon

// Pokemon Client
it('check if it returns a pokemon passig a name', async () => {
const data = await client.pokemon
.getPokemonByName('luxray')
.then((response: Pokemon) => response);
const data = await client.pokemon.getPokemonByName('luxray');

expectTypeOf(data).toMatchTypeOf<Pokemon>();
expect(data.id).toBe(405);
});
});
4 changes: 2 additions & 2 deletions src/__tests__/move.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test, it, beforeAll } from 'vitest';
import { expect, it, beforeAll, describe } from 'vitest';
import {
Move,
MoveAilment,
Expand All @@ -19,7 +19,7 @@ import {
MoveTargets,
} from '../constants';

test('Move Client', () => {
describe('Move Client', () => {
let client: MoveClient;
beforeAll(() => {
client = new MoveClient();
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/pokemon.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test, it, beforeAll } from 'vitest';
import { expect, it, beforeAll, describe } from 'vitest';
import {
Ability,
Characteristic,
Expand Down Expand Up @@ -32,7 +32,7 @@ import {
} from '../constants';
import { PokemonClient } from '../clients';

test('Pokemon Client', () => {
describe('Pokemon Client', () => {
let client: PokemonClient;
beforeAll(() => {
client = new PokemonClient();
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/utility.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect, test, it, beforeAll } from 'vitest';
import { expect, it, beforeAll, describe } from 'vitest';
import { Language, NamedAPIResourceList, Pokemon } from '../models';
import { Languages } from '../constants';
import { UtilityClient } from '../clients';

test('Utility Client', () => {
describe('Utility Client', () => {
let client: UtilityClient;
beforeAll(() => {
client = new UtilityClient();
Expand Down
4 changes: 2 additions & 2 deletions src/structures/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export interface ClientArgs {
* ### Base Client
*/
export class BaseClient {
public api: AxiosCacheInstance;
private api: AxiosCacheInstance;

public logger: pino.Logger;
private logger: pino.Logger;

/**
*
Expand Down

0 comments on commit 3a32dff

Please sign in to comment.