Мне нравится этот путь!
//encode your data into JSON and send the response
$this->_helper->json($myArrayofData);
//nothing else will get executed after the line above
Вы на самом деле не прикрепили функцию add()
к MyObjectFactory
. Попробуйте что-то вроде этого:
describe("The launchTask function", () => {
let spyObj;
beforeEach(() => {
global.external.MyObjectFactory= jasmine.any(Function);
spyObj = jasmine.createSpyObj(["add"]);
spyOn(global.external, 'MyObjectFactory').and.returnValue(spyObj);
});
it("Scene 1", () => {
launchTask(123);
expect(global.external.MyObjectFactory).toHaveBeenCalledWith("INDEXED");
expect(spyObj.add).toHaveBeenCalledWith(123);
});
});