Skip to content

Commit f02e4c0

Browse files
committed
step 2 updated
1 parent edfacb0 commit f02e4c0

File tree

10 files changed

+63
-60
lines changed

10 files changed

+63
-60
lines changed

tutorial/00/01.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
const chai = require('chai');
32
const spies = require('chai-spies');
43
const expect = chai.expect;

tutorial/01/01.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
var expect = require('chai').expect;
32

43
const filter = require('BASE/01-filter.js');

tutorial/02/01-sort.spec.js

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

tutorial/02/01.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const expect = require('chai').expect;
2+
3+
// load('02/myBest.js', true)
4+
5+
const sort = require('BASE/02-sort.js');
6+
const compareScore = sort.__get__('compareScore');
7+
8+
describe('01 function compareScore', () => {
9+
10+
it('doesn\'t exist', () => {
11+
expect(compareScore).to.not.be.undefined;
12+
});
13+
14+
it('isn\'t a Function', () => {
15+
expect(compareScore).to.be.a('function');
16+
});
17+
18+
it('doesn\'t have two params', () => {
19+
expect(compareScore.length).to.equal(2);
20+
});
21+
22+
it('doesn\'t return 1 when b\'s score is more than a\'s', () => {
23+
expect(compareScore({
24+
score: 3
25+
}, {
26+
score: 5
27+
})).to.equal(1);
28+
});
29+
30+
});
File renamed without changes.

tutorial/02/03-sort.spec.js

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

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 function compareScore', () => {
2+
3+
it('doesn\'t return 0 when b\'s score equals a\'s', () => {
4+
expect(compareScore({score: 3}, {score: 3})).to.equal(0);
5+
});
6+
7+
});

tutorial/02/04-sort.spec.js

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

tutorial/02/04.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
describe('04 var mySorted', () => {
2+
3+
const mySorted = sort.__get__('mySorted');
4+
5+
it('doesn\'t exist', () => {
6+
expect(mySorted).to.not.be.undefined;
7+
});
8+
9+
it('doesn\'t output an array', () => {
10+
expect(mySorted).to.be.an('array');
11+
});
12+
13+
it('doesn\'t output exactly seven items', () => {
14+
expect(mySorted).to.have.length(7);
15+
});
16+
17+
it('isn\'t the right sorted data', () => {
18+
expect(mySorted[0].score).to.equal(93);
19+
expect(mySorted[6].score).to.equal(73);
20+
});
21+
22+
});

tutorial/02/sort.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Alright, now time to sort your best grades to the top.
3333
First you'll need to write a sort condition function called `compareScore`.
3434

3535
+ `compareScore` should return 1 if the first score is less than the second
36-
@test('02/01-sort')
36+
@test('02/01')
3737
@action(open('02-sort.js'))
3838
@action(set(
3939
```
@@ -55,15 +55,15 @@ function compareScore(a, b) {
5555
```
5656
))
5757
+ `compareScore` should return -1 if the first score is more than the second
58-
@test('02/02-sort')
58+
@test('02/02')
5959
@hint('set the second case to `b.score < a.score`')
6060

6161
+ `compareScore` should return 0 if the first score is the same as the second
62-
@test('02/03-sort')
62+
@test('02/03')
6363
@hint('no case is necessary, use the `default` case')
6464

6565
+ Set `mySorted` to the result of `myBest` sorted by `compareScore`
66-
@test('02/04-sort')
66+
@test('02/04')
6767
@action(insert(
6868
```
6969
// use the compare function to sort myBest

0 commit comments

Comments
 (0)