Supposedly, I have a public function in a scope that receives a JSRecord object, so-called currentRecord as an argument. In my implementation, I used currentRecord's bounded relation to another table, so-called the_table_foo_to_the_table_bar, to loop through and search for necessary record.
How can I mock the JSRecord as well as its bounded relation while testing?
My first idea is to define a concret object like this
- Code: Select all
var mockedCurrentRecord = [{attribute_0: value_0, attribute_1: value_1}];
and then pass it in the testing function. But when executing the test I got the error of
TypeError: Cannot call method "forEach" of undefined
Could you guys help me please?