File tree Expand file tree Collapse file tree 3 files changed +43
-962
lines changed Expand file tree Collapse file tree 3 files changed +43
-962
lines changed Original file line number Diff line number Diff line change @@ -12,8 +12,16 @@ if (!global.courses) {
12
12
13
13
describe ( 'var suspectData' , function ( ) {
14
14
15
+ it ( 'should have 10 items' , function ( ) {
16
+ expect ( suspectData ) . to . have . length . above ( 9 ) ;
17
+ } )
18
+
15
19
it ( 'should filter if the `indexOf` the suspects name is greater than -1' , function ( ) {
16
-
20
+ if ( suspectData . length === 10 ) {
21
+ suspectData . forEach ( function ( suspect ) {
22
+ expect ( suspect . name ) . to . equal ( 'Hack Kerr' ) ;
23
+ } ) ;
24
+ }
17
25
} ) ;
18
26
19
27
} ) ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ var path = require ( 'path' ) ;
3
+ var chai = require ( 'chai' ) ;
4
+ var spies = require ( 'chai-spies' ) ;
5
+ var expect = chai . expect ;
6
+ chai . use ( spies ) ;
7
+ var loadJS = require ( '../../common/loadJS' ) . default ;
8
+
9
+ if ( ! global . courses ) {
10
+ global . courses = JSON . parse ( JSON . stringify ( require ( '../../data/courses2.json' ) ) ) ;
11
+ }
12
+
13
+ describe ( 'var suspectData' , function ( ) {
14
+
15
+ it ( 'should filter if the `indexOf` the suspects name is greater than -1' , function ( ) {
16
+ var result = courses . map ( function ( course ) {
17
+ return course . students . map ( function ( student ) {
18
+ return {
19
+ title : course . title ,
20
+ instructor : course . instructor ,
21
+ name : student . name ,
22
+ score : student . score ,
23
+ grade : student . grade
24
+ } ;
25
+ } ) ;
26
+ } ) . flatten ( ) ;
27
+ var suspects = [ 'Hack Kerr' , 'Kevin Mitnick' , 'Albert Gonzalez' ] ;
28
+ var suspectResult = result . filter ( function ( student ) {
29
+ return suspects . indexOf ( student . name ) > - 1 ;
30
+ } ) ;
31
+ expect ( suspectData ) . to . deep . equal ( suspectResult ) ;
32
+ } ) ;
33
+
34
+ } ) ;
You can’t perform that action at this time.
0 commit comments