Skip to content

Commit 5244fc2

Browse files
author
Kuniwak
committed
Implement stage5
1 parent 654e2ef commit 5244fc2

File tree

4 files changed

+110
-1
lines changed

4 files changed

+110
-1
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"devDependencies": {
2323
"body-parser": "^1.12.0",
2424
"chai": "^2.1.1",
25+
"chai-as-promised": "^4.3.0",
2526
"express": "^4.12.2",
2627
"gulp": "^3.8.11",
2728
"gulp-eslint": "^0.6.0",
@@ -35,6 +36,7 @@
3536
"dependencies": {
3637
"bootstrap": "^3.3.2",
3738
"chai-jquery": "^2.0.0",
38-
"jquery": "^2.1.3"
39+
"jquery": "^2.1.3",
40+
"whatwg-fetch": "^0.7.0"
3941
}
4042
}

test/stage5/.eslintrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"mocha": true
5+
},
6+
"globals": {
7+
"$": false,
8+
"jQuery": false,
9+
"fetch": false,
10+
"Promise": false,
11+
"HTMLCollection": false
12+
}
13+
}

test/stage5/index.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>mixi JS Training</title>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<link href="http://img.mixi.net/img/basic/favicon.ico" type="image/vnd.microsoft.icon" rel="icon">
8+
<link href="http://img.mixi.net/img/basic/favicon.ico" type="image/vnd.microsoft.icon" rel="shortcut icon">
9+
<link rel="stylesheet" href="/modules/mocha/mocha.css">
10+
<link rel="stylesheet" href="../common/mocha-patch.css">
11+
</head>
12+
<body>
13+
<div id="mocha"></div>
14+
<script src="/modules/jquery/dist/jquery.js"></script>
15+
<script src="/modules/mocha/mocha.js"></script>
16+
<script src="/modules/chai/chai.js"></script>
17+
<script src="/modules/chai-jquery/chai-jquery.js"></script>
18+
<script src="/modules/chai-as-promised/lib/chai-as-promised.js"></script>
19+
<script src="/modules/whatwg-fetch/fetch.js"></script>
20+
<script>
21+
mocha.ui('bdd');
22+
mocha.reporter('html');
23+
expect = chai.expect;
24+
</script>
25+
<script>mocha.setup('bdd')</script>
26+
<script src="tests.js"></script>
27+
<script>
28+
if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
29+
else { mocha.run(); }
30+
</script>
31+
</body>
32+
</html>

test/stage5/tests.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
'use strict';
2+
3+
describe('ステージ5(意図通りに非同期処理を利用できる)', function() {
4+
describe('通信編', function() {
5+
it('Github の mixi-inc の organization の情報を取得できる', function() {
6+
var mixiOrg;
7+
8+
// チュートリアル
9+
//
10+
// ここに下記のコードを記述してください。
11+
//
12+
// mixiOrg = fetch('https://api.github.com/orgs/mixi-inc').
13+
// then(function(response) {
14+
// return response.json();
15+
// });
16+
17+
18+
return expect(mixiOrg).to.eventually.have.property('id', 1089312);
19+
20+
// Github API に関する参考情報
21+
// https://developer.github.com/v3/repos/
22+
});
23+
24+
25+
it('Github API を使って、mixi-inc/JavaScriptTraining の情報を取得できる', function(){
26+
var repositry = 'mixi-inc/JavaScriptTraining';
27+
var mixiRepo;
28+
29+
// コードをここに記述してください。
30+
31+
32+
return expect(mixiRepo).to.eventually.have.property(
33+
'full_name', repositry);
34+
});
35+
36+
37+
it('Github API を使って、VimL、Emacs Lisp でスターが最も多いプロダクト名を' +
38+
'それぞれ 1 つずつ取得できる', function(){
39+
var languages = [ 'VimL', '"Emacs Lisp"' ];
40+
var mostPopularRepos;
41+
42+
// コードをここに記述してください。
43+
// なお、 mostPopularRepos は Promise インスタンスであることを
44+
// 意図しています。
45+
46+
47+
return expect(mostPopularRepos).to.eventually.have.length(2);
48+
49+
// fetch API に関する参考情報
50+
// https://github.com/github/fetch
51+
//
52+
// Github API に関する参考情報
53+
// https://developer.github.com/v3/search/
54+
//
55+
// Promise に関する参考情報
56+
// https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise
57+
//
58+
// Promise 参考情報(重量級)
59+
// http://azu.github.io/promises-book/
60+
});
61+
});
62+
});

0 commit comments

Comments
 (0)