I am new to JS unit testing and finding it challenging to understand how to effectively make use of Jasmine spies for creating meaningful tests.
it('should accept an array of shopping items', function() {
spyOn(checkObj, 'getTotal');
checkObj.getTotal([1, 2, 3]);
expect(checkObj.getTotal).toHaveBeenCalledWith(jasmine.any(Array));
});
The test example above raises a concern regarding the hardcoded call to getTotal within the spec. While I want to ensure that the parameter passed is indeed an array and not another data type, I believe hardcoding in this manner could be problematic.
I would greatly appreciate some guidance on approaching this particular testing scenario effectively.