Morning, I'm trying to mock the each() function on...
# suitescript
c
Morning, I'm trying to mock the each() function on SSv2 Search module and I can't get it right. I posted a question to SO here: https://stackoverflow.com/questions/59969278/how-can-i-create-a-function-instance-of-this-typescript-interface I've been beating my head on this for too long!
b
not typescript, and not specifically for jest
Copy code
function ResultSetStub(searchResultStubs) {
		this.each = sinon.stub().callsFake(function(callback) {
			var i = 0;
			var continueEach;
			do {
				continueEach = callback(searchResultStubs[i]);
				i++;
			} while (i < searchResultStubs.length && continueEach);
		});
	}
c
@battk I appreciate the help.
b
if i had to make a promise version, i would just do the same thing and return a Promise that uses setTimeout to resolve at some future point in time