Skip to content

Instantly share code, notes, and snippets.

@Alan01252
Created July 19, 2012 09:22
Show Gist options
  • Save Alan01252/3142624 to your computer and use it in GitHub Desktop.
Save Alan01252/3142624 to your computer and use it in GitHub Desktop.
var should = require('should'),
symbleApi = require('./lib/symbleApi.js');
var BaseTest = {
_error:null,
_response:null,
_body:null,
_json:null,
performCreateTests:function(){
var _self = this;
describe('Test standard requests',function(done) {
before(function(done){
symbleApi.create(_self.collection, _self.document, function (error, response, body) {
_self._error = error;
_self._response = response;
_self._body = body;
_self._json = JSON.parse(body);
done();
})
});
it("Request should be failing",function(){
_self._response.statusCode.should.equal(500);
});
it("Should Respond with valid JSON",function(){
_self._response.should.be.json;
});
it("Should Respond with an array of failed validators",function(){
_self._json.should.have.property('message');
_self._json.message.should.be.equal('Validation failed');
_self._json.should.have.property('errors');
_self._json.errors.should.be.an.instanceOf(Object);
});
_self.performOtherCreateTests();
});
}
}
var AccountTest = BaseTest;
AccountTest.collection = 'account';
AccountTest.document = {'name' : 'Code Monkey account',
'tier' : "1",
'type' : "1",
"isActive" : 1,
"idStaff" : "4f549611395a64506be52490"
};
AccountTest.rules = {
'name':'required',
'tier':'required',
'type':'required',
'isActive' : 'required'
}
AccountTest.performOtherCreateTests = function() {
var _self = this;
it("Should Respond with valid JSON",function(done){
_self._response.should.be.json;
done();
});
}
AccountTest.performCreateTests();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment