File tree Expand file tree Collapse file tree 6 files changed +123
-12
lines changed
src/create/setup/tutorial/chapter-01 Expand file tree Collapse file tree 6 files changed +123
-12
lines changed Original file line number Diff line number Diff line change 1
- ### Page One Title
2
- Page one description .
1
+ ### Add & Subtract
2
+ Writing basic functions .
3
3
4
- More about page one .
4
+ A function has inputs and outputs. The inputs we call "parameters" and wrap them in ` ( ` brackets ` ) ` .
5
5
6
- + write a function that does something.
6
+ The output is ` return ` ed from the function.
7
+
8
+ ```
9
+ // input
10
+ function doSomething(parameter) {
11
+ // output
12
+ return parameter;
13
+ }
14
+ ```
15
+
16
+ Try making your own basic functions.
17
+
18
+ + write a function ` addOne ` that adds one to a number
7
19
@test ('chapter-01/page-01/task-01')
8
20
9
- + write some other function
21
+ + write a function ` subtractOne ` that subtracts one from a number
10
22
@test ('chapter-01/page-01/task-02')
Original file line number Diff line number Diff line change 1
- console . log ( 'page one test' ) ;
1
+ var expect = require ( 'chai' ) . expect ;
2
+ var context = require ( 'test-context' ) ;
3
+ var filePath = '../../../example.js' ;
4
+ context ( filePath ) ;
5
+
6
+ describe ( 'addOne' , function ( ) {
7
+
8
+ it ( 'doesn\'t exist' , function ( ) {
9
+ expect ( addOne ) . to . not . be . undefined ;
10
+ } ) ;
11
+
12
+ it ( 'doesn\'t take any parameters' , function ( ) {
13
+ expect ( addOne . length ) . to . be . above ( 0 ) ;
14
+ } ) ;
15
+
16
+ it ( 'doesn\'t return anything' , function ( ) {
17
+ expect ( addOne ( 1 ) ) . to . exist ;
18
+ } ) ;
19
+
20
+ it ( 'doesn\'t output a number' , function ( ) {
21
+ expect ( addOne ( 1 ) ) . to . be . a ( 'number' ) ;
22
+ } ) ;
23
+
24
+ it ( 'doesn\'t add 1 + 1' , function ( ) {
25
+ expect ( addOne ( 1 ) ) . to . equal ( 2 ) ;
26
+ expect ( addOne ( 10 ) ) . to . equal ( 11 ) ;
27
+ } ) ;
28
+
29
+ } ) ;
Original file line number Diff line number Diff line change
1
+ var expect = require ( 'chai' ) . expect ;
2
+ var context = require ( 'test-context' ) ;
3
+ context ( '../../../example.js' ) ;
4
+
5
+ describe ( 'subtractOne' , function ( ) {
6
+
7
+ it ( 'doesn\'t exist' , function ( ) {
8
+ expect ( subtractOne ) . to . not . be . undefined ;
9
+ } ) ;
10
+
11
+ it ( 'doesn\'t take any parameters' , function ( ) {
12
+ expect ( subtractOne . length ) . to . be . above ( 0 ) ;
13
+ } ) ;
14
+
15
+ it ( 'doesn\'t output a number' , function ( ) {
16
+ expect ( subtractOne ( 1 ) ) . to . be . a ( 'number' ) ;
17
+ } ) ;
18
+
19
+ it ( 'doesn\'t subtract 1' , function ( ) {
20
+ expect ( subtractOne ( 1 ) ) . to . equal ( 0 ) ;
21
+ expect ( subtractOne ( 10 ) ) . to . equal ( 9 ) ;
22
+ } ) ;
23
+
24
+ } ) ;
Original file line number Diff line number Diff line change 1
- ### Page Two Title
2
- Page two description .
1
+ ### Divide & Multiply
2
+ Writing basic functions continued .
3
3
4
- More about page two.
4
+ We'll write two more basic functions, this time without any help .
5
5
6
- + write a function that does something.
6
+ + write a function ` divideOne ` divides a number by 1
7
7
@test ('chapter-01/page-02/task-01')
8
8
9
- + write some other function
9
+ + write a function ` mutiplyone ` that multiplies a number by 1
10
10
@test ('chapter-01/page-02/task-02')
Original file line number Diff line number Diff line change 1
- console . log ( 'page one test' ) ;
1
+ var expect = require ( 'chai' ) . expect ;
2
+ var context = require ( 'test-context' ) ;
3
+ context ( '../../../example.js' ) ;
4
+
5
+ describe ( 'divideOne' , function ( ) {
6
+
7
+ it ( 'doesn\'t exist' , function ( ) {
8
+ expect ( divideOne ) . to . not . be . undefined ;
9
+ } ) ;
10
+
11
+ it ( 'doesn\'t take any parameters' , function ( ) {
12
+ expect ( divideOne . length ) . to . be . above ( 0 ) ;
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 ) ;
22
+ } ) ;
23
+
24
+ } ) ;
Original file line number Diff line number Diff line change
1
+ var expect = require ( 'chai' ) . expect ;
2
+ var context = require ( 'test-context' ) ;
3
+ context ( '../../../example.js' ) ;
4
+
5
+ describe ( 'multiplyOne' , function ( ) {
6
+
7
+ it ( 'doesn\'t exist' , function ( ) {
8
+ expect ( multiplyOne ) . to . not . be . undefined ;
9
+ } ) ;
10
+
11
+ it ( 'doesn\'t take any parameters' , function ( ) {
12
+ expect ( multiplyOne . length ) . to . be . above ( 0 ) ;
13
+ } ) ;
14
+
15
+ it ( 'doesn\'t output a number' , function ( ) {
16
+ expect ( multiplyOne ( 1 ) ) . to . be . a ( 'number' ) ;
17
+ } ) ;
18
+
19
+ it ( 'returns the multiplied number by one' , function ( ) {
20
+ expect ( multiplyOne ( 1 ) ) . to . equal ( 1 ) ;
21
+ expect ( multiplyOne ( 10 ) ) . to . equal ( 10 ) ;
22
+ } ) ;
23
+
24
+ } ) ;
You can’t perform that action at this time.
0 commit comments