I am currently working on a jasmine specification that involves testing a jQuery plugin I created:
describe "plugins", ->
beforeEach ->
@server = sinon.fakeServer.create()
afterEach ->
@server.restore()
describe "reviewStatus", ->
it "should attach dates to content", ->
@server.respondWith("GET", "/GeneralDocument.mvc.aspx/GetDocumentParent?typeName=ncontinuity2.core.domain.Plan&documentParentUid=45f0bccb-27c9-410a-bca8-9ff900ab4c28d",
[200, {"Content-Type": "application/json"},
'{"ReviewDate":"22/09/2012","AcknowledgedDate":"05/07/2012"}'])
$('#jasmine_content').addReviewStatus('ncontinuity2.domain.Plan', "45f0bccb-27c9-410a-bca8-9ff900ab4c28")
@server.respond()
expect($('#reviewDateTab').find("strong").eq(0).length).toEqual(1)
The function addReviewStatus in my jQuery plugin is designed as follows:
do($ = jQuery) ->
$.fn.extend
addReviewStatus: (type, uid) ->
ele = @
reviewData = null
getJSON '/GeneralDocument.mvc.aspx/GetDocumentParent', {typeName: type, documentParentUid: uid},
(document) ->
console.log('document = ' + document)
compileTemplate(ele, document)
(response) ->
showErrorMessage response.responseText
#etc., etc.
In the getJSON method utilized by the plugin, an issue arises where the anonymous function callback is not being triggered. Additionally, the call to $.ajax returns a 404 not found error. Can anyone provide insight into what may be causing this problem?