silverstripe-framework/thirdparty/jquery-entwine/vendor/jspec/spec/spec.jquery.xhr.js
Ingo Schommer 8256228e69 MINOR Upgraded jQuery.entwine (formerly known as jQuery.concrete) to the latest trunk
MINOR Updated jQuery.concrete references to point to the new "entwine" name

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102695 467b73ca-7a2a-4603-9d3b-597d59a354a9
2010-04-13 05:45:29 +00:00

65 lines
1.7 KiB
JavaScript

describe 'jQuery'
describe '.ajax()'
it "should call the success function when 200"
mock_request().and_return('{ foo: "bar" }', 'application/json')
var successCalled = false
$.ajax({
type: "POST",
url: 'foo',
dataType: 'json',
success: function() {
successCalled = true
}
})
successCalled.should.be_true
end
it "should call the error function when 404"
mock_request().and_return('{ foo: "bar" }', 'application/json', 404)
var errorCalled = false
$.ajax({
type: "POST",
url: 'foo',
dataType: 'json',
error: function() {
errorCalled = true
}
})
errorCalled.should.be_true
end
end
describe '.getJSON()'
it 'should work with mockRequest'
mockRequest().and_return('{ foo : "bar" }')
$.getJSON('foo', function(response, statusText){
response.foo.should.eql 'bar'
statusText.should.eql 'success'
})
end
it 'should work with a json fixture'
mockRequest().and_return(fixture('test.json'))
$.getJSON('foo', function(response){
response.users.tj.email.should.eql 'tj@vision-media.ca'
})
end
it 'should not invoke callback when response status is 4xx'
mockRequest().and_return('foo', 'text/plain', 404)
$.getJSON('foo', function(){
fail('callback was invoked')
})
end
end
describe '.post()'
it 'should work with mockRequest'
mockRequest().and_return('<p></p>', 'text/html')
$.post('foo', function(response){
response.should.eql '<p></p>'
})
end
end
end