Skip to content

Commit

Permalink
fix(constants): remove enums for readonly consts
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabb-c committed Jun 21, 2023
1 parent 084af0e commit 483252a
Show file tree
Hide file tree
Showing 34 changed files with 927 additions and 924 deletions.
13 changes: 7 additions & 6 deletions src/__tests__/berry.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BerryClient } from "../clients";
import { Berries, BerryFirmnesses, BerryFlavors } from "../constants";
import { BERRIES, BERRY_FIRMNESSES, BERRY_FLAVORS } from "../constants";
import { Berry, BerryFirmness, BerryFlavor, NamedAPIResourceList } from "../models";
import { assertType, beforeAll, describe, expect, expectTypeOf, it } from "vitest";

Expand All @@ -20,11 +20,11 @@ describe("Berry Client", () => {
const data = await client.getBerryByName("cheri");

expectTypeOf(data).toEqualTypeOf<Berry>();
expect(data.id).toBe(Berries.CHERI);
expect(data.id).toBe(BERRIES.CHERI);
});

it("check if it returns a berry passing an ID", async () => {
const data = await client.getBerryById(Berries.CHERI);
const data = await client.getBerryById(BERRIES.CHERI);

expectTypeOf(data).toEqualTypeOf<Berry>();
expect(data.name).toBe("cheri");
Expand All @@ -45,7 +45,7 @@ describe("Berry Client", () => {
});

it("check if it returns a berry firmness passing an ID", async () => {
const data = await client.getBerryFirmnessById(BerryFirmnesses.VERY_SOFT);
const data = await client.getBerryFirmnessById(BERRY_FIRMNESSES.VERY_SOFT);

expectTypeOf(data).toEqualTypeOf<BerryFirmness>();
expect(data.name).toBe("very-soft");
Expand All @@ -56,18 +56,19 @@ describe("Berry Client", () => {

expectTypeOf(data).toEqualTypeOf<NamedAPIResourceList>();
expect(data.results.length).toBeGreaterThan(0);
expect(data.results.length).toBeLessThanOrEqual(20);
});

// Berry Flavor
it("check if it returns a berry flavor passig a name", async () => {
const data = await client.getBerryFlavorByName("spicy");

expectTypeOf(data).toEqualTypeOf<BerryFlavor>();
expect(data.id).toBe(BerryFlavors.SPICY);
expect(data.id).toBe(BERRY_FLAVORS.SPICY);
});

it("check if it returns a berry flavor passing an ID", async () => {
const data = await client.getBerryFlavorById(BerryFlavors.SPICY);
const data = await client.getBerryFlavorById(BERRY_FLAVORS.SPICY);

expectTypeOf(data).toEqualTypeOf<BerryFlavor>();
expect(data.name).toBe("spicy");
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/contest.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ContestClient } from "../clients";
import { ContestTypes } from "../constants";
import { CONTEST_TYPES } from "../constants";
import { ContestEffect, ContestType, NamedAPIResourceList, SuperContestEffect } from "../models";
import { beforeAll, describe, expect, expectTypeOf, it } from "vitest";

Expand All @@ -19,11 +19,11 @@ describe("Contest Client", () => {
const data = await client.getContestTypeByName("cool");

expectTypeOf(data).toEqualTypeOf<ContestType>();
expect(data.id).toBe(ContestTypes.COOL);
expect(data.id).toBe(CONTEST_TYPES.COOL);
});

it("check if it returns a contest type passing an ID", async () => {
const data = await client.getContestTypeById(ContestTypes.COOL);
const data = await client.getContestTypeById(CONTEST_TYPES.COOL);

expectTypeOf(data).toEqualTypeOf<ContestType>();
expect(data.name).toBe("cool");
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/encounter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EncounterClient } from "../clients";
import { EncounterConditionValues, EncounterConditions, EncounterMethods } from "../constants";
import { ENCOUNTER_CONDITIONS, ENCOUNTER_CONDITION_VALUES, ENCOUNTER_METHODS } from "../constants";
import {
EncounterCondition,
EncounterConditionValue,
Expand All @@ -24,11 +24,11 @@ describe("Encounter Client", () => {
const data = await client.getEncounterMethodByName("walk");

expectTypeOf(data).toEqualTypeOf<EncounterMethod>();
expect(data.id).toBe(EncounterMethods.WALK);
expect(data.id).toBe(ENCOUNTER_METHODS.WALK);
});

it("check if it returns an encounter method passig an id", async () => {
const data = await client.getEncounterMethodById(EncounterMethods.WALK);
const data = await client.getEncounterMethodById(ENCOUNTER_METHODS.WALK);

expectTypeOf(data).toEqualTypeOf<EncounterMethod>();
expect(data.name).toBe("walk");
Expand All @@ -46,11 +46,11 @@ describe("Encounter Client", () => {
const data = await client.getEncounterConditionByName("swarm");

expectTypeOf(data).toEqualTypeOf<EncounterCondition>();
expect(data.id).toBe(EncounterConditions.SWARM);
expect(data.id).toBe(ENCOUNTER_CONDITIONS.SWARM);
});

it("check if it returns an encounter condition passig an id", async () => {
const data = await client.getEncounterConditionById(EncounterConditions.SWARM);
const data = await client.getEncounterConditionById(ENCOUNTER_CONDITIONS.SWARM);

expectTypeOf(data).toEqualTypeOf<EncounterCondition>();
expect(data.name).toBe("swarm");
Expand All @@ -68,11 +68,11 @@ describe("Encounter Client", () => {
const data = await client.getEncounterConditionValueByName("swarm-yes");

expectTypeOf(data).toEqualTypeOf<EncounterConditionValue>();
expect(data.id).toBe(EncounterConditionValues.SWARM_YES);
expect(data.id).toBe(ENCOUNTER_CONDITION_VALUES.SWARM_YES);
});

it("check if it returns an encounter condition values passig an id", async () => {
const data = await client.getEncounterConditionValueById(EncounterConditionValues.SWARM_YES);
const data = await client.getEncounterConditionValueById(ENCOUNTER_CONDITION_VALUES.SWARM_YES);

expectTypeOf(data).toEqualTypeOf<EncounterConditionValue>();
expect(data.name).toBe("swarm-yes");
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/evolution.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EvolutionClient } from "../clients";
import { EvolutionTriggers } from "../constants";
import { EVOLUTION_TRIGGERS } from "../constants";
import { EvolutionChain, EvolutionTrigger, NamedAPIResourceList } from "../models";
import { beforeAll, describe, expect, expectTypeOf, it } from "vitest";

Expand All @@ -16,7 +16,7 @@ describe("Evolution Client", () => {

// Evolution Trigger
it("check if it returns an evolution trigger passig an ID", async () => {
const data = await client.getEvolutionTriggerById(EvolutionTriggers.LEVEL_UP);
const data = await client.getEvolutionTriggerById(EVOLUTION_TRIGGERS.LEVEL_UP);

expectTypeOf(data).toEqualTypeOf<EvolutionTrigger>();
expect(data.name).toBe("level-up");
Expand All @@ -26,7 +26,7 @@ describe("Evolution Client", () => {
const data = await client.getEvolutionTriggerByName("level-up");

expectTypeOf(data).toEqualTypeOf<EvolutionTrigger>();
expect(data.id).toBe(EvolutionTriggers.LEVEL_UP);
expect(data.id).toBe(EVOLUTION_TRIGGERS.LEVEL_UP);
});

it("check if it returns a list of evolution triggers", async () => {
Expand Down
21 changes: 10 additions & 11 deletions src/__tests__/game.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GameClient } from "../clients";
import { Generations, Pokedexes, VersionGroups, Versions } from "../constants";
import { GENERATIONS, POKEDEXES, VERSIONS, VERSION_GROUPS } from "../constants";
import { Generation, NamedAPIResourceList, Pokedex, Version, VersionGroup } from "../models";
import { beforeAll, describe, expect, expectTypeOf, it } from "vitest";

Expand All @@ -19,34 +19,33 @@ describe("Game Client", () => {
const data = await client.getGenerationByName("generation-i");

expectTypeOf(data).toEqualTypeOf<Generation>();
expect(data.id).toBe(Generations.GENERATION_I);
expect(data.id).toBe(GENERATIONS.GENERATION_I);
});

it("check if it returns a generation passing an ID", async () => {
const data = await client.getGenerationById(Generations.GENERATION_I);
const data = await client.getGenerationById(GENERATIONS.GENERATION_I);

expectTypeOf(data).toEqualTypeOf<Generation>();
expect(data.name).toBe("generation-i");
});

it("check if it returns a list of generations", async (ctx) => {
it("check if it returns a list of generations", async () => {
const data = await client.listGenerations();

expectTypeOf(data).toEqualTypeOf<NamedAPIResourceList>();
expect(data.results.length).toBeGreaterThan(0);
ctx.onTestFailed((error) => console.error(error));
});

// Pokedex
it("check if it returns a pokedex passig a name", async () => {
const data = await client.getPokedexByName("national");

expectTypeOf(data).toEqualTypeOf<Pokedex>();
expect(data.id).toBe(Pokedexes.NATIONAL);
expect(data.id).toBe(POKEDEXES.NATIONAL);
});

it("check if it returns a pokedex passing an ID", async () => {
const data = await client.getPokedexById(Pokedexes.NATIONAL);
const data = await client.getPokedexById(POKEDEXES.NATIONAL);

expectTypeOf(data).toEqualTypeOf<Pokedex>();
expect(data.name).toBe("national");
Expand All @@ -64,11 +63,11 @@ describe("Game Client", () => {
const data = await client.getVersionByName("red");

expectTypeOf(data).toEqualTypeOf<Version>();
expect(data.id).toBe(Versions.RED);
expect(data.id).toBe(VERSIONS.RED);
});

it("check if it returns a version passing an ID", async () => {
const data = await client.getVersionById(Versions.RED);
const data = await client.getVersionById(VERSIONS.RED);

expectTypeOf(data).toEqualTypeOf<Version>();
expect(data.name).toBe("red");
Expand All @@ -86,11 +85,11 @@ describe("Game Client", () => {
const data = await client.getVersionGroupByName("red-blue");

expectTypeOf(data).toEqualTypeOf<VersionGroup>();
expect(data.id).toBe(VersionGroups.RED_BLUE);
expect(data.id).toBe(VERSION_GROUPS.RED_BLUE);
});

it("check if it returns a version group passing an ID", async () => {
const data = await client.getVersionGroupById(VersionGroups.RED_BLUE);
const data = await client.getVersionGroupById(VERSION_GROUPS.RED_BLUE);

expectTypeOf(data).toEqualTypeOf<VersionGroup>();
expect(data.name).toBe("red-blue");
Expand Down
12 changes: 6 additions & 6 deletions src/__tests__/item.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ItemClient } from "../clients";
import { ItemCategories, ItemFlingEffects, ItemPockets } from "../constants";
import { ITEM_CATEGORIES, ITEM_FLING_EFFECTS, ITEM_POCKETS } from "../constants";
import {
Item,
ItemAttribute,
Expand Down Expand Up @@ -75,7 +75,7 @@ describe("Item Client", () => {
});

it("check if it returns an item category passing an ID", async () => {
const data = await client.getItemCategoryById(ItemCategories.CHOICE);
const data = await client.getItemCategoryById(ITEM_CATEGORIES.CHOICE);

expectTypeOf(data).toEqualTypeOf<ItemCategory>();
expect(data.name).toBe("choice");
Expand All @@ -93,11 +93,11 @@ describe("Item Client", () => {
const data = await client.getItemFlingEffectByName("flinch");

expectTypeOf(data).toEqualTypeOf<ItemFlingEffect>();
expect(data.id).toBe(ItemFlingEffects.FLINCH);
expect(data.id).toBe(ITEM_FLING_EFFECTS.FLINCH);
});

it("check if it returns an item fling effect passing an ID", async () => {
const data = await client.getItemFlingEffectById(ItemFlingEffects.FLINCH);
const data = await client.getItemFlingEffectById(ITEM_FLING_EFFECTS.FLINCH);

expectTypeOf(data).toEqualTypeOf<ItemFlingEffect>();
expect(data.name).toBe("flinch");
Expand All @@ -115,11 +115,11 @@ describe("Item Client", () => {
const data = await client.getItemPocketByName("battle");

expectTypeOf(data).toEqualTypeOf<ItemPocket>();
expect(data.id).toBe(ItemPockets.BATTLE);
expect(data.id).toBe(ITEM_POCKETS.BATTLE);
});

it("check if it returns an item pocket passing an ID", async () => {
const data = await client.getItemPocketById(ItemPockets.BATTLE);
const data = await client.getItemPocketById(ITEM_POCKETS.BATTLE);

expectTypeOf(data).toEqualTypeOf<ItemPocket>();
expect(data.name).toBe("battle");
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/location.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LocationClient } from "../clients";
import { PalParkAreas, Regions } from "../constants";
import { PAL_PARK_AREAS, REGIONS } from "../constants";
import { Location, LocationArea, NamedAPIResourceList, PalParkArea, Region } from "../models";
import { beforeAll, describe, expect, expectTypeOf, it } from "vitest";

Expand Down Expand Up @@ -63,11 +63,11 @@ describe("Location Client", () => {
const data = await client.getPalParkAreaByName("forest");

expectTypeOf(data).toEqualTypeOf<PalParkArea>();
expect(data.id).toBe(PalParkAreas.FOREST);
expect(data.id).toBe(PAL_PARK_AREAS.FOREST);
});

it("check if it returns a pal park area passing an ID", async () => {
const data = await client.getPalParkAreaById(PalParkAreas.FOREST);
const data = await client.getPalParkAreaById(PAL_PARK_AREAS.FOREST);

expectTypeOf(data).toEqualTypeOf<PalParkArea>();
expect(data.name).toBe("forest");
Expand All @@ -85,11 +85,11 @@ describe("Location Client", () => {
const data = await client.getRegionByName("kanto");

expectTypeOf(data).toEqualTypeOf<Region>();
expect(data.id).toBe(Regions.KANTO);
expect(data.id).toBe(REGIONS.KANTO);
});

it("check if it returns a region passing an ID", async () => {
const data = await client.getRegionById(Regions.KANTO);
const data = await client.getRegionById(REGIONS.KANTO);

expectTypeOf(data).toEqualTypeOf<Region>();
expect(data.name).toBe("kanto");
Expand Down
20 changes: 10 additions & 10 deletions src/__tests__/main.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as Clients from "../clients";
import {
Berries,
ContestTypes,
EncounterMethods,
EvolutionTriggers,
Generations,
BERRIES,
CONTEST_TYPES,
ENCOUNTER_METHODS,
EVOLUTION_TRIGGERS,
GENERATIONS,
} from "../constants";
import {
Berry,
Expand Down Expand Up @@ -46,39 +46,39 @@ describe("MainClient Client", () => {
const data = await client.berry.getBerryByName("cheri");

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

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

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

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

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

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

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

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

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

// Item Client
Expand Down

0 comments on commit 483252a

Please sign in to comment.