test(aio): add tests for renderAttributes helper

This commit is contained in:
Peter Bacon Darwin
2017-05-10 14:44:43 +01:00
committed by Pete Bacon Darwin
parent c757e5794f
commit 2eca6e67e1
2 changed files with 28 additions and 2 deletions

View File

@ -92,6 +92,9 @@ module.exports = {
},
renderAttributes(attrMap) {
return Object.keys(attrMap).map(key => (attrMap[key] === true) ? ` ${key}` : ` ${key}="${attrMap[key].replace(/"/g, '"')}"`).join('');
return Object.keys(attrMap).map(key =>
attrMap[key] === false ? '' :
attrMap[key] === true ? ` ${key}` :
` ${key}="${attrMap[key].replace(/"/g, '"')}"`).join('');
}
};