Include Javascript client into integration test

and return the promise-like result of $.ajax for API
This commit is contained in:
xhh
2015-12-17 20:41:09 +08:00
parent 794783a4bb
commit f07b75f419
11 changed files with 424 additions and 94 deletions

View File

@@ -33,15 +33,21 @@ var createRandomPet = function() {
describe('PetApi', function() {
it('should create and get pet', function (done) {
var pet = createRandomPet();
api.addPet(pet);
api.addPet(pet).then(function() {
api.getPetById(pet.id, function(fetched, textStatus, jqXHR, error) {
if (error) throw error;
api.getPetById(pet.id, function(fetched, textStatus, jqXHR) {
expect(textStatus).to.be('success');
expect(fetched).to.be.ok();
expect(fetched.id).to.be(pet.id);
expect(fetched.getCategory()).to.be.ok();
expect(fetched.getCategory().getName()).to.be(pet.getCategory().getName());
done();
expect(textStatus).to.be('success');
expect(fetched).to.be.ok();
expect(fetched.id).to.be(pet.id);
expect(fetched.getCategory()).to.be.ok();
expect(fetched.getCategory().getName()).to.be(pet.getCategory().getName());
api.deletePet(pet.id);
done();
});
}, function(jqXHR, textStatus, errorThrown) {
throw errorThrown || textStatus;
});
});
});