
+
-
-
-
-
+
+

diff --git a/test/test.html.js b/test/test.html.js
index 8abb8a0..64f2007 100644
--- a/test/test.html.js
+++ b/test/test.html.js
@@ -1,876 +1,385 @@
-describe("service worker", function () {
- it("should be activated on second run", function () {
- const P = new Pokedex.Pokedex({cacheImages: true});
- return navigator.serviceWorker.getRegistrations().then(function(registrations) {
- const sw = registrations.filter(function(serviceworker) {
- return serviceworker.active.scriptURL.endsWith('pokeapi-js-wrapper-sw.js')
- });
- expect(sw).to.have.lengthOf(1)
- expect(sw[0].active.state).to.be.equal('activated')
- });
- });
-});
-
-describe("pokedex", function () {
- var id = 2;
- defaultP = new Pokedex.Pokedex();
- customP = new Pokedex.Pokedex({
- protocol: 'https',
- offset: 10,
- limit: 1,
- timeout: 10000,
- cache: false,
- cacheImages: false
- });
- this.timeout(5000);
-
- describe(".resource(Mixed: array)", function () {
- it("should have property name", function () {
- return customP.resource(['/api/v2/pokemon/36', 'api/v2/berry/8', 'https://pokeapi.co/api/v2/ability/9/']).then(res => {
- expect(res[0]).to.have.property('name');
- expect(res[1]).to.have.property('name');
- expect(res[2]).to.have.property('name');
- })
- });
- });
-
- describe(".resource(Path: string)", function () {
- it("should have property height", function () {
- return defaultP.resource('/api/v2/pokemon/34').then(res => {
- expect(res).to.have.property('height');
- })
- });
- });
-
- describe(".resource(Url: string)", function () {
- it("should have property height", function () {
- return defaultP.resource('https://pokeapi.co/api/v2/pokemon/400').then(res => {
- expect(res).to.have.property('height')
- })
- });
- });
-
- describe(".getVersionByName(Id: int)", function () {
- it("should have property name", function () {
- return defaultP.getVersionByName(id).then(res => {
- expect(res).to.have.property("name");
- })
- });
- });
-
- // start root endpoints
-
- describe(".getEndpointsList() secure (with ssl)", function() {
- it("should have property pokedex", function() {
- return defaultP.getEndpointsList().then(res => {
- expect(res).to.have.property("pokedex");
- })
- });
- });
-
- describe(".getBerriesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getBerriesList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getBerriesFirmnesssList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getBerriesFirmnesssList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getBerriesFlavorsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getBerriesFlavorsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getContestTypesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getContestTypesList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getContestEffectsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getContestEffectsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getSuperContestEffectsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getSuperContestEffectsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getEncounterMethodsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getEncounterMethodsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getEncounterConditionsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getEncounterConditionsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getEncounterConditionValuesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getEncounterConditionValuesList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getEvolutionChainsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getEvolutionChainsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getEvolutionTriggersList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getEvolutionTriggersList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getGenerationsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getGenerationsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getPokedexsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getPokedexsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getVersionsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getVersionsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getVersionGroupsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getVersionGroupsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getItemsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getItemsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getItemAttributesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getItemAttributesList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getItemCategoriesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getItemCategoriesList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getItemFlingEffectsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getItemFlingEffectsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getItemPocketsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getItemPocketsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getMachinesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getMachinesList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getMovesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getMovesList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getMoveAilmentsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getMoveAilmentsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getMoveBattleStylesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getMoveBattleStylesList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getMoveCategoriesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getMoveCategoriesList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getMoveDamageClassesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getMoveDamageClassesList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
-
- describe(".getMoveLearnMethodsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getMoveLearnMethodsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
+import { Pokedex } from '../src/index.js';
- describe(".getMoveTargetsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getMoveTargetsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
+mocha.setup('bdd');
+const expect = chai.expect;
+let P, defaultP, customP;
- describe(".getLocationsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getLocationsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
+describe("service worker", function () {
+ this.timeout(10000);
- describe(".getLocationAreasList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getLocationAreasList().then(res => {
- expect(res).to.have.property("count");
- })
- });
+ before(async function() {
+ P = await Pokedex.init({ cacheImages: true });
});
- describe(".getPalParkAreasList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getPalParkAreasList().then(res => {
- expect(res).to.have.property("count");
- })
- });
+ it("should be activated on second run", async function () {
+ const registrations = await navigator.serviceWorker.getRegistrations();
+ const sw = registrations.filter(serviceworker =>
+ serviceworker.active.scriptURL.endsWith('pokeapi-js-wrapper-sw.js')
+ );
+ expect(sw).to.have.lengthOf(1);
+ expect(sw[0].active.state).to.be.equal('activated');
});
+});
- describe(".getRegionsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getRegionsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
+describe("pokedex", function () {
+ this.timeout(30000);
- describe(".getAbilitiesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getAbilitiesList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
+ var id = 2;
- describe(".getCharacteristicsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getCharacteristicsList().then(res => {
- expect(res).to.have.property("count");
- })
+ before(async function() {
+ defaultP = await Pokedex.init();
+ customP = await Pokedex.init({
+ protocol: 'https',
+ offset: 10,
+ limit: 1,
+ timeout: 10000,
+ cache: false,
+ cacheImages: false
});
});
- describe(".getEggGroupsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getEggGroupsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
+ // --- Resource Methods ---
- describe(".getGendersList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getGendersList().then(res => {
- expect(res).to.have.property("count");
- })
+ describe(".resource(Mixed: array) not cached", function () {
+ it("should have property name", async function () {
+ const res = await customP.resource(['/api/v2/pokemon/36', 'api/v2/berry/8', 'https://pokeapi.co/api/v2/ability/9/']);
+ expect(res[0]).to.have.property('name');
+ expect(res[1]).to.have.property('name');
+ expect(res[2]).to.have.property('name');
});
});
- describe(".getGrowthRatesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getGrowthRatesList().then(res => {
- expect(res).to.have.property("count");
- })
+ describe(".resource(Path: string)", function () {
+ it("should have property height", async function () {
+ const res = await defaultP.resource('/api/v2/pokemon/34');
+ expect(res).to.have.property('height');
});
});
- describe(".getNaturesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getNaturesList().then(res => {
- expect(res).to.have.property("count");
- })
- });
+ describe(".resource(Url: string)", function () {
+ it("should have property height", async function () {
+ const res = await defaultP.resource('https://pokeapi.co/api/v2/pokemon/400');
+ expect(res).to.have.property('height');
+ });
+ });
+
+ // --- Root Endpoints ---
+
+ describe("Root Endpoints List", function() {
+ it(".getEndpointsList()", async () => expect(await defaultP.getEndpointsList()).to.have.property("pokedex"));
+ it(".getBerriesList()", async () => expect(await defaultP.getBerriesList()).to.have.property("count"));
+ it(".getBerriesFirmnesssList()", async () => expect(await defaultP.getBerriesFirmnesssList()).to.have.property("count"));
+ it(".getBerriesFlavorsList()", async () => expect(await defaultP.getBerriesFlavorsList()).to.have.property("count"));
+ it(".getContestTypesList()", async () => expect(await defaultP.getContestTypesList()).to.have.property("count"));
+ it(".getContestEffectsList()", async () => expect(await defaultP.getContestEffectsList()).to.have.property("count"));
+ it(".getSuperContestEffectsList()", async () => expect(await defaultP.getSuperContestEffectsList()).to.have.property("count"));
+ it(".getEncounterMethodsList()", async () => expect(await defaultP.getEncounterMethodsList()).to.have.property("count"));
+ it(".getEncounterConditionsList()", async () => expect(await defaultP.getEncounterConditionsList()).to.have.property("count"));
+ it(".getEncounterConditionValuesList()", async () => expect(await defaultP.getEncounterConditionValuesList()).to.have.property("count"));
+ it(".getEvolutionChainsList()", async () => expect(await defaultP.getEvolutionChainsList()).to.have.property("count"));
+ it(".getEvolutionTriggersList()", async () => expect(await defaultP.getEvolutionTriggersList()).to.have.property("count"));
+ it(".getGenerationsList()", async () => expect(await defaultP.getGenerationsList()).to.have.property("count"));
+ it(".getPokedexsList()", async () => expect(await defaultP.getPokedexsList()).to.have.property("count"));
+ it(".getVersionsList()", async () => expect(await defaultP.getVersionsList()).to.have.property("count"));
+ it(".getVersionGroupsList()", async () => expect(await defaultP.getVersionGroupsList()).to.have.property("count"));
+ it(".getItemsList()", async () => expect(await defaultP.getItemsList()).to.have.property("count"));
+ it(".getItemAttributesList()", async () => expect(await defaultP.getItemAttributesList()).to.have.property("count"));
+ it(".getItemCategoriesList()", async () => expect(await defaultP.getItemCategoriesList()).to.have.property("count"));
+ it(".getItemFlingEffectsList()", async () => expect(await defaultP.getItemFlingEffectsList()).to.have.property("count"));
+ it(".getItemPocketsList()", async () => expect(await defaultP.getItemPocketsList()).to.have.property("count"));
+ it(".getMachinesList()", async () => expect(await defaultP.getMachinesList()).to.have.property("count"));
+ it(".getMovesList()", async () => expect(await defaultP.getMovesList()).to.have.property("count"));
+ it(".getMoveAilmentsList()", async () => expect(await defaultP.getMoveAilmentsList()).to.have.property("count"));
+ it(".getMoveBattleStylesList()", async () => expect(await defaultP.getMoveBattleStylesList()).to.have.property("count"));
+ it(".getMoveCategoriesList()", async () => expect(await defaultP.getMoveCategoriesList()).to.have.property("count"));
+ it(".getMoveDamageClassesList()", async () => expect(await defaultP.getMoveDamageClassesList()).to.have.property("count"));
+ it(".getMoveLearnMethodsList()", async () => expect(await defaultP.getMoveLearnMethodsList()).to.have.property("count"));
+ it(".getMoveTargetsList()", async () => expect(await defaultP.getMoveTargetsList()).to.have.property("count"));
+ it(".getLocationsList()", async () => expect(await defaultP.getLocationsList()).to.have.property("count"));
+ it(".getLocationAreasList()", async () => expect(await defaultP.getLocationAreasList()).to.have.property("count"));
+ it(".getPalParkAreasList()", async () => expect(await defaultP.getPalParkAreasList()).to.have.property("count"));
+ it(".getRegionsList()", async () => expect(await defaultP.getRegionsList()).to.have.property("count"));
+ it(".getAbilitiesList()", async () => expect(await defaultP.getAbilitiesList()).to.have.property("count"));
+ it(".getCharacteristicsList()", async () => expect(await defaultP.getCharacteristicsList()).to.have.property("count"));
+ it(".getEggGroupsList()", async () => expect(await defaultP.getEggGroupsList()).to.have.property("count"));
+ it(".getGendersList()", async () => expect(await defaultP.getGendersList()).to.have.property("count"));
+ it(".getGrowthRatesList()", async () => expect(await defaultP.getGrowthRatesList()).to.have.property("count"));
+ it(".getNaturesList()", async () => expect(await defaultP.getNaturesList()).to.have.property("count"));
+ it(".getPokeathlonStatsList()", async () => expect(await defaultP.getPokeathlonStatsList()).to.have.property("count"));
+ it(".getPokemonsList()", async () => expect(await defaultP.getPokemonsList()).to.have.property("count"));
+ it(".getPokemonColorsList()", async () => expect(await defaultP.getPokemonColorsList()).to.have.property("count"));
+ it(".getPokemonFormsList()", async () => expect(await defaultP.getPokemonFormsList()).to.have.property("count"));
+ it(".getPokemonHabitatsList()", async () => expect(await defaultP.getPokemonHabitatsList()).to.have.property("count"));
+ it(".getPokemonShapesList()", async () => expect(await defaultP.getPokemonShapesList()).to.have.property("count"));
+ it(".getPokemonSpeciesList()", async () => expect(await defaultP.getPokemonSpeciesList()).to.have.property("count"));
+ it(".getStatsList()", async () => expect(await defaultP.getStatsList()).to.have.property("count"));
+ it(".getTypesList()", async () => expect(await defaultP.getTypesList()).to.have.property("count"));
+ it(".getLanguagesList()", async () => expect(await defaultP.getLanguagesList()).to.have.property("count"));
});
- describe(".getPokeathlonStatsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getPokeathlonStatsList().then(res => {
- expect(res).to.have.property("count");
- })
- });
- });
+ // --- Normal Data Calls ---
- describe(".getPokemonsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getPokemonsList().then(res => {
- expect(res).to.have.property("count");
- })
+ describe("Data Retrieval by Name/ID", function() {
+ it(".getBerryByName(Array: string)", async function() {
+ const res = await defaultP.getBerryByName(['cheri', 'chesto', 'pecha']);
+ expect(res).to.have.length(3);
});
- });
- describe(".getPokemonColorsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getPokemonColorsList().then(res => {
- expect(res).to.have.property("count");
- })
+ it(".getBerryByName(Array: int)", async function () {
+ const res = await defaultP.getBerryByName([1, 3, 5]);
+ expect(res).to.have.length(3);
});
- });
- describe(".getPokemonFormsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getPokemonFormsList().then(res => {
- expect(res).to.have.property("count");
- })
+ it(".getPokemonByName(Array: int)", async function() {
+ const res = await defaultP.getPokemonByName([15, 35, 433, 444]);
+ expect(res).to.have.length(4);
});
- });
- describe(".getPokemonHabitatsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getPokemonHabitatsList().then(res => {
- expect(res).to.have.property("count");
- })
+ it(".getBerryByName(Id: int)", async function() {
+ const res = await defaultP.getBerryByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getPokemonShapesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getPokemonShapesList().then(res => {
- expect(res).to.have.property("count");
- })
+ it(".getBerryFirmnessByName(Id: int)", async function() {
+ const res = await defaultP.getBerryFirmnessByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getPokemonSpeciesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getPokemonSpeciesList().then(res => {
- expect(res).to.have.property("count");
- })
+ it(".getBerryFlavorByName(Id: int)", async function() {
+ const res = await defaultP.getBerryFlavorByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getStatsList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getStatsList().then(res => {
- expect(res).to.have.property("count");
- })
+ it(".getContestTypeByName(Id: int)", async function() {
+ const res = await defaultP.getContestTypeByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getTypesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getTypesList().then(res => {
- expect(res).to.have.property("count");
- })
+ it(".getContestEffectById(Id: int)", async function() {
+ const res = await defaultP.getContestEffectById(id);
+ expect(res).to.have.property("id");
});
- });
- describe(".getLanguagesList() secure (with ssl)", function() {
- it("should have property count", function() {
- return defaultP.getLanguagesList().then(res => {
- expect(res).to.have.property("count");
- })
+ it(".getSuperContestEffectById(Id: int)", async function() {
+ const res = await defaultP.getSuperContestEffectById(id);
+ expect(res).to.have.property("id");
});
- });
- // end root endpoints
-
- // start normals calls
-
- describe(".getBerryByName(Array: string)", function() {
- it("should have length 3", function() {
- return defaultP.getBerryByName(['cheri', 'chesto', 'pecha']).then(res => {
- expect(res).to.have.length(3);
- })
+ it(".getEncounterMethodByName(Id: int)", async function() {
+ const res = await defaultP.getEncounterMethodByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getBerryByName(Array: int)", function() {
- it("should have length 3", function () {
- return defaultP.getBerryByName([1, 3, 5]).then(res => {
- expect(res).to.have.length(3);
- })
+ it(".getEncounterConditionByName(Id: int)", async function() {
+ const res = await defaultP.getEncounterConditionByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getPokemonByName(Array: int)", function() {
- it("should have length 4", function() {
- return defaultP.getPokemonByName([15, 35, 433, 444]).then(res => {
- expect(res).to.have.length(4);
- })
+ it(".getEncounterConditionValueByName(Id: int)", async function() {
+ const res = await defaultP.getEncounterConditionValueByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getBerryByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getBerryByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getEvolutionChainById(Id: int)", async function() {
+ const res = await defaultP.getEvolutionChainById(id);
+ expect(res).to.have.property("id");
});
- });
- describe(".getBerryByName(Id: int) cached", function() {
- it("should have property name", function() {
- return defaultP.getBerryByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getEvolutionTriggerByName(Id: int)", async function() {
+ const res = await defaultP.getEvolutionTriggerByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getBerryFirmnessByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getBerryFirmnessByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getGenerationByName(Id: int)", async function() {
+ const res = await defaultP.getGenerationByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getBerryFlavorByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getBerryFlavorByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getPokedexByName(Id: int)", async function() {
+ const res = await defaultP.getPokedexByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getContestTypeByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getContestTypeByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getVersionByName(Id: int)", async function() {
+ const res = await defaultP.getVersionByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getContestEffectById(Id: int)", function() {
- it("should have property id", function() {
- return defaultP.getContestEffectById(id).then(res => {
- expect(res).to.have.property("id");
- })
+ it(".getVersionGroupByName(Id: int)", async function() {
+ const res = await defaultP.getVersionGroupByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getSuperContestEffectById(Id: int)", function() {
- it("should have property id", function() {
- return defaultP.getSuperContestEffectById(id).then(res => {
- expect(res).to.have.property("id");
- })
+ it(".getItemByName(Id: int)", async function() {
+ const res = await defaultP.getItemByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getEncounterMethodByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getEncounterMethodByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getItemAttributeByName(Id: int)", async function() {
+ const res = await defaultP.getItemAttributeByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getEncounterConditionByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getEncounterConditionByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getItemCategoryByName(Id: int)", async function() {
+ const res = await defaultP.getItemCategoryByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getEncounterConditionValueByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getEncounterConditionValueByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getItemFlingEffectByName(Id: int)", async function() {
+ const res = await defaultP.getItemFlingEffectByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getEvolutionChainById(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getEvolutionChainById(id).then(res => {
- expect(res).to.have.property("id");
- })
+ it(".getItemPocketByName(Id: int)", async function() {
+ const res = await defaultP.getItemPocketByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getEvolutionTriggerByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getEvolutionTriggerByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getMachineById(Id: int)", async function() {
+ const res = await defaultP.getMachineById(id);
+ expect(res).to.have.property("id");
});
- });
- describe(".getGenerationByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getGenerationByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getMoveByName(Id: int)", async function() {
+ const res = await defaultP.getMoveByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getPokedexByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getPokedexByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getMoveAilmentByName(Id: int)", async function() {
+ const res = await defaultP.getMoveAilmentByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getVersionByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getVersionByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getMoveBattleStyleByName(Id: int)", async function() {
+ const res = await defaultP.getMoveBattleStyleByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getVersionGroupByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getVersionGroupByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getMoveCategoryByName(Id: int)", async function() {
+ const res = await defaultP.getMoveCategoryByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getItemByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getItemByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getMoveDamageClassByName(Id: int)", async function() {
+ const res = await defaultP.getMoveDamageClassByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getItemAttributeByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getItemAttributeByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getMoveTargetByName(Id: int)", async function() {
+ const res = await defaultP.getMoveTargetByName(id);
+ expect(res).to.have.property("name");
});
- });
-
- describe(".getItemCategoryByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getItemCategoryByName(id).then(res => {
- expect(res).to.have.property("name");
- })
- });
- });
-
- describe(".getItemFlingEffectByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getItemFlingEffectByName(id).then(res => {
- expect(res).to.have.property("name");
- })
- });
- });
-
- describe(".getItemPocketByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getItemPocketByName(id).then(res => {
- expect(res).to.have.property("name");
- })
- });
- });
-
- describe(".getMachineById(Id: int)", function() {
- it("should have property id", function() {
- return defaultP.getMachineById(id).then(res => {
- expect(res).to.have.property("id");
- })
- });
- });
- describe(".getMoveByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getMoveByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getLocationByName(Id: int)", async function() {
+ const res = await defaultP.getLocationByName(id);
+ expect(res).to.have.property("name");
});
- });
-
- describe(".getMoveAilmentByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getMoveAilmentByName(id).then(res => {
- expect(res).to.have.property("name");
- })
- });
- });
-
- describe(".getMoveBattleStyleByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getMoveBattleStyleByName(id).then(res => {
- expect(res).to.have.property("name");
- })
- });
- });
-
- describe(".getMoveCategoryByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getMoveCategoryByName(id).then(res => {
- expect(res).to.have.property("name");
- })
- });
- });
-
- describe(".getMoveDamageClassByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getMoveDamageClassByName(id).then(res => {
- expect(res).to.have.property("name");
- })
- });
- });
- describe(".getMoveTargetByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getMoveTargetByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getLocationAreaByName(Id: int)", async function() {
+ const res = await defaultP.getLocationAreaByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getLocationByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getLocationByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getPalParkAreaByName(Id: int)", async function() {
+ const res = await defaultP.getPalParkAreaByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getLocationAreaByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getLocationAreaByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getRegionByName(Id: int)", async function() {
+ const res = await defaultP.getRegionByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getPalParkAreaByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getPalParkAreaByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getAbilityByName(Id: int)", async function() {
+ const res = await defaultP.getAbilityByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getRegionByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getRegionByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getCharacteristicById(Id: int)", async function() {
+ const res = await defaultP.getCharacteristicById(id);
+ expect(res).to.have.property("id");
});
- });
- describe(".getAbilityByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getAbilityByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getEggGroupByName(Id: int)", async function() {
+ const res = await defaultP.getEggGroupByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getCharacteristicById(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getCharacteristicById(id).then(res => {
- expect(res).to.have.property("id");
- })
+ it(".getGenderByName(Id: int)", async function() {
+ const res = await defaultP.getGenderByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getEggGroupByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getEggGroupByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getGrowthRateByName(Id: int)", async function() {
+ const res = await defaultP.getGrowthRateByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getGenderByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getGenderByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getNatureByName(Id: int)", async function() {
+ const res = await defaultP.getNatureByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getGrowthRateByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getGrowthRateByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getPokeathlonStatByName(Id: int)", async function() {
+ const res = await defaultP.getPokeathlonStatByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getNatureByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getNatureByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getPokemonByName(Id: int)", async function() {
+ const res = await defaultP.getPokemonByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getPokeathlonStatByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getPokeathlonStatByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getPokemonColorByName(Id: int)", async function() {
+ const res = await defaultP.getPokemonColorByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getPokemonByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getPokemonByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getPokemonFormByName(Id: int)", async function() {
+ const res = await defaultP.getPokemonFormByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getPokemonColorByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getPokemonColorByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getPokemonHabitatByName(Id: int)", async function() {
+ const res = await defaultP.getPokemonHabitatByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getPokemonFormByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getPokemonFormByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getPokemonShapeByName(Id: int)", async function() {
+ const res = await defaultP.getPokemonShapeByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getPokemonHabitatByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getPokemonHabitatByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getPokemonSpeciesByName(Id: int)", async function() {
+ const res = await defaultP.getPokemonSpeciesByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getPokemonShapeByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getPokemonShapeByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getStatByName(Id: int)", async function() {
+ const res = await defaultP.getStatByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getPokemonSpeciesByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getPokemonSpeciesByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getTypeByName(Id: int)", async function() {
+ const res = await defaultP.getTypeByName(id);
+ expect(res).to.have.property("name");
});
- });
- describe(".getStatByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getStatByName(id).then(res => {
- expect(res).to.have.property("name");
- })
+ it(".getLanguageByName(Id: int)", async function() {
+ const res = await defaultP.getLanguageByName(id);
+ expect(res).to.have.property("name");
});
});
+});
- describe(".getTypeByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getTypeByName(id).then(res => {
- expect(res).to.have.property("name");
- })
- });
- });
+const button = document.getElementById('flush-cache-btn');
- describe(".clearCache()", function () {
- it("should clear all cached entries", function () {
- return defaultP.clearCache().then(res => {
- defaultP.getCacheLength().then(length => {
- expect(length).to.be.equal(0);
- })
- })
- });
- });
+button.addEventListener('click', async () => {
+ try {
+ await defaultP.clearCache();
+ } catch (error) {
+ console.error(error);
+ }
+});
- describe(".getLanguageByName(Id: int)", function() {
- it("should have property name", function() {
- return defaultP.getLanguageByName(id).then(res => {
- expect(res).to.have.property("name");
- })
- });
- });
-});
+mocha.run();
\ No newline at end of file
diff --git a/test/test.js b/test/test.js
index a722b1e..db51b9e 100644
--- a/test/test.js
+++ b/test/test.js
@@ -1,1364 +1,52 @@
-//var localStorage = require('localStorage');
-var Pokedex = require("../dist/index.js");
-var chai = require('chai'),
- expect = chai.expect,
- assert = chai.assert;
-chai.use(require("chai-things"));
-chai.use(require("chai-as-promised"));
-
-global.navigator = {
- userAgent: 'node.js'
-};
-
-global.window = {
- userAgent: 'node.js'
-};
-
-describe("pokedex", function () {
- var promise,
- id = 2,
- path = '/api/v2/pokemon/34',
- url = 'https://pokeapi.co/api/v2/pokemon/35',
- secureP = new Pokedex.Pokedex({cacheImages: true}),
- P = new Pokedex.Pokedex({
+import { Pokedex } from "../src/index.js";
+import { describe, it, before } from "node:test";
+import assert from "node:assert/strict";
+
+describe("pokedex", { timeout: 30000 }, function () {
+ let p1;
+ let p2;
+
+ const id = 2;
+ const path = '/api/v2/pokemon/34';
+ const url = 'https://pokeapi.co/api/v2/pokemon/35';
+ const interval = { limit: 10, offset: 34 };
+
+ before(async function () {
+ p1 = await Pokedex.init({ cacheImages: false });
+ p2 = await Pokedex.init({
protocol: 'https',
offset: 10,
limit: 1,
timeout: 10000,
cache: false
- }),
- interval = {
- limit: 10,
- offset: 34
- }
-
- this.timeout(21000);
-
- describe("P.getPokemonsList(interval: Interval) with default interval", function () {
- it("should succeed", function () {
- P.getPokemonsList().then(function(res) {
- expect(res).to.have.property('results');
- expect(res.results).to.have.lengthOf(1);
- expect(res.results[0].name).to.be.equal("caterpie");
- expect(res.results[0].name).not.to.be.equal("metapod");
- });
});
});
+ // --- Utility Methods ---
describe(".getConfig()", function () {
it("should return protocol property", function () {
- let config = P.getConfig()
- expect(config).to.have.property('protocol');
- });
- });
-
- describe(".getPokemonsList(interval: Interval) with interval", function () {
- before(function () {
- promise = secureP.getPokemonsList(interval);
- });
- it("should succeed", function () {
- return promise;
- });
- it("should have length results", function() {
- return expect(promise).to.eventually.have.property('results');
- });
- });
-
- describe(".clearCache()", function () {
- it("should clear all cached entries", function () {
- return P.clearCache().then(res => {
- P.getCacheLength().then(length => {
- expect(length).to.be.equal(0);
- })
- })
- });
- });
-
- describe(".resource(Mixed: array)", function () {
- before(function () {
- promise = secureP.resource(['/api/v2/pokemon/36', 'api/v2/berry/8', 'https://pokeapi.co/api/v2/ability/9/']);
- });
- it("should succeed", function () {
- return promise;
- });
- it("should have length 3", function() {
- return expect(promise).to.eventually.have.length(3);
- });
- it("should have property name", function () {
- return expect(promise).to.eventually.all.have.property('name');
- });
- });
-
- describe(".resource(Path: string)", function () {
- before(function () {
- promise = secureP.resource(path);
- });
- it("should succeed", function () {
- return promise;
- });
- it("should have property height", function () {
- return expect(promise).to.eventually.have.property('height');
- });
- });
-
- describe(".resource(Url: string)", function () {
- before(function () {
- promise = secureP.resource(url);
- });
- it("should succeed", function () {
- return promise;
- });
- it("should have property height", function () {
- return expect(promise).to.eventually.have.property('height')
- });
- });
-
- describe(".getPokemonEncounterAreasByName(Id: int)", function () {
- before(function () {
- promise = secureP.getPokemonEncounterAreasByName(id);
- });
- it("should succeed", function () {
- return promise;
- });
- it("should be an array", function () {
- return expect(promise).to.eventually.be.an("array");
- });
- });
-
- describe(".getVersionByName(Id: int)", function () {
- before(function () {
- promise = secureP.getVersionByName(id);
- });
- it("should succeed", function () {
- return promise;
- });
- it("should have property name", function () {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- // start root endpoints
-
- describe(".getEndpointsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getEndpointsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property pokedex", function() {
- return expect(promise).to.eventually.have.property("pokedex");
- });
- });
-
- describe(".getBerriesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getBerriesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getBerriesFirmnesssList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getBerriesFirmnesssList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getBerriesFlavorsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getBerriesFlavorsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getContestTypesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getContestTypesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getContestEffectsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getContestEffectsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getSuperContestEffectsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getSuperContestEffectsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getEncounterMethodsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getEncounterMethodsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getEncounterConditionsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getEncounterConditionsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getEncounterConditionValuesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getEncounterConditionValuesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getEvolutionChainsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getEvolutionChainsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getEvolutionTriggersList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getEvolutionTriggersList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getGenerationsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getGenerationsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getPokedexsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getPokedexsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getVersionsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getVersionsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getVersionGroupsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getVersionGroupsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getItemsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getItemsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getItemAttributesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getItemAttributesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getItemCategoriesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getItemCategoriesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getItemFlingEffectsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getItemFlingEffectsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getItemPocketsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getItemPocketsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getMachinesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getMachinesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getMovesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getMovesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getMoveAilmentsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getMoveAilmentsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getMoveBattleStylesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getMoveBattleStylesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getMoveCategoriesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getMoveCategoriesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getMoveDamageClassesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getMoveDamageClassesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getMoveLearnMethodsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getMoveLearnMethodsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getMoveTargetsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getMoveTargetsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getLocationsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getLocationsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getLocationAreasList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getLocationAreasList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getPalParkAreasList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getPalParkAreasList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getRegionsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getRegionsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getAbilitiesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getAbilitiesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getCharacteristicsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getCharacteristicsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getEggGroupsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getEggGroupsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getGendersList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getGendersList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getGrowthRatesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getGrowthRatesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getNaturesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getNaturesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getPokeathlonStatsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getPokeathlonStatsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
+ // p2 is now guaranteed to be initialized here
+ const config = p2.getConfig();
+ assert.ok(Object.hasOwn(config, 'protocol'), "Config should have protocol");
});
});
- describe(".getPokemonsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getPokemonsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getPokemonColorsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getPokemonColorsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getPokemonFormsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getPokemonFormsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
+ // --- List Methods ---
+ describe(".getPokemonsList()", function () {
+ it("should succeed with default interval", async function () {
+ const res = await p2.getPokemonsList();
+ assert.ok(res.results, "Response should have results");
+ assert.strictEqual(res.results.length, 1);
});
});
- describe(".getPokemonHabitatsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getPokemonHabitatsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
+ // --- Failure Cases ---
+ describe("Error Handling", function () {
+ it("should fail when getting a non-existent berry", async function () {
+ await assert.rejects(
+ p1.getBerryByName('non-existent-berry'),
+ Error
+ );
});
});
-
- describe(".getPokemonShapesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getPokemonShapesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getPokemonSpeciesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getPokemonSpeciesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getStatsList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getStatsList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getTypesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getTypesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- describe(".getLanguagesList() secure (with ssl)", function() {
- before(function() {
- promise = secureP.getLanguagesList();
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property count", function() {
- return expect(promise).to.eventually.have.property("count");
- });
- });
-
- // end root endpoints
-
- // start normals calls
-
- describe(".getBerryByName(Array: string)", function() {
- before(function() {
- promise = secureP.getBerryByName(['cheri', 'chesto', 'pecha']);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have length 3", function() {
- return expect(promise).to.eventually.have.length(3);
- });
- it("berries should have property growth_time", function() {
- return expect(promise).to.eventually.all.have.property('growth_time');
- });
- });
-
- describe(".getBerryByName(Array: int)", function() {
- before(function() {
- promise = secureP.getBerryByName([1, 3, 5]);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have length 3", function() {
- return expect(promise).to.eventually.have.length(3);
- });
- it("berries should have property growth_time", function() {
- return expect(promise).to.eventually.all.have.property('growth_time');
- });
- });
-
- describe(".getPokemonByName(Array: int)", function() {
- before(function() {
- promise = secureP.getPokemonByName([15, 35, 433, 444]);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have length 4", function() {
- return expect(promise).to.eventually.have.length(4);
- });
- it("pokemons should have property height", function() {
- return expect(promise).to.eventually.all.have.property('height');
- });
- });
-
- describe(".getBerryByName(Id: int)", function() {
- before(function() {
- promise = secureP.getBerryByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getBerryByName(Id: int) cached", function() {
- before(function() {
- promise = secureP.getBerryByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getBerryFirmnessByName(Id: int)", function() {
- before(function() {
- promise = secureP.getBerryFirmnessByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getBerryFlavorByName(Id: int)", function() {
- before(function() {
- promise = secureP.getBerryFlavorByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getContestTypeByName(Id: int)", function() {
- before(function() {
- promise = secureP.getContestTypeByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getContestEffectById(Id: int)", function() {
- before(function() {
- promise = secureP.getContestEffectById(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property id", function() {
- return expect(promise).to.eventually.have.property("id");
- });
- });
-
- describe(".getSuperContestEffectById(Id: int)", function() {
- before(function() {
- promise = secureP.getSuperContestEffectById(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property id", function() {
- return expect(promise).to.eventually.have.property("id");
- });
- });
-
- describe(".getEncounterMethodByName(Id: int)", function() {
- before(function() {
- promise = secureP.getEncounterMethodByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getEncounterConditionByName(Id: int)", function() {
- before(function() {
- promise = secureP.getEncounterConditionByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getEncounterConditionValueByName(Id: int)", function() {
- before(function() {
- promise = secureP.getEncounterConditionValueByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getEvolutionChainById(Id: int)", function() {
- before(function() {
- promise = secureP.getEvolutionChainById(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("id");
- });
- });
-
- describe(".getEvolutionTriggerByName(Id: int)", function() {
- before(function() {
- promise = secureP.getEvolutionTriggerByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getGenerationByName(Id: int)", function() {
- before(function() {
- promise = secureP.getGenerationByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getPokedexByName(Id: int)", function() {
- before(function() {
- promise = secureP.getPokedexByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getVersionByName(Id: int)", function() {
- before(function() {
- promise = secureP.getVersionByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getVersionGroupByName(Id: int)", function() {
- before(function() {
- promise = secureP.getVersionGroupByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getItemByName(Id: int)", function() {
- before(function() {
- promise = secureP.getItemByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getItemAttributeByName(Id: int)", function() {
- before(function() {
- promise = secureP.getItemAttributeByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getItemCategoryByName(Id: int)", function() {
- before(function() {
- promise = secureP.getItemCategoryByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getItemFlingEffectByName(Id: int)", function() {
- before(function() {
- promise = secureP.getItemFlingEffectByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getItemPocketByName(Id: int)", function() {
- before(function() {
- promise = secureP.getItemPocketByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getMachineById(Id: int)", function() {
- before(function() {
- promise = secureP.getMachineById(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property id", function() {
- return expect(promise).to.eventually.have.property("id");
- });
- });
-
- describe(".getMoveByName(Id: int)", function() {
- before(function() {
- promise = secureP.getMoveByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getMoveAilmentByName(Id: int)", function() {
- before(function() {
- promise = secureP.getMoveAilmentByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getMoveBattleStyleByName(Id: int)", function() {
- before(function() {
- promise = secureP.getMoveBattleStyleByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getMoveCategoryByName(Id: int)", function() {
- before(function() {
- promise = secureP.getMoveCategoryByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getMoveDamageClassByName(Id: int)", function() {
- before(function() {
- promise = secureP.getMoveDamageClassByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getMoveTargetByName(Id: int)", function() {
- before(function() {
- promise = secureP.getMoveTargetByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getLocationByName(Id: int)", function() {
- before(function() {
- promise = secureP.getLocationByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getLocationAreaByName(Id: int)", function() {
- before(function() {
- promise = secureP.getLocationAreaByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getPalParkAreaByName(Id: int)", function() {
- before(function() {
- promise = secureP.getPalParkAreaByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getRegionByName(Id: int)", function() {
- before(function() {
- promise = secureP.getRegionByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getAbilityByName(Id: int)", function() {
- before(function() {
- promise = secureP.getAbilityByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getCharacteristicById(Id: int)", function() {
- before(function() {
- promise = secureP.getCharacteristicById(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("id");
- });
- });
-
- describe(".getEggGroupByName(Id: int)", function() {
- before(function() {
- promise = secureP.getEggGroupByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getGenderByName(Id: int)", function() {
- before(function() {
- promise = secureP.getGenderByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getGrowthRateByName(Id: int)", function() {
- before(function() {
- promise = secureP.getGrowthRateByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getNatureByName(Id: int)", function() {
- before(function() {
- promise = secureP.getNatureByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getPokeathlonStatByName(Id: int)", function() {
- before(function() {
- promise = secureP.getPokeathlonStatByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getPokemonByName(Id: int)", function() {
- before(function() {
- promise = secureP.getPokemonByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getPokemonColorByName(Id: int)", function() {
- before(function() {
- promise = secureP.getPokemonColorByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getPokemonFormByName(Id: int)", function() {
- before(function() {
- promise = secureP.getPokemonFormByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getPokemonHabitatByName(Id: int)", function() {
- before(function() {
- promise = secureP.getPokemonHabitatByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getPokemonShapeByName(Id: int)", function() {
- before(function() {
- promise = secureP.getPokemonShapeByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getPokemonSpeciesByName(Id: int)", function() {
- before(function() {
- promise = secureP.getPokemonSpeciesByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getStatByName(Id: int)", function() {
- before(function() {
- promise = secureP.getStatByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getTypeByName(Id: int)", function() {
- before(function() {
- promise = secureP.getTypeByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getLanguageByName(Id: int)", function() {
- before(function() {
- promise = secureP.getLanguageByName(id);
- });
- it("should succeed", function() {
- return promise;
- });
- it("should have property name", function() {
- return expect(promise).to.eventually.have.property("name");
- });
- });
-
- describe(".getBerryByName(Name: string)", function() {
- before(function() {
- promise = secureP.getBerryByName('sfgfsgsfggsfg');
- });
- it("should fail", function() {
- return expect(promise).rejected;
- });
- });
-
-});
+});
\ No newline at end of file
diff --git a/webpack.config.js b/webpack.config.js
deleted file mode 100644
index a65c85e..0000000
--- a/webpack.config.js
+++ /dev/null
@@ -1,33 +0,0 @@
-const path = require('path');
-const webpack = require('webpack');
-const CopyPlugin = require('copy-webpack-plugin');
-
-module.exports = {
- entry: './src/index.js',
- target: 'web',
- devtool: 'source-map',
- output: {
- path: path.resolve(__dirname, 'dist'),
- filename: 'index.js',
- libraryTarget: 'umd',
- library: 'Pokedex',
- globalObject: `(typeof self !== 'undefined' ? self : this)`
- },
- mode: 'production',
- plugins: [
- new CopyPlugin({
- patterns: [
- {
- from: 'src/pokeapi-js-wrapper-sw.js',
- to: 'pokeapi-js-wrapper-sw.js',
- toType: 'file'
- },
- {
- from: 'src/pokeapi-js-wrapper-sw.js',
- to: '../test/pokeapi-js-wrapper-sw.js',
- toType: 'file'
- }
- ]
- })
- ]
-};