Creating multiple tests and expectations
This time, we'll create and test the collection utility module. Create the CollectionUtils.js
file in the ~/snapterest/source/utils/
directory:
import TweetUtils from './TweetUtils'; function getNumberOfTweetsInCollection(collection) { const listOfCollectionTweetIds = TweetUtils .getListOfTweetIds(collection); return listOfCollectionTweetIds.length; } function isEmptyCollection(collection) { return getNumberOfTweetsInCollection(collection) === 0; } export default { getNumberOfTweetsInCollection, isEmptyCollection };
The CollectionUtils
module has two functions: getNumberOfTweetsInCollection()
and isEmptyCollection()
.
First, let's discuss getNumberOfTweetsInCollection()
:
function getNumberOfTweetsInCollection(collection) { const listOfCollectionTweetIds = TweetUtils .getListOfTweetIds(collection); return listOfCollectionTweetIds.length; }
As you can see, this function calls the getListOfTweetIds()
method from...