We will look at a previous project called circleci-jobs-example (https://github.com/packtci/circleci-jobs-example) that has several unit tests that have been written to test individual functions. In the repository, we have a file called sort.js that has the following function in it:
/ Takes an array of objects and sorts by First Name function sortListOfNames(names) { return names.sort((a, b) => { if (a.firstName < b.firstName) { return -1; } if (a.firstName > b.firstName) { return 1; } if (a.firstName === b.firstName) { return 0; } }); }
This function takes an array of objects and sorts the objects by the firstName attribute. For our unit test, we simply want to test that the sortListOfNames function will sort the first ...