Skip to content

Commit 3157b12

Browse files
committed
Added test to the README
1 parent 5a47307 commit 3157b12

3 files changed

Lines changed: 42 additions & 28 deletions

File tree

README.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![npm version](https://badge.fury.io/js/pokeapi-js-wrapper.svg)](https://badge.fury.io/js/pokeapi-js-wrapper)
44
[![Build Status](https://travis-ci.org/PokeAPI/pokeapi-js-wrapper.svg?branch=master)](https://travis-ci.org/PokeAPI/pokeapi-js-wrapper)
5+
[![Mocha browser tetst](https://img.shields.io/badge/test-browser-brightgreen.svg)](https://pokeapi.github.io/pokeapi-js-wrapper/test/test.html)
56
[![Ghit.me](https://ghit.me/badge.svg?repo=PokeAPI/pokeapi-js-wrapper)](https://ghit.me/repo/PokeAPI/pokeapi-js-wrapper)
67

78
A PokeAPI wrapper intended for browsers only. Comes fully asynchronous (with [localForage](https://github.com/localForage/localForage)) and built-in cache. For a Node (server-side) wrapper see: [pokedex-promise-v2](https://github.com/PokeAPI/pokedex-promise-v2)
@@ -14,6 +15,7 @@ A PokeAPI wrapper intended for browsers only. Comes fully asynchronous (with [lo
1415
- [Usage](#usage)
1516
- [Example requests](#example-requests)
1617
- [Configuration](#configuration)
18+
- [Tests](#tests)
1719
- [Endpoints](#endpoints)
1820
- [Berries](#berries)
1921
- [Contests](#contests)
@@ -28,39 +30,37 @@ A PokeAPI wrapper intended for browsers only. Comes fully asynchronous (with [lo
2830
- [Utility](#utility)
2931
- [Root Endpoints](#root-endpoints)
3032
- [List of supported root endpoints](#list-of-supported-root-endpoints)
33+
- [Internet Explorer 8](#internet-explorer-8)
3134

3235
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
3336

3437
## Install
3538

3639
![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Internet_Explorer_10_logo.svg/48px-Internet_Explorer_10_logo.svg.png) |
3740
--- | --- | --- | --- | --- | --- |
38-
✔ | ✔ | ✔ | ✔ | ✔ | 8+ ✔ |
39-
40-
You can install with Npm!
41+
✔ | ✔ | ✔ | ✔ | ✔ | [8+](#internet-explorer-8) ✔ |
4142

4243
```shell
4344
npm install pokeapi-js-wrapper
4445
```
4546

4647
## Usage
4748

48-
4949
```js
5050
var Pokedex = require('pokeapi-js-wrapper');
5151
var P = new Pokedex.Pokedex();
5252
```
5353

5454
```html
5555
<script src="https://unpkg.com/pokeapi-js-wrapper/dist/index.js"></script>
56-
<script>var P = new Pokedex.Pokedex();</script>
56+
<script> var P = new Pokedex.Pokedex(); </script>
5757
```
5858

5959
**NOTE**: Any function with the designation "ByName" can also be passed an integer ID. However, the functions with the designation "ById" can only be passed an integer ID. Refer to the [pokeapi v2 docs](http://pokeapi.co/docsv2/) to find out more about how the data is structured.
6060

6161
**UPDATE**: You can pass an array to each endpoint, it will retrive data for each array element. If you scroll down, you will find an example.
6262

63-
### Example requests
63+
### [Example](http://jsbin.com/jedakor/edit?html,console) requests
6464

6565
```js
6666
P.getPokemonByName('eevee') // with Promise
@@ -82,11 +82,21 @@ var options = {
8282
hostName: 'localhost:443',
8383
versionPath: '/api/v2/',
8484
cache: true,
85-
tiemout: 5 * 1000 // 5s
85+
timeout: 5 * 1000 // 5s
8686
}
8787
var P = new Pokedex.Pokedex(options);
8888
```
8989

90+
## Tests
91+
92+
`pokeapi-js-wrapper` can be tested using two strategies. One is with Node, since this package works even with Node (altough not recommended), and the other with a browser.
93+
94+
```js
95+
npm test
96+
```
97+
98+
Or open `/test/test.html` in your browser. A live version can be found at [`gh-pages`](https://pokeapi.github.io/pokeapi-js-wrapper/test/test.html)
99+
90100
## Endpoints
91101

92102
### Berries
@@ -658,3 +668,7 @@ This is what you will get:
658668
- .getStatsList()
659669
- .getTypesList()
660670
- .getLanguagesList()
671+
672+
## Internet Explorer 8
673+
674+
In order to target this browser if must load a Promise polyfill before `pokeapi-js-wrapper`. You can choose one of your chioce, we recommed [jakearchibald/es6-promise](https://cdnjs.com/libraries/es6-promise) or [stefanpenner/es6-promise](https://github.com/stefanpenner/es6-promise)

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/test.html

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
html>
2-
<head>
3-
<meta charset="utf-8">
4-
<title>Mocha Tests</title>
5-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.2.0/mocha.min.css" />
6-
</head>
7-
<body>
8-
<div id="mocha"></div>
1+
<html>
2+
<head>
3+
<meta charset="utf-8">
4+
<title>Mocha Tests</title>
5+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.2.0/mocha.min.css" />
6+
</head>
7+
<body>
8+
<div id="mocha"></div>
99

10-
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
11-
<script src="https://cdnjs.cloudflare.com/ajax/libs/expect.js/0.2.0/expect.min.js"></script>
12-
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.2.0/mocha.min.js"></script>
13-
<script src="../dist/index.js"></script>
10+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
11+
<script src="https://cdnjs.cloudflare.com/ajax/libs/expect.js/0.2.0/expect.min.js"></script>
12+
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.2.0/mocha.min.js"></script>
13+
<script src="../dist/index.js"></script>
1414

15-
<script>mocha.setup('bdd')</script>
16-
<script src="test.html.js"></script>
17-
<script>
18-
mocha.checkLeaks();
19-
mocha.globals(['jQuery']);
20-
mocha.run();
21-
</script>
22-
</body>
15+
<script>mocha.setup('bdd')</script>
16+
<script src="test.html.js"></script>
17+
<script>
18+
mocha.checkLeaks();
19+
mocha.globals(['jQuery']);
20+
mocha.run();
21+
</script>
22+
</body>
2323
</html>

0 commit comments

Comments
 (0)