1- const { getArray } = require ( './support/data-factory' ) ,
1+ const { expect } = require ( './support/chai' ) ,
2+ { getArray } = require ( './support/data-factory' ) ,
23 { getCallback } = require ( './support/helpers' ) ,
34 {
45 rejectsWithError,
@@ -31,7 +32,6 @@ context('Async Reduce', () => {
3132 } ) ;
3233
3334 describe ( 'Given a synchronous callback' , ( ) => {
34- // eslint-disable-next-line no-unused-vars
3535 let result , callback , reducedAccumulator ;
3636
3737 beforeEach ( async ( ) => {
@@ -42,20 +42,34 @@ context('Async Reduce', () => {
4242 reducedAccumulator = await asyncReduce ( array , callback ) ;
4343 } ) ;
4444
45- it ( 'Should run each callback in order' , ( ) =>
46- ranCallbacksInOrder ( result ) ) ;
45+ it ( 'Should run each callback in order' , ( ) => {
46+ ranCallbacksInOrder ( result ) ;
47+
48+ expect ( result . length ) . to . be . greaterThan (
49+ 0 ,
50+ 'No callbacks were run.'
51+ ) ;
52+ } ) ;
4753
4854 it ( 'Should reduce each item in order' , async ( ) => {
49- throw 'pending' ;
55+ array . every ( ( element , index ) => {
56+ return expect ( reducedAccumulator [ index ] ) . to . equal ( element ) ;
57+ } ) ;
5058 } ) ;
5159
5260 it ( 'Should resolve to the completed value accumulator' , async ( ) => {
53- throw 'pending' ;
61+ result . every ( ( { item } , index ) => {
62+ return expect ( reducedAccumulator [ index ] ) . to . equal ( item ) ;
63+ } ) ;
64+
65+ expect ( result . length ) . to . be . greaterThan (
66+ 0 ,
67+ 'No callbacks were run.'
68+ ) ;
5469 } ) ;
5570 } ) ;
5671
5772 describe ( 'Given an asynchronous callback' , ( ) => {
58- // eslint-disable-next-line no-unused-vars
5973 let result , callback , reducedAccumulator ;
6074
6175 beforeEach ( async ( ) => {
@@ -67,15 +81,30 @@ context('Async Reduce', () => {
6781 reducedAccumulator = await asyncReduce ( array , callback ) ;
6882 } ) ;
6983
70- it ( 'Should run each callback in order' , ( ) =>
71- ranCallbacksInOrder ( result ) ) ;
84+ it ( 'Should run each callback in order' , ( ) => {
85+ ranCallbacksInOrder ( result ) ;
86+
87+ expect ( result . length ) . to . be . greaterThan (
88+ 0 ,
89+ 'No callbacks were run.'
90+ ) ;
91+ } ) ;
7292
7393 it ( 'Should reduce each item in order' , async ( ) => {
74- throw 'pending' ;
94+ array . every ( ( element , index ) => {
95+ return expect ( reducedAccumulator [ index ] ) . to . equal ( element ) ;
96+ } ) ;
7597 } ) ;
7698
7799 it ( 'Should resolve to the completed value accumulator' , async ( ) => {
78- throw 'pending' ;
100+ result . every ( ( { item } , index ) => {
101+ return expect ( reducedAccumulator [ index ] ) . to . equal ( item ) ;
102+ } ) ;
103+
104+ expect ( result . length ) . to . be . greaterThan (
105+ 0 ,
106+ 'No callbacks were run.'
107+ ) ;
79108 } ) ;
80109 } ) ;
81110
@@ -105,17 +134,22 @@ context('Async Reduce', () => {
105134 await asyncReduce ( array , callback ) ;
106135 } ) ;
107136
108- it ( 'Should have access to accumulator, currentValue, index and array on the callback' , ( ) =>
137+ it ( 'Should have access to accumulator, currentValue, index and array on the callback' , ( ) => {
109138 hasAccessToCorrectArgumentsOnCallback ( array , result , [
110139 'accumulator' ,
111140 'currentValue' ,
112141 'index' ,
113142 'array'
114- ] ) ) ;
143+ ] ) ;
144+
145+ expect ( result . length ) . to . be . greaterThan (
146+ 0 ,
147+ 'No callbacks were run.'
148+ ) ;
149+ } ) ;
115150 } ) ;
116151
117152 describe ( 'Given the optional accumulator parameter' , ( ) => {
118- // eslint-disable-next-line no-unused-vars
119153 let result , callback , accumulator ;
120154
121155 beforeEach ( async ( ) => {
@@ -125,7 +159,17 @@ context('Async Reduce', () => {
125159 } ) ;
126160
127161 it ( 'Should have accesss to accumulator on all callback iterations' , ( ) => {
128- throw 'pending' ;
162+ expect (
163+ result . every (
164+ ( { accumulator : resultAccumulator } ) =>
165+ resultAccumulator === accumulator
166+ )
167+ ) . to . be . true ;
168+
169+ expect ( result . length ) . to . be . greaterThan (
170+ 0 ,
171+ 'No callbacks were run.'
172+ ) ;
129173 } ) ;
130174 } ) ;
131175} ) ;
0 commit comments