-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
78 lines (65 loc) · 2.77 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Library for SWAPI</title>
</head>
<body>
<div>
<h1>Test being performed on console. Check developer tools.</h1><br>
</div>
<script src="./lib/swapiLib.js"></script>
<script>
//Function used to treat data coming from 'swapiLib' methods
var treatData = function(functionName){
functionName
.then(function (response) {
console.log("%c" + "New Query", 'background: green; color: white; display: block;');
console.log(response);
})
.catch(function (error) {
console.log("%c" + "Failed Query", 'background: red; color: white; display: block;');
console.log("ERROR. " + error);
});
}
//TESTS
treatData(swapiLib.getResources())
treatData(swapiLib.getResources(1)); //Is supposed to give object with ERROR
var People = swapiLib.People;
treatData(People.getPeople([1,200]));
treatData(People.getPeople(1,2)); //Is supposed to give ERROR
treatData(People.getPeople([1,2,3]));
treatData(People.getPeople()); //Get all People
treatData(People.getPeopleSchema())
// var Films = swapiLib.Films;
// treatData(Films.getFilms(1));
// treatData(Films.getFilms(1,2)); //Is supposed to give ERROR
// treatData(Films.getFilms([1,2,3]));
// treatData(Films.getFilms()); //Get all Films
// treatData(Films.getFilmsSchema());
// var Starships = swapiLib.Starships;
// treatData(Starships.getStarships(10));
// treatData(Starships.getStarships(1,177)); //Is supposed to give ERROR
// treatData(Starships.getStarships([1,2,3]));
// treatData(Starships.getStarships()); //Get all Starships
// treatData(Starships.getStarshipsSchema());
// var Vehicles = swapiLib.Vehicles;
// treatData(Vehicles.getVehicles(4));
// treatData(Vehicles.getVehicles([1,2,3]));
// treatData(Vehicles.getVehicles([4,6,8,14]));
// treatData(Vehicles.getVehicles());
// treatData(Vehicles.getVehiclesSchema());
// var Species = swapiLib.Species;
// treatData(Species.getSpecies(1));
// treatData(Species.getSpecies([1,2,3]));
// treatData(Species.getSpecies());
// treatData(Species.getSpeciesSchema());
// var Planets = swapiLib.Planets;
// treatData(Planets.getPlanets(1));
// treatData(Planets.getPlanets([1,2,3]));
// treatData(Planets.getPlanets());
// treatData(Planets.getPlanetsSchema());
//------------- TESTS end ----------------------------------
</script>
</body>
</html>