@@ -31,10 +31,6 @@ context('Async Map Sort', () => {
3131 ) ) ;
3232 } ) ;
3333
34- describe ( 'Given no comparisonFunction' , ( ) => {
35- // It should map and then sort by unicode
36- } ) ;
37-
3834 describe ( 'Given a synchronous mappingFunction' , ( ) => {
3935 let result , mappingFunction , mapSortedArray ;
4036
@@ -47,18 +43,16 @@ context('Async Map Sort', () => {
4743 it ( 'Should run each mappingFunction in order' , ( ) =>
4844 ranCallbacksInOrder ( result ) ) ;
4945
50- it ( 'Should map each item in order' , async ( ) => {
51- mapSortedArray . every ( ( item , index ) =>
52- expect ( item ) . to . equal ( array [ index ] )
53- ) ;
54- } ) ;
55-
5646 it ( 'Should resolve to a new array' , async ( ) => {
5747 expect ( mapSortedArray ) . to . not . equal ( array ) ;
5848 } ) ;
5949
6050 it ( 'Should sort by unicode after mapping' , async ( ) => {
61- // should sort by unicode
51+ const expectedResult = mapSortedArray . slice ( ) . sort ( ) ;
52+
53+ expectedResult . every ( ( item , index ) =>
54+ expect ( mapSortedArray [ index ] ) . to . equal ( item )
55+ ) ;
6256 } ) ;
6357 } ) ;
6458
@@ -76,18 +70,16 @@ context('Async Map Sort', () => {
7670 it ( 'Should run each mappingFunction in order' , ( ) =>
7771 ranCallbacksInOrder ( result ) ) ;
7872
79- it ( 'Should map each item in order' , async ( ) => {
80- mapSortedArray . every ( ( item , index ) =>
81- expect ( item ) . to . equal ( array [ index ] )
82- ) ;
83- } ) ;
84-
8573 it ( 'Should resolve to a new array' , async ( ) => {
8674 expect ( mapSortedArray ) . to . not . equal ( array ) ;
8775 } ) ;
8876
8977 it ( 'Should sort by unicode after mapping' , async ( ) => {
90- // should sort by unicode
78+ const expectedResult = mapSortedArray . slice ( ) . sort ( ) ;
79+
80+ expectedResult . every ( ( item , index ) =>
81+ expect ( mapSortedArray [ index ] ) . to . equal ( item )
82+ ) ;
9183 } ) ;
9284 } ) ;
9385
@@ -123,26 +115,23 @@ context('Async Map Sort', () => {
123115 ] ) ) ;
124116 } ) ;
125117
126- describe ( 'Given the optional comparisonFunction parameter ' , ( ) => {
127- let result , mappingFunction , mapSortedArray , comparisonFunction ;
118+ describe ( 'Given an optional comparisonFunction that uses all arguments ' , ( ) => {
119+ let result , mappingFunction , comparisonFunction ;
128120
129121 beforeEach ( async ( ) => {
130122 ( { callback : mappingFunction } = getCallback ( ) ) ;
131123 ( { result, callback : comparisonFunction } = getCallback ( {
132124 isSort : true
133125 } ) ) ;
134126
135- mapSortedArray = await asyncMapSort (
136- array ,
137- mappingFunction ,
138- comparisonFunction
139- ) ;
127+ await asyncMapSort ( array , mappingFunction , comparisonFunction ) ;
140128 } ) ;
141129
142- it ( 'Should sort by the given comparisonFunction after mapping' , async ( ) => {
143- expect ( mapSortedArray ) ;
144- expect ( result ) ;
145- // returned array should have correct ordering given the comparison
146- } ) ;
130+ it ( 'Should have access to first and second elements' , ( ) =>
131+ result . every ( ( { firstEl, secondEl } ) =>
132+ expect ( array )
133+ . to . contain ( firstEl )
134+ . and . contain ( secondEl )
135+ ) ) ;
147136 } ) ;
148137} ) ;
0 commit comments