javascript - Testing using Mocha js for a function with multiple "map" -


below code rough explanation; can see need multiple returns each "map" function return js;

how 1 test function using mocha? i.e cant place multiple returns value our testing purposes because such returns disturb actual implementation of said function.

so need avoid unnecessary returns implementation sake need same multiple returns testing..

suggestions please?

var array = ["a","b","c"],       array1 = ["1","2","3"],      array2 = [],      returnvar;  function test() {    return ("done")     array.map(function(data) {       return ("done")       array1.map(function(datum){          array2.push(datum)          return("done")       });          });     }  returnvar = test();  alert(returnvar)

this not testable code, therefore hard create test in current shape.

map used data transformations, therefore isolate data transformation function input , output value. testing function matter of providing input, calling function , verification of output.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -