I need to write test cases for a function which has $ as argument. But the $ argument is being used as a function and an object
<code>function test($, sf) {
let resultObj = {}
resultObj.id = setTimeout(function () {
$.ajax({
'url': URL,
'type': 'GET',
'success': function (response) {
},
'error': function () {
}
});
})
$(document).ready(function () {
$(document).ajaxSend(function () {
})
});
return {
start: function (options) {
resultObj.id(options);
}
}
}
</code>
<code>function test($, sf) {
let resultObj = {}
resultObj.id = setTimeout(function () {
$.ajax({
'url': URL,
'type': 'GET',
'success': function (response) {
},
'error': function () {
}
});
})
$(document).ready(function () {
$(document).ajaxSend(function () {
})
});
return {
start: function (options) {
resultObj.id(options);
}
}
}
</code>
function test($, sf) {
let resultObj = {}
resultObj.id = setTimeout(function () {
$.ajax({
'url': URL,
'type': 'GET',
'success': function (response) {
},
'error': function () {
}
});
})
$(document).ready(function () {
$(document).ajaxSend(function () {
})
});
return {
start: function (options) {
resultObj.id(options);
}
}
}
i tried test case like this
<code>import * as test from './function'
test((doc) => {
return {
ready: (cb) => { cb() },
ajaxSend: (cb) => { cb() }
}
})
describe("test suite", () => {
test("testing ", async () => {
});
});
</code>
<code>import * as test from './function'
test((doc) => {
return {
ready: (cb) => { cb() },
ajaxSend: (cb) => { cb() }
}
})
describe("test suite", () => {
test("testing ", async () => {
});
});
</code>
import * as test from './function'
test((doc) => {
return {
ready: (cb) => { cb() },
ajaxSend: (cb) => { cb() }
}
})
describe("test suite", () => {
test("testing ", async () => {
});
});
How can i mock $ as both function and object