This repository has been archived by the owner on Nov 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
214 lines (171 loc) · 13.9 KB
/
test.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body style="font-family: monospace;">
<p>Open console to see more details.</p>
<pre id="error" style="color: red;"></pre>
<pre id="success" style="color: green;"></pre>
<script src="it.js"></script>
<script src="env.js"></script>
<script src="polyfills/polyfills.js"></script>
<script src="es5/mal.min.js"></script>
<script>
window.addEventListener('polyfillsLoaded', function() {
console.log('loaded polyfills');
var api = new MALjs(window._ENV.user, window._ENV.password);
console.log(api);
var xmlString = `<?xml version="1.0" encoding="utf-8"?> <anime> <entry> <id>71</id> <title>Full Metal Panic!</title> <english>Full Metal Panic!</english> <synonyms>FMP; Fullmetal Panic!</synonyms> <episodes>24</episodes> <score>7.81</score> <type>TV</type> <status>Finished Airing</status> <start_date>2002-01-08</start_date> <end_date>2002-06-18</end_date> <synopsis>Equipped with cutting-edge weaponry and specialized troops, a private military organization named Mithril strives to extinguish the world's terrorism and all threats to peace on earth. The organization is powered by the &quot;Whispered,&quot; individuals who possess intuitive knowledge and the remarkable ability to create powerful devices and machinery.<br /> <br /> Seventeen-year-old Sousuke Sagara, a sergeant working for Mithril, has been assigned to protect Kaname Chidori, a Whispered candidate. He is ordered to join her high school class and be as close to her as possible to prevent her from falling into enemy hands&mdash;that is, if he can safely blend in with their fellow classmates without revealing his true identity.<br /> <br /> Sousuke, who was raised on a battlefield and has very little knowledge of an average high school student's lifestyle, must adapt to a normal school life to safeguard Kaname. However, enemy forces have already begun making their move, and Sousuke is about to find out that the adversary coming for the Whispered girl may be a lot more familiar than he expects.<br /> <br /> [Written by MAL Rewrite]</synopsis> <image>https://myanimelist.cdn-dena.com/images/anime/2/75259.jpg</image> </entry> <entry> <id>72</id> <title>Full Metal Panic? Fumoffu</title> <english>Full Metal Panic? Fumoffu</english> <synonyms>Full Metal Panic Fumoffu; Fullmetal Panic? Fumoffu</synonyms> <episodes>12</episodes> <score>8.21</score> <type>TV</type> <status>Finished Airing</status> <start_date>2003-08-26</start_date> <end_date>2003-10-18</end_date> <synopsis>It's back-to-school mayhem with Kaname Chidori and her war-freak classmate Sousuke Sagara as they encounter more misadventures in and out of Jindai High School. But when Kaname gets into some serious trouble, Sousuke takes the guise of Bonta-kun&mdash;the gun-wielding, butt-kicking mascot. And while he struggles to continue living as a normal teenager, Sousuke also has to deal with protecting his superior officer Teletha Testarossa, who has decided to take a vacation from Mithril and spend a couple of weeks as his and Kaname's classmate.<br /> <br /> (Source: ANN)</synopsis> <image>https://myanimelist.cdn-dena.com/images/anime/4/75260.jpg</image> </entry> <entry> <id>73</id> <title>Full Metal Panic! The Second Raid</title> <english>Full Metal Panic! The Second Raid</english> <synonyms>Full Metal Panic! TSR</synonyms> <episodes>13</episodes> <score>8.06</score> <type>TV</type> <status>Finished Airing</status> <start_date>2005-07-14</start_date> <end_date>2005-10-20</end_date> <synopsis>This series is set about two months after the events ocurred in the Tuatha de Danaan at the end of the original series. Mithril becomes aware of a secret organization that has technology able to counter the ECS (Electronic Cloaking System) mode. This organization, known as Amalgam, also has &quot;Black Technology,&quot; obtained from &quot;Whispered&quot; like Kaname Chidori, and like the other intelligence agencies, they intend to obtain more; however, when Sousuke's mission to protect Chidori is terminated by Mithril, all seems to be in place for Amalgam's plans...<br /> <br /> (Source: ANN)</synopsis> <image>https://myanimelist.cdn-dena.com/images/anime/11/75261.jpg</image> </entry> <entry> <id>121</id> <title>Fullmetal Alchemist</title> <english>Fullmetal Alchemist</english> <synonyms>Hagane no Renkinjutsushi; FMA; Full Metal Alchemist</synonyms> <episodes>51</episodes> <score>8.33</score> <type>TV</type> <status>Finished Airing</status> <start_date>2003-10-04</start_date> <end_date>2004-10-02</end_date> <synopsis>Edward Elric, a young, brilliant alchemist, has lost much in his twelve-year life: when he and his brother Alphonse try to resurrect their dead mother through the forbidden act of human transmutation, Edward loses his brother as well as two of his limbs. With his supreme alchemy skills, Edward binds Alphonse&#039;s soul to a large suit of armor.<br /> <br /> A year later, Edward, now promoted to the fullmetal alchemist of the state, embarks on a journey with his younger brother to obtain the Philosopher&#039;s Stone. The fabled mythical object is rumored to be capable of amplifying an alchemist&#039;s abilities by leaps and bounds, thus allowing them to override the fundamental law of alchemy: to gain something, an alchemist must sacrifice something of equal value. Edward hopes to draw into the military&#039;s resources to find the fabled stone and restore his and Alphonse&#039;s bodies to normal. However, the Elric brothers soon discover that there is more to the legendary stone than meets the eye, as they are led to the epicenter of a far darker battle than they could have ever imagined.<br /> <br /> [Written by MAL Rewrite]</synopsis> <image>https://myanimelist.cdn-dena.com/images/anime/10/75815.jpg</image> </entry> <entry> <id>1015</id> <title>Full Metal Panic! The Second Raid: Wari to Hima na Sentaichou no Ichinichi</title> <english></english> <synonyms>The Commanding Officer's Rather Quiet Day; Full Metal Panic! The Second Raid Special; Full Metal Panic! The Second Raid OVA</synonyms> <episodes>1</episodes> <score>7.78</score> <type>Special</type> <status>Finished Airing</status> <start_date>2006-05-26</start_date> <end_date>2006-05-26</end_date> <synopsis>On her day off, Tessa wakes up in her commander chair. After regaining her composure, she notices that her favorite stuffed animal is missing and thus tries to remember what actually transpired the night before. To do so, she will spend time with all the main characters of the Danaan crew, and eventually recalls the events of the previous night.<br /> <br /> [Written by MAL Rewrite]</synopsis> <image>https://myanimelist.cdn-dena.com/images/anime/3/23458.jpg</image> </entry> <entry> <id>2601</id> <title>Juusenki L-Gaim III: Full Metal Soldier</title> <english></english> <synonyms>Heavy Metal L-Gaim OVA; Heavy Metal L-Gaim III: Full Metal Soldier</synonyms> <episodes>1</episodes> <score>6.50</score> <type>OVA</type> <status>Finished Airing</status> <start_date>1987-03-28</start_date> <end_date>1987-03-28</end_date> <synopsis>A side story taking place somewhere before the second half of the series, prior to Daba acquiring the L-Gaim Mk-II. Daba's comrade Leccee is captured by Poseidal's forces, and Daba and his rebels attempt to save her. </synopsis> <image>https://myanimelist.cdn-dena.com/images/anime/3/24615.jpg</image> </entry> <entry> <id>6291</id> <title>Full Metal Panic! The Second Raid Episode 000</title> <english></english> <synonyms>Full Metal Panic! The Second Raid Pre-festival: Night of the Light Novel</synonyms> <episodes>1</episodes> <score>7.55</score> <type>Special</type> <status>Finished Airing</status> <start_date>2005-07-06</start_date> <end_date>2005-07-06</end_date> <synopsis>Sousuke, Kurz and Melissa are deployed to the Republic of Manistan in Central Asia to eradicate a growing civil war between rebels and the Manistani military. <br /> <br /> (Source: Wikipedia)</synopsis> <image>https://myanimelist.cdn-dena.com/images/anime/9/45048.jpg</image> </entry> <entry> <id>31931</id> <title>Full Metal Panic! (Shinsaku)</title> <english></english> <synonyms></synonyms> <episodes>0</episodes> <score>7.48</score> <type></type> <status>Not yet aired</status> <start_date>2017-10-00</start_date> <end_date>0000-00-00</end_date> <synopsis>Jindai High School was a relatively safe place, right up until Sousuke Sagaka transferred there. A total nut, he wreaks havoc on the school&#039;s student body and gets into a world of trouble with the teachers! But there&#039;s more to Sousuke than meets the eye&mdash;not just a hell-raising student, he&#039;s actually a member of an elite military unit, on an undercover mission to protect the beautiful schoolgirl Kaname Chidori from the KGB. <br /> <br /> (Source: Tokyopop)</synopsis> <image>https://myanimelist.cdn-dena.com/images/anime/3/77141.jpg</image> </entry> </anime>`;
it('should be able to set the username and password', function() {
console.log('username:', api._user, window._ENV.user);
console.log('password:', api._password, window._ENV.password);
if (
api._user != window._ENV.user ||
api._password != window._ENV.password
) {
this.fail();
}
this.done();
});
it('should be able to convert MAL\'s xml to json', function() {
api._xmlToJson(xmlString)
.then(object => {
if (
!object.anime ||
object.anime.length == 0 ||
object.anime[0].id != 71
) {
this.fail();
}
this.done();
})
.catch(this.fail);
});
it('should be able to convert xml to json', function() {
var object = {
episode: 1,
status: 6,
score: 7
};
var xmlString = api._toXml(object);
console.log(xmlString);
if (xmlString !== '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><episode>1</episode><status>6</status><score>7</score>') {
this.fail();
}
this.done();
});
it('should be able to search an anime', function() {
var searchString = 'bleach';
api.anime.search(searchString).then(result => {
console.log(result);
if(!result.anime[0].id == 269) {
this.fail();
}
this.done();
}).catch(this.fail)
});
it('should be able to search an manga', function() {
var searchString = 'bleach';
api.manga.search(searchString).then(result => {
console.log(result);
if(!result.manga[0].id == 12) {
this.fail();
}
this.done();
}).catch(this.fail)
});
it('should be able to add, update and delete an anime to the list', function() {
api.anime.add(269, {
episode: 1,
status: 6,
score: 7
}).then(result => {
console.log('Anime', result);
if(result !== 'Created') {
this.fail();
}
api.anime.update(269, {
episode: 2
}).then(result => {
console.log('Anime', result);
api.anime.delete(269).then(result => {
console.log('Anime', result);
this.done();
}).catch(this.fail);
}).catch(this.fail);
}).catch(this.fail);
}).then(_ => {
it('should be able to list an users anime list', function() {
api.anime.add(269, {
episode: 1,
status: 6,
score: 7
}).then(result => {
console.log(result);
if(result !== 'Created') {
this.fail();
}
api.anime.list().then(list => {
console.log(list);
if (
list.myanimelist.anime.length !== 1 ||
list.myanimelist.anime[0].series_animedb_id != '269'
) {
this.fail();
}
api.anime.delete(269);
this.done();
});
}).catch(this.fail);
});
});
it('should be able to add, update and delete an manga to the list', function() {
api.manga.add(12, {
chapter: 6,
status: 6,
volume: 1
}).then(result => {
console.log('manga', result);
if(result !== 'Created') {
this.fail();
}
api.manga.update(12, {
chapter: 7
}).then(result => {
console.log('manga', result);
api.manga.delete(12).then(result => {
console.log('manga', result);
this.done();
}).catch(this.fail);
}).catch(this.fail);
}).catch(this.fail);
}).then(_ => {
it('should be able to list an users manga list', function() {
api.manga.add(12, {
chapter: 6,
status: 6,
volume: 1
}).then(result => {
console.log(result);
if(result !== 'Created') {
this.fail();
}
api.manga.list().then(list => {
console.log(list);
if (
list.myanimelist.manga.length !== 1 ||
list.myanimelist.manga[0].series_mangadb_id != '12'
) {
this.fail();
}
api.manga.delete(12);
this.done();
});
}).catch(this.fail);
});
});
});
</script>
</body>
</html>