Skip to content

Commit 4443e01

Browse files
committed
tutorial updates - step 2 outlined
1 parent 2ac8c4a commit 4443e01

File tree

11 files changed

+70
-105
lines changed

11 files changed

+70
-105
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ We'll be installing a lot of scripts from terminal. You may also want to conside
4141
##### The Store
4242

4343
The "single source of truth".
44+
45+
```js
46+
const store = createStore(reducer, initialState);
47+
```

coderoad.json

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,41 @@
1818
],
1919
"actions": [
2020
"open('package.json')",
21-
"set('{\n \"name\": \"coderoad-redux-js\",\n \"version\": \"0.1.0\",\n \"description\": \"Coderoad tutorial for using redux with raw javascript\",\n \"bugs\": {\n \"url\": \"https://github.com/shmck/coderoad-redux-js\"\n },\n \"license\": \"ISC\",\n \"author\": \"Shawn McKay <shawn.j.mckay@gmail.com>\",\n \"main\": \"index.js\",\n \"repository\": \"https://github.com/shmck/coderoad-redux-js\",\n \"scripts\": {\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"config\": {\n \"language\": \"JS\",\n \"runner\": \"mocha-coderoad\"\n },\n \"dependencies\": {\n \"mocha-coderoad\": \"latest\"\n },\n \"devDependencies\": {\n \"babel-preset-es2015\": \"^6.9.0\",\n \"babel-preset-react\": \"^6.11.1\",\n \"babelify\": \"^7.3.0\",\n \"browser-sync\": \"^2.13.0\",\n \"concurrently\": \"^2.2.0\",\n \"npm-watch\": \"^0.1.5\"\n },\n \"watch\": {\n \"reload\": {\n \"patterns\": [\n \"src\"\n ],\n \"extensions\": \"js,jsx,css,html,scss\",\n \"ignore\": \"node_modules\",\n \"quiet\": false\n }\n },\n \"scripts\": {\n \"browserify\": \"browserify src/index.js --extension=.jsx -o dist/bundle.js -t [ babelify --presets [ es2015 react ] ]\",\n \"browsersync:reload\": \"browser-sync reload\",\n \"browsersync:start\": \"browser-sync start --server --files 'index.html dist/bundle.js'\",\n \"build\": \"npm run browserify\",\n \"reload\": \"npm run browserify && npm run browsersync:reload\",\n \"start\": \"concurrently --kill-others 'npm run build' 'npm run browsersync:start' 'npm run watch'\",\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\",\n \"watch\": \"npm-watch\",\n \"setup\": \"npm install && mkdir -p dist && npm i -g concurrently browser-sync && npm start\"\n }\n}\n')"
21+
"set('{\n \"name\": \"coderoad-redux-js\",\n \"version\": \"0.1.0\",\n \"description\": \"Coderoad tutorial for using redux with raw javascript\",\n \"bugs\": {\n \"url\": \"https://github.com/shmck/coderoad-redux-js\"\n },\n \"license\": \"ISC\",\n \"author\": \"Shawn McKay <shawn.j.mckay@gmail.com>\",\n \"main\": \"index.js\",\n \"repository\": \"https://github.com/shmck/coderoad-redux-js\",\n \"scripts\": {\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"dependencies\": {\n \"mocha-coderoad\": \"latest\"\n },\n \"devDependencies\": {\n \"babel-preset-es2015\": \"^6.9.0\",\n \"babel-preset-react\": \"^6.11.1\",\n \"babelify\": \"^7.3.0\",\n \"browser-sync\": \"^2.13.0\",\n \"concurrently\": \"^2.2.0\",\n \"npm-watch\": \"^0.1.5\",\n \"coderoad-redux-js\": \"^0.1.0\"\n },\n \"watch\": {\n \"reload\": {\n \"patterns\": [\n \"src\"\n ],\n \"extensions\": \"js,jsx,css,html,scss\",\n \"ignore\": \"node_modules\",\n \"quiet\": false\n }\n },\n \"scripts\": {\n \"browserify\": \"browserify src/index.js --extension=.jsx -o dist/bundle.js -t [ babelify --presets [ es2015 react ] ]\",\n \"browsersync:reload\": \"browser-sync reload\",\n \"browsersync:start\": \"browser-sync start --server --files 'index.html dist/bundle.js'\",\n \"build\": \"npm run browserify\",\n \"reload\": \"npm run browserify && npm run browsersync:reload\",\n \"start\": \"concurrently --kill-others 'npm run build' 'npm run browsersync:start' 'npm run watch'\",\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\",\n \"watch\": \"npm-watch\",\n \"setup\": \"npm install && mkdir -p dist && npm i -g concurrently browser-sync && npm start\"\n }\n}\n')"
2222
]
2323
}
2424
],
2525
"onPageComplete": "Continue to start working with Redux"
2626
},
2727
{
2828
"title": "The Store",
29-
"description": "The \"single source of truth\".",
29+
"description": "The \"single source of truth\".\n\n```js\nconst store = createStore(reducer, initialState);\n```",
3030
"tasks": [
3131
{
32-
"description": "write a function `divideOne` divides a number by 1",
32+
"description": "install Redux. Run `npm install redux`.",
33+
"actions": [
34+
"open('index.js')"
35+
],
3336
"tests": [
3437
"02/01"
35-
],
36-
"actions": [
37-
"open('page-02.js')",
38-
"set('// divideOne\nfunction divideOne(x) {\n return ::>\n}\n')"
3938
]
4039
},
4140
{
42-
"description": "write a function `mutiplyone` that multiplies a number by 1",
41+
"description": "import { createStore } from 'redux';",
4342
"tests": [
4443
"02/02"
45-
],
46-
"actions": [
47-
"insert('\n// multiplyOne\nfunction multiplyOne(x) {\n return ::>\n}\n')"
44+
]
45+
},
46+
{
47+
"description": "create your first store and call it `store`. Use a simple \"reducer\" function for now, let's say `state => state`.",
48+
"tests": [
49+
"02/03"
50+
]
51+
},
52+
{
53+
"description": "log your store to the console and have a look.",
54+
"tests": [
55+
"02/04"
4856
]
4957
}
5058
]

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
},
88
"license": "ISC",
99
"author": "Shawn McKay <shawn.j.mckay@gmail.com>",
10-
"main": "index.js",
10+
"main": "coderoad.json",
1111
"repository": "https://github.com/shmck/coderoad-redux-js",
1212
"scripts": {
1313
"test": "echo \"Error: no test specified\" && exit 1"
1414
},
1515
"config": {
16+
"dir": "tutorial",
17+
"testSuffix": ".js",
1618
"language": "JS",
17-
"runner": "mocha-coderoad"
19+
"runner": "mocha-coderoad",
20+
"edit": true
1821
},
1922
"dependencies": {
20-
"mocha-coderoad": "latest"
23+
"mocha-coderoad": "0.9.0"
2124
}
2225
}

