Browse Source

adding comments to the tests

content-update
MSilva95 4 years ago committed by Clément
parent
commit
64871dd9b0
  1. 10
      js/tests/using-filter_test.js
  2. 34
      js/tests/using-map_test.js
  3. 42
      js/tests/using-reduce_test.js

10
js/tests/using-filter_test.js

@ -8,8 +8,8 @@ const check = ({ filterCalls }, eq, a, b) => {
return len ? result : false return len ? result : false
} }
//check that the code did use filter properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
// check that the code did use filter properly
check(ctx, eq, filterShortStateName(ctx.arr1), [ check(ctx, eq, filterShortStateName(ctx.arr1), [
'Alaska', 'Alaska',
'Hawaii', 'Hawaii',
@ -25,8 +25,8 @@ t(({ eq, ctx }) =>
]), ]),
) )
//check that the code did use filter properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
// check that the code did use filter properly
check(ctx, eq, filterStartVowel(ctx.arr1), [ check(ctx, eq, filterStartVowel(ctx.arr1), [
'Alabama', 'Alabama',
'Alaska', 'Alaska',
@ -43,8 +43,8 @@ t(({ eq, ctx }) =>
]), ]),
) )
//check that the code did use filter properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
// check that the code did use filter properly
check(ctx, eq, filter5Vowels(ctx.arr1), [ check(ctx, eq, filter5Vowels(ctx.arr1), [
'California', 'California',
'Louisiana', 'Louisiana',
@ -55,8 +55,8 @@ t(({ eq, ctx }) =>
]), ]),
) )
//check that the code did use filter properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
// check that the code did use filter properly
check(ctx, eq, filter1DistinctVowel(ctx.arr1), [ check(ctx, eq, filter1DistinctVowel(ctx.arr1), [
'Alabama', 'Alabama',
'Alaska', 'Alaska',
@ -69,8 +69,8 @@ t(({ eq, ctx }) =>
]), ]),
) )
//check that the code did use filter properly
t(({ eq, ctx }) => t(({ eq, ctx }) =>
// check that the code did use filter properly
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' },
{ tag: 'HI', name: 'Hawaii', capital: 'Honolulu', region: 'West' }, { tag: 'HI', name: 'Hawaii', capital: 'Honolulu', region: 'West' },

34
js/tests/using-map_test.js

@ -13,11 +13,13 @@ t(({ eq, ctx }) =>
'Jackson', 'Jackson',
'Utqiagvik', 'Utqiagvik',
'Albuquerque', 'Albuquerque',
]), ])
) )
//check that the code did use map properly t(({ eq, ctx }) =>
t(({ eq, ctx }) => eq(ctx.mapCalls[0], ctx.states)) // check that the code did use map properly
eq(ctx.mapCalls[0], ctx.states)
)
// upperCasingStates // upperCasingStates
t(({ eq, ctx }) => t(({ eq, ctx }) =>
@ -31,11 +33,13 @@ t(({ eq, ctx }) =>
'Ohio', 'Ohio',
'Texas', 'Texas',
'West Virginia', 'West Virginia',
]), ])
) )
//check that the code did use map properly t(({ eq, ctx }) =>
t(({ eq, ctx }) => eq(ctx.mapCalls.includes(ctx.cities), true)) // check that the code did use map properly
eq(ctx.mapCalls.includes(ctx.cities), true)
)
// fahrenheitToCelsius // fahrenheitToCelsius
t(({ eq, ctx }) => t(({ eq, ctx }) =>
@ -47,11 +51,13 @@ t(({ eq, ctx }) =>
'-13°C', '-13°C',
'21°C', '21°C',
'-19°C', '-19°C',
]), ])
) )
//check that the code did use map properly t(({ eq, ctx }) =>
t(({ eq, ctx }) => eq(ctx.mapCalls.includes(ctx.temps), true)) // check that the code did use map properly
eq(ctx.mapCalls.includes(ctx.temps), true)
)
// trimTemp // trimTemp
t(({ eq, ctx }) => t(({ eq, ctx }) =>
@ -95,11 +101,13 @@ t(({ eq, ctx }) =>
region: 'West', region: 'West',
temperature: '95°F', temperature: '95°F',
}, },
]), ])
) )
//check that the code did use map properly t(({ eq, ctx }) =>
t(({ eq, ctx }) => eq(ctx.mapCalls.includes(ctx.states), true)) // check that the code did use map properly
eq(ctx.mapCalls.includes(ctx.states), true)
)
// tempForecasts // tempForecasts
t(({ eq, ctx }) => t(({ eq, ctx }) =>
@ -113,7 +121,7 @@ t(({ eq, ctx }) =>
'21°Celsius in Jackson, Mississippi', '21°Celsius in Jackson, Mississippi',
'-19°Celsius in Utqiagvik, Alaska', '-19°Celsius in Utqiagvik, Alaska',
'35°Celsius in Albuquerque, New Mexico', '35°Celsius in Albuquerque, New Mexico',
]), ])
) )
export const setup = () => { export const setup = () => {

42
js/tests/using-reduce_test.js

@ -2,47 +2,53 @@ 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]), // check that the code did use reduce properly
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]), // check that the code did use reduce properly
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 }) =>
t(({ eq, ctx }) => eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], [])) // check that the code did use reduce properly
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]), // check that the code did use reduce properly
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]), // check that the code did use reduce properly
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]), // check that the code did use reduce properly
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]), // check that the code did use reduce properly
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 }) =>
t(({ eq, ctx }) => eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], ctx.fArr1)) // check that the code did use reduce properly
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 }) =>
t(({ eq, ctx }) => eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], ctx.fArr2)) // check that the code did use reduce properly
eq(ctx.reduceCalls[ctx.reduceCalls.length - 1], ctx.fArr2)
)
Object.freeze(tests) Object.freeze(tests)

Loading…
Cancel
Save