Skip to content

Commit 30f56a1

Browse files
committed
tutorial updates
1 parent a6e97fa commit 30f56a1

File tree

9 files changed

+125
-84
lines changed

9 files changed

+125
-84
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
node_modules
2-
tutorial/_temp**
2+
tutorial/_temp.spec.js

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ CodeRoad is an open-sourced interactive tutorial platform for the Atom Editor. L
1919

2020
## Outline
2121

22-
### Declaring Variables
22+
### Features
2323

24-
Using `let` & `const`.
24+
New features in ES2015.
2525

2626
##### Let
2727

coderoad.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
},
66
"chapters": [
77
{
8-
"title": "Declaring Variables",
9-
"description": "Using `let` & `const`.",
8+
"title": "Features",
9+
"description": "New features in ES2015.",
1010
"pages": [
1111
{
1212
"title": "Let",

tutorial/.tmp.spec.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
'use strict';
2+
var chai = require('chai');
3+
var spies = require('chai-spies');
4+
var expect = chai.expect;
5+
chai.use(spies);
6+
var spy = chai.spy.on(console, 'log');
7+
8+
// use =>
9+
const greet = function (name) {
10+
return 'hello ' + name;
11+
}
12+
13+
14+
describe('01 greet', () => {
15+
16+
it('doesn\'t exist', () => {
17+
expect(greet).to.be.defined;
18+
});
19+
20+
it('doesn\'t use an arrow function', () => {
21+
expect(greet.toString()).to.match(/=>/g);
22+
});
23+
24+
it('doesn\'t return "hello " + name', () => {
25+
expect(greet('there')).to.equal('hello there');
26+
});
27+
28+
});
29+
30+
describe('02 getName', () => {
31+
32+
it('doesn\'t exist', () => {
33+
expect(getName).to.be.defined;
34+
});
35+
36+
it('doesn\'t use an arrow function', () => {
37+
expect(getName.toString()).to.match(/=>/g);
38+
});
39+
40+
it('should not use the `return` keyword', () => {
41+
expect(getName.toString()).not.to.match(/return/g);
42+
});
43+
44+
it('doesn\'t return the name "Joe"', () => {
45+
expect(getName()).to.equal('Joe');
46+
});
47+
48+
});
49+
50+
describe('03 clock', () => {
51+
52+
it('try the example on CodePen', () => {
53+
expect(true).to.equal(true);
54+
});
55+
56+
});
57+

tutorial/1/04/03.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ describe('03 expression', () => {
88
expect(expression.toString()).to.match(/`/g);
99
});
1010

11+
it('should use expressions `{exp}`', () => {
12+
expect(expression.toString()).to.match(/${name}/g);
13+
});
14+
1115
it('shouldn\'t have regular quotes, only backticks (`)', () => {
1216
expect(expression.toString()).not.to.match(/['"]/g);
1317
});

tutorial/2/01/01.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
var expect = require('chai').expect;
3+
4+
/// load('object-literal.js')
5+
6+
describe('01 getPersonObj', () => {
7+
8+
it('doesn\'t exist', () => {
9+
expect(getPersonObj).to.be.defined;
10+
});
11+
12+
it('should use the object shorthand', () => {
13+
expect(getPersonObj.toString()).not.to.match(/name:\s?name/g);
14+
expect(getPersonObj.toString()).not.to.match(/city:\s?city/g);
15+
});
16+
17+
it('should return an object with name & city', function() {
18+
expect(getPersonObj('J', 'V')).to.deep.equal({
19+
name: 'J',
20+
city: 'V'
21+
});
22+
});
23+
24+
});

tutorial/2/01/object-literal.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### Object Literal
2+
3+
A shorthand for writing objects.
4+
5+
```js
6+
const foo = 'something';
7+
const bar = 'else';
8+
9+
// using object literal shorthand
10+
const fooObj = {
11+
foo, bar
12+
};
13+
// { foo: 'something', bar: 'else'}
14+
```
15+
16+
+ Rewrite the object in an easier way using object literals
17+
@action(open('object-literal.js'))
18+
@test('2/01/01')
19+
@action(set(
20+
```
21+
// rewrite in a simpler way
22+
function getPersonObj(name, city) {
23+
return {
24+
name: name,
25+
city: city
26+
};
27+
}
28+
```
29+
))

tutorial/_tmp.spec.js

Lines changed: 0 additions & 73 deletions
This file was deleted.

tutorial/tutorial.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# ES2015
22
Practice refactoring with ES2015 features.
33

4-
## Declaring Variables
5-
Using `let` & `const`.
4+
## Features
5+
New features in ES2015.
66

7-
@import('tutorial/1/01/let')
8-
@import('tutorial/1/02/const')
9-
@import('tutorial/1/03/arrow-function')
10-
@import('tutorial/1/04/template-literal')
7+
@import('1/01/let')
8+
@import('1/02/const')
9+
@import('1/03/arrow-function')
10+
@import('1/04/template-literal')

0 commit comments

Comments
 (0)