test.js

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

tutorial/01/01.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
var expect = require('chai').expect;
2-
const { accessSync, F_OK } = require('fs');
32

4-
// must include function to check before deps are added
5-
function exists(path, silent = true) {
6-
try {
7-
accessSync(path, F_OK);
8-
} catch (e) {
9-
if (e) {
10-
if (!silent) {
11-
console.log(e);
12-
}
13-
return false;
14-
}
15-
}
16-
return true;
17-
}
3+
/// load('index.js')
184

195
describe('01 setup', () => {
206

tutorial/01/index.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ We'll be installing a lot of scripts from terminal. You may also want to conside
3737
"scripts": {
3838
"test": "echo \"Error: no test specified\" && exit 1"
3939
},
40-
"config": {
41-
"language": "JS",
42-
"runner": "mocha-coderoad"
43-
},
4440
"dependencies": {
4541
"mocha-coderoad": "latest"
4642
},
@@ -50,7 +46,8 @@ We'll be installing a lot of scripts from terminal. You may also want to conside
5046
"babelify": "^7.3.0",
5147
"browser-sync": "^2.13.0",
5248
"concurrently": "^2.2.0",
53-
"npm-watch": "^0.1.5"
49+
"npm-watch": "^0.1.5",
50+
"coderoad-redux-js": "^0.1.0"
5451
},
5552
"watch": {
5653
"reload": {

tutorial/02/01.js

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
var expect = require('chai').expect;
1+
var chai = require('chai');
2+
var spies = require('chai-spies');
3+
var expect = chai.expect;
4+
chai.use(spies);
25

3-
/// load('page-02.js')
6+
describe('01 Redux', () => {
47

5-
describe('01 divideOne', function() {
6-
7-
it('doesn\'t exist', function () {
8-
expect(divideOne).to.be.defined;
9-
});
10-
11-
it('should take a parameter', function() {
12-
expect(divideOne).to.have.length(1);
13-
});
14-
15-
it('doesn\'t output a number', function () {
16-
expect(divideOne(1)).to.be.a('number');
17-
});
18-
19-
it('returns the same number', function() {
20-
expect(divideOne(1)).to.equal(1);
21-
expect(divideOne(10)).to.equal(10);
8+
it('isn\'t installed', () => {
9+
expect(exists('node_modules/redux')).to.be.true;
2210
});
2311

2412
});

tutorial/02/02.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1-
describe('02 multiplyOne', function() {
1+
describe('02 createStore', () => {
22

3-
it('doesn\'t exist', function () {
4-
expect(multiplyOne).to.be.defined;
5-
});
6-
7-
it('should take a parameter', function() {
8-
expect(multiplyOne).to.have.length(1);
9-
});
10-
11-
it('should output a number', function () {
12-
expect(multiplyOne(1)).to.be.a('number');
13-
});
14-
15-
it('returns the multiplied number by one', function() {
16-
expect(multiplyOne(1)).to.equal(1);
17-
expect(multiplyOne(10)).to.equal(10);
3+
it('isn\'t imported. `import { createStore } from "redux";`', () => {
4+
expect(createStore).to.be.defined;
185
});
196

207
});

tutorial/02/03.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
describe('03 store', () => {
2+
3+
it('isn\'t defined. `const store`', () => {
4+
expect(store).to.be.defined;
5+
});
6+
7+
});

tutorial/02/04.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var spy = chai.spy.on(console, 'log');
2+
3+
describe('04 log store', () => {
4+
5+
it('isn\'t logged to the console. `console.log(store)`', () => {
6+
expect(spy).to.have.been.called.with(store);
7+
});
8+
9+
});

tutorial/02/index.md

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
## The Store
22
The "single source of truth".
33

4-
+ write a function `divideOne` divides a number by 1
5-
@test('02/01')
6-
@action(open('page-02.js'))
7-
@action(set(
8-
```
9-
// divideOne
10-
function divideOne(x) {
11-
return ::>
12-
}
4+
```js
5+
const store = createStore(reducer, initialState);
136
```
14-
))
157

16-
+ write a function `mutiplyone` that multiplies a number by 1
8+
+ install Redux. Run `npm install redux`.
9+
@action(open('index.js'))
10+
@test('02/01')
11+
12+
+ `import { createStore } from 'redux';`
1713
@test('02/02')
18-
@action(insert(
19-
```
2014

21-
// multiplyOne
22-
function multiplyOne(x) {
23-
return ::>
24-
}
25-
```
26-
))
15+
+ create your first store and call it `store`. Use a simple "reducer" function for now, let's say `state => state`.
16+
@test('02/03')
17+
18+
+ log your store to the console and have a look.
19+
@test('02/04')

0 commit comments

Comments
 (0)