A test case specifies input data, execution conditions, and expected results for evaluating software behavior. For data-oriented functions, the pattern is refreshingly direct: supply data, run the function, and compare the returned data with the expected data. section 6.0 section 6.1
Build a data-oriented test case in three moves:
- Generate the input data, such as catalog data and an array of author IDs. section 6.1
- Generate the expected output data. section 6.1
- Compare the function result with the expected output, recursively comparing collections by value rather than reference. section 6.1
Test quantity should follow the function-call tree. Lower-level functions usually handle simpler data and need more cases; higher-level functions can use a minimal case when their called functions are already covered. section 6.2.3 section 6.6
Testing Catalog.authorNames
Use a minimal catalog and test an empty ID list, one known author, multiple known authors, missing catalog data, and nonexistent author IDs. Compare each returned array with its expected array using _.isEqual. section 6.2.2
Listing 6.3 The general pattern of a data-oriented test case
var dataIn = {
// input
};
var dataOut = {
// expected output
};
_.isEqual(f(dataIn), dataOut);
The general pattern makes the test case executable: define dataIn, define dataOut, and compare _.isEqual(f(dataIn), dataOut). section 6.1




















































