File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
33var expect = require ( 'chai' ) . expect ;
4+ var starWarsNames = require ( '.' ) ;
45
56describe ( 'starwars-names' , function ( ) {
6- it ( 'should work' , function ( ) {
7- expect ( true ) . to . be . true
7+ it ( 'should have a list of all available names' , function ( ) {
8+ expect ( starWarsNames . all ) . to . satisfy ( isArrayOfStrings ) ;
9+ } ) ;
10+
11+ it ( 'should allow me to get a random name from the list' , function ( ) {
12+ expect ( starWarsNames . random ( ) ) . to . satisfy ( isIncludedIn ( starWarsNames . all ) ) ;
813 } ) ;
914} ) ;
15+
16+ function isArrayOfStrings ( array ) {
17+ return array . every ( function ( i ) {
18+ return typeof i === 'string' ;
19+ } ) ;
20+ }
21+
22+ function isIncludedIn ( array ) {
23+ return function ( item ) {
24+ return array . includes ( item ) ;
25+ } ;
26+ }
You can’t perform that action at this time.
0 commit comments