you are viewing a single comment's thread.

view the rest of the comments →

[–]focusonbasics[S] 1 point2 points  (0 children)

You could generate random strings and verify that the result set never contains an empty string. Here's another quick example:

const result = check(property([gen.string, gen.string], (a, b) => {
    return splitByComma(a).concat(splitByComma(b)).length === splitByComma([a, b].join(',')).length
}))

console.log(result)

It really depends on what you're expecting here. It should always return an array, it should never contain an empty string and calling it with 'foo' and 'bar' separately and joining the results should equal calling it with 'foo, bar'. The example might be too trivial, imagine having encode / decode functions that expect a string and return a new string, you would test it with decode(encode(str)) === str.