Created
June 8, 2016 17:41
-
-
Save daniellizik-sc/6ebd5b567b734f2cb4c07dab62c75b77 to your computer and use it in GitHub Desktop.
__scd.b.i spec, check for malformed item properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
($specs => { | |
'use strict'; | |
console.group('%c__scd.b.i spec, check for malformed item properties', 'font-weight:900;font-size:1.4em') | |
$specs().forEach(t => { | |
console.log(`%c${t.msg}`, 'color:grey;font-weight:900'); | |
console.log(`%c${t.res === true ? '[PASS]' : '[FAIL]'} actual: ${t.actual}`, `color:${t.res === true ? 'blue' : 'red'}`); | |
}); | |
console.groupEnd(); | |
})(() => { | |
const reduce = property => window.__scd.b.i.reduce((acc, item) => { | |
if (item.hasOwnProperty(property)) { | |
acc.push({ property, val: item[property] }); | |
} | |
return acc; | |
}, []); | |
const basket_i = reduce('i'); | |
const basket_v = reduce('v'); | |
const basket_q = reduce('q'); | |
const basket_u = reduce('u'); | |
const basket_n = reduce('n'); | |
const basket_f1 = reduce('f1'); | |
return [ | |
{ | |
actual: JSON.stringify(basket_i), | |
res: basket_i.length === __scd.b.i.length, | |
msg: 'basket items must have i property' | |
}, | |
{ | |
actual: JSON.stringify(basket_v), | |
res: basket_v.length === __scd.b.i.length, | |
msg: 'basket items must have v property' | |
}, | |
{ | |
actual: JSON.stringify(basket_q), | |
res: basket_q.length === __scd.b.i.length, | |
msg: 'basket items must have q property' | |
}, | |
{ | |
actual: JSON.stringify(basket_u), | |
res: basket_u.length === __scd.b.i.length, | |
msg: 'basket items must have u property' | |
}, | |
{ | |
actual: JSON.stringify(basket_n), | |
res: basket_n.length === __scd.b.i.length, | |
msg: 'basket items must have n property' | |
}, | |
{ | |
actual: JSON.stringify(basket_f1), | |
res: basket_f1.length === __scd.b.i.length, | |
msg: 'basket items must have f1 property' | |
}, | |
] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment