Browse Source

adding comments to the tests

pull/581/head
MSilva95 4 years ago committed by Clément
parent
commit
9d4be8c198
  1. 10
      js/tests/using-filter_test.js
  2. 4
      js/tests/using-map_test.js
  3. 9
      js/tests/using-reduce_test.js

10
js/tests/using-filter_test.js

@ -7,7 +7,7 @@ const check = ({ filterCalls }, eq, a, b) => {
filterCalls.length = 0 filterCalls.length = 0
return len ? result : false return len ? result : false
} }
//check that the code did use filter properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
check(ctx, eq, filterShortStateName(ctx.arr1), [ check(ctx, eq, filterShortStateName(ctx.arr1), [
'Alaska', 'Alaska',
@ -23,7 +23,7 @@ t(({ eq, ctx }) =>
'Utah', 'Utah',
]), ]),
) )
//check that the code did use filter properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
check(ctx, eq, filterStartVowel(ctx.arr1), [ check(ctx, eq, filterStartVowel(ctx.arr1), [
'Alabama', 'Alabama',
@ -40,7 +40,7 @@ t(({ eq, ctx }) =>
'Utah', 'Utah',
]), ]),
) )
//check that the code did use filter properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
check(ctx, eq, filter5Vowels(ctx.arr1), [ check(ctx, eq, filter5Vowels(ctx.arr1), [
'California', 'California',
@ -51,7 +51,7 @@ t(({ eq, ctx }) =>
'West Virginia', 'West Virginia',
]), ]),
) )
//check that the code did use filter properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
check(ctx, eq, filter1DistinctVowel(ctx.arr1), [ check(ctx, eq, filter1DistinctVowel(ctx.arr1), [
'Alabama', 'Alabama',
@ -64,7 +64,7 @@ t(({ eq, ctx }) =>
'Tennessee', 'Tennessee',
]), ]),
) )
//check that the code did use filter properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
check(ctx, eq, multiFilter(ctx.arr2), [ check(ctx, eq, multiFilter(ctx.arr2), [
{ tag: 'CA', name: 'California', capital: 'Sacramento', region: 'West' }, { tag: 'CA', name: 'California', capital: 'Sacramento', region: 'West' },

4
js/tests/using-map_test.js

@ -16,6 +16,7 @@ t(({ eq, ctx }) =>
]), ]),
) )
//check that the code did use map properly
t(({ eq, ctx }) => eq(ctx.mapCalls[0], ctx.states)) t(({ eq, ctx }) => eq(ctx.mapCalls[0], ctx.states))
// upperCasingStates // upperCasingStates
@ -33,6 +34,7 @@ t(({ eq, ctx }) =>
]), ]),
) )
//check that the code did use map properly
t(({ eq, ctx }) => eq(ctx.mapCalls.includes(ctx.cities), true)) t(({ eq, ctx }) => eq(ctx.mapCalls.includes(ctx.cities), true))
// fahrenheitToCelsius // fahrenheitToCelsius
@ -48,6 +50,7 @@ t(({ eq, ctx }) =>
]), ]),
) )
//check that the code did use map properly
t(({ eq, ctx }) => eq(ctx.mapCalls.includes(ctx.temps), true)) t(({ eq, ctx }) => eq(ctx.mapCalls.includes(ctx.temps), true))
// trimTemp // trimTemp
@ -95,6 +98,7 @@ t(({ eq, ctx }) =>
]), ]),
) )
//check that the code did use map properly
t(({ eq, ctx }) => eq(ctx.mapCalls.includes(ctx.states), true)) t(({ eq, ctx }) => eq(ctx.mapCalls.includes(ctx.states), true))
// tempForecasts // tempForecasts

9
js/tests/using-reduce_test.js

@ -2,37 +2,46 @@ export const tests = []
const t = (f) => tests.push(f) const t = (f) => tests.push(f)
t(({ eq }) => eq(adder([1, 2, 3, 4]), 10)) t(({ eq }) => eq(adder([1, 2, 3, 4]), 10))
//check that the code did use reduce properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [1, 2, 3, 4]), eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [1, 2, 3, 4]),
) )
t(({ eq }) => eq(adder([9, 24, 7, 11, 3], 10), 64)) t(({ eq }) => eq(adder([9, 24, 7, 11, 3], 10), 64))
//check that the code did use reduce properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [9, 24, 7, 11, 3]), eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [9, 24, 7, 11, 3]),
) )
t(({ eq }) => eq(adder([]), 0)) t(({ eq }) => eq(adder([]), 0))
//check that the code did use reduce properly
t(({ eq, ctx }) => eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [])) t(({ eq, ctx }) => eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], []))
t(({ eq }) => eq(sumOrMul([29, 23, 3, 2, 25]), 135)) t(({ eq }) => eq(sumOrMul([29, 23, 3, 2, 25]), 135))
//check that the code did use reduce properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [29, 23, 3, 2, 25]), eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [29, 23, 3, 2, 25]),
) )
t(({ eq }) => eq(sumOrMul([18, 17, 7, 13, 25], 12), 278)) t(({ eq }) => eq(sumOrMul([18, 17, 7, 13, 25], 12), 278))
//check that the code did use reduce properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [18, 17, 7, 13, 25]), eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [18, 17, 7, 13, 25]),
) )
t(({ eq }) => eq(sumOrMul([8, 16, 7, 0, 32]), 0)) t(({ eq }) => eq(sumOrMul([8, 16, 7, 0, 32]), 0))
//check that the code did use reduce properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [8, 16, 7, 0, 32]), eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [8, 16, 7, 0, 32]),
) )
t(({ eq }) => eq(sumOrMul([8, 16, 7, 0, 31]), 31)) t(({ eq }) => eq(sumOrMul([8, 16, 7, 0, 31]), 31))
//check that the code did use reduce properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [8, 16, 7, 0, 31]), eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [8, 16, 7, 0, 31]),
) )
t(({ eq, ctx }) => eq(funcExec(ctx.fArr1, 10), `result: [137]`)) t(({ eq, ctx }) => eq(funcExec(ctx.fArr1, 10), `result: [137]`))
//check that the code did use reduce properly
t(({ eq, ctx }) => eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], ctx.fArr1)) t(({ eq, ctx }) => eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], ctx.fArr1))
t(({ eq, ctx }) => eq(funcExec(ctx.fArr2, 4), { result: 72, isOdd: true })) t(({ eq, ctx }) => eq(funcExec(ctx.fArr2, 4), { result: 72, isOdd: true }))
//check that the code did use reduce properly
t(({ eq, ctx }) => eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], ctx.fArr2)) t(({ eq, ctx }) => eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], ctx.fArr2))
Object.freeze(tests) Object.freeze(tests)

Loading…
Cancel
Save