1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-24 00:11:29 +00:00

Added in full test coverage of current spec

This commit is contained in:
Scott Tolksdorf
2017-01-06 17:45:48 -05:00
parent 987363ed41
commit ca40ec5a2d
14 changed files with 413 additions and 170 deletions

View File

@@ -1,17 +1,17 @@
const _ = require('lodash');
module.exports = {
getGoodBrewTitle : (text) => {
getGoodBrewTitle : (text = '') => {
const titlePos = text.indexOf('# ');
if(titlePos !== -1){
const ending = text.indexOf('\n', titlePos);
return text.substring(titlePos + 2, ending);
let ending = text.indexOf('\n', titlePos);
ending = (ending == -1 ? undefined : ending);
return text.substring(titlePos + 2, ending).trim();
}else{
return _.find(text.split('\n'), (line)=>{
return (_.find(text.split('\n'), (line)=>{
return line;
});
}) || '').trim();
}
},
replaceByMap : (text, mapping) => {