Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"devDependencies": {
"body-parser": "^1.12.0",
"chai": "^2.1.1",
"chai-as-promised": "^4.3.0",
"express": "^4.12.2",
"gulp": "^3.8.11",
"gulp-eslint": "^0.6.0",
Expand All @@ -35,6 +36,7 @@
"dependencies": {
"bootstrap": "^3.3.2",
"chai-jquery": "^2.0.0",
"jquery": "^2.1.3"
"jquery": "^2.1.3",
"whatwg-fetch": "^0.7.0"
}
}
8 changes: 8 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ var MODULE_DIR = path.join(__dirname, 'node_modules');
app.use(express.static(PUBLIC_DIR));
app.use('/modules', express.static(MODULE_DIR));


app.get('/api/heavy', function(req, res) {
setTimeout(function() {
res.send('// do nothing');
}, 1000);
});


var server = require('http').createServer(app);
var PORT = 8000;
var HOSTNAME = 'localhost';
Expand Down
8 changes: 7 additions & 1 deletion test/stage4/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<li id="firebrick">1</li>
<li id="chocolate">2</li>
<li class="mediumseagreen">3</li>
<li class="turquoise"><input type="number" value="0"></li>
<li class="turquoise">4<input type="number" value="0"></li>
</ul>
</div>
<div id="mocha"></div>
Expand All @@ -35,5 +35,11 @@
if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
else { mocha.run(); }
</script>
<script src="/api/heavy"></script>
<div class="js-training-container">
<ul class="js-training">
<li class="steelblue">5 &#x1f433;</li>
</ul>
</div>
</body>
</html>
59 changes: 15 additions & 44 deletions test/stage4/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,56 +45,27 @@
.js-training .turquoise {
background-color: turquoise;
font-weight: normal;
text-align: right;
}

.js-training blockquote {
background-color: steelblue;
margin: 0;
.js-training .turquoise input {
background-color: hsla(0, 0%, 0%, 0.1);
width: 3em;
height: 40px;
font-size: 1;
font-weight: normal;
}

.js-training [data-js-training="blueviolet"] {
background-color: blueviolet;
}

.js-training #brown {
background-color: brown;
font-weight: normal;
}

.js-training #darkorange {
background-color: darkorange;
font-weight: normal;
}

.js-training .limegreen {
background-color: limegreen;
font-weight: normal;
}
border: none;
margin-left: 15%;
padding: 0 0 0 12px;

.js-training .mediumturquoise {
background-color: mediumturquoise;
font-weight: normal;
font-size: inherit;
color: inherit;
text-shadow: inherit;
text-align: center;
}

.js-training p {
.js-training .steelblue {
background-color: steelblue;
margin: 0;
padding: 0;
background-color: cornflowerblue;
font-weight: normal;
}

.js-training [data-js-training="darkorchid"] {
background-color: darkorchid;
}

.js-training-trick {
z-index: 1;
position: absolute;
top: 0;
height: 40px;
line-height: 40px;
text-indent: 60%;
font-size: 1;
font-weight: normal;
}
19 changes: 18 additions & 1 deletion test/stage4/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('ステージ4(意図通りにイベントを利用できる)', fun
});


it('4 番の要素のに入力された角度に回転できる', function() {
it('4 番の要素を入力された角度に回転できる', function() {

// ここにコードを記述してください。

Expand All @@ -80,6 +80,23 @@ describe('ステージ4(意図通りにイベントを利用できる)', fun
expect(turquoise).to.have.deep.property(
secret('fglyr.genafsbez'), secret('ebgngr(20qrt)'));
});


it('5 番の要素の内容を取得できる', function(done) {

// このテストは、画面下部の .steelblue 要素の内容が "5 (クジラの絵文字)" で
// あることを確認する意図があります。画面上は 5 とクジラの絵文字が正しく
// 表示されています。しかし、テストは失敗しているようです。
//
// このテストが意図通り成功するようにテストコードを修正してください。
//
// なお、expect(steelblue).to.be.null は上記のテストの要件を満たして
// いないので、正解ではありません。

var steelblue = document.querySelector('.steelblue');
expect(steelblue).to.have.property('textContent', '5 \uD83D\uDC33');
done();
});
});
});

Expand Down
13 changes: 13 additions & 0 deletions test/stage5/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"env": {
"browser": true,
"mocha": true
},
"globals": {
"$": false,
"jQuery": false,
"fetch": false,
"Promise": false,
"HTMLCollection": false
}
}
32 changes: 32 additions & 0 deletions test/stage5/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<title>mixi JS Training</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="http://img.mixi.net/img/basic/favicon.ico" type="image/vnd.microsoft.icon" rel="icon">
<link href="http://img.mixi.net/img/basic/favicon.ico" type="image/vnd.microsoft.icon" rel="shortcut icon">
<link rel="stylesheet" href="/modules/mocha/mocha.css">
<link rel="stylesheet" href="../common/mocha-patch.css">
</head>
<body>
<div id="mocha"></div>
<script src="/modules/jquery/dist/jquery.js"></script>
<script src="/modules/mocha/mocha.js"></script>
<script src="/modules/chai/chai.js"></script>
<script src="/modules/chai-jquery/chai-jquery.js"></script>
<script src="/modules/chai-as-promised/lib/chai-as-promised.js"></script>
<script src="/modules/whatwg-fetch/fetch.js"></script>
<script>
mocha.ui('bdd');
mocha.reporter('html');
expect = chai.expect;
</script>
<script>mocha.setup('bdd')</script>
<script src="tests.js"></script>
<script>
if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
else { mocha.run(); }
</script>
</body>
</html>
62 changes: 62 additions & 0 deletions test/stage5/tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use strict';

describe('ステージ5(意図通りに非同期処理を利用できる)', function() {
describe('通信編', function() {
it('Github の mixi-inc の organization の情報を取得できる', function() {
var mixiOrg;

// チュートリアル
//
// ここに下記のコードを記述してください。
//
// mixiOrg = fetch('https://api.github.com/orgs/mixi-inc').
// then(function(response) {
// return response.json();
// });


return expect(mixiOrg).to.eventually.have.property('id', 1089312);

// Github API に関する参考情報
// https://developer.github.com/v3/repos/
});


it('Github API を使って、mixi-inc/JavaScriptTraining の情報を取得できる', function(){
var repositry = 'mixi-inc/JavaScriptTraining';
var mixiRepo;

// コードをここに記述してください。


return expect(mixiRepo).to.eventually.have.property(
'full_name', repositry);
});


it('Github API を使って、VimL、Emacs Lisp でスターが最も多いプロダクト名を' +
'それぞれ 1 つずつ取得できる', function(){
var languages = [ 'VimL', '"Emacs Lisp"' ];
var mostPopularRepos;

// コードをここに記述してください。
// なお、 mostPopularRepos は Promise インスタンスであることを
// 意図しています。


return expect(mostPopularRepos).to.eventually.have.length(2);

// fetch API に関する参考情報
// https://github.com/github/fetch
//
// Github API に関する参考情報
// https://developer.github.com/v3/search/
//
// Promise に関する参考情報
// https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise
//
// Promise 参考情報(重量級)
// http://azu.github.io/promises-book/
});
});
});