kiwicopple/doctest-js

Not working with objects

kiwicopple opened this issue · 2 comments

this seems to be failing:

/**
 * @param {object} obj 
 * @private
 * @returns {string}
 *
 * @example
 * objectToQueryString({ 
 *  param1: 'hello', 
 *  param2: 'world 
 * })
 * //=>
 * 'param1=hello&param2=world'
 */
export function objectToQueryString(obj) {
  return Object.keys(obj)
    .map(param => `${param}=${this.obj[param]}`)
    .join('&')
}

Also to test :
Strings and int seem to return true

/**
 * Converts the value of an individual column
 * @param {String} columnName The column that you want to convert
 * @param {{name: String, type: String}[]} columns All of the columns
 * @param {Object} records The map of string values
 * @param {Array} skipTypes An array of types that should not be converted
 * 
 * @example
 * convertColumn(
 *  'age', 
 *  [{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}], 
 *  ['Paul', '33'], 
 *  []
 * )
 * //=>
 * 33
 * @example
 * convertColumn(
 *  'age',
 *  [{name: 'first_name', type: 'text'}, {name: 'age', type: 'int4'}],
 *  ['Paul', '33'],
 *  ['int4']
 * )
 * //=>
 * "33"
 */
export const convertColumn = (columnName, columns, records, skipTypes) => {
  let column = columns.find(x => x.name == columnName)
  if(skipTypes.includes(column.type)) return noop(records[columnName])
  else return convertCell(column.type, records[columnName])
}

Could be the new line? Worth testing without. Eg:

//=> "33"

instead of

//=>
 * "33"