Skip to content

Instantly share code, notes, and snippets.

@amboy00
Created August 21, 2015 22:40
Show Gist options
  • Save amboy00/3dd4dc344ae7fa6e8bc4 to your computer and use it in GitHub Desktop.
Save amboy00/3dd4dc344ae7fa6e8bc4 to your computer and use it in GitHub Desktop.
When I run this test, it fails - Employee Module should get Employee by ID: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
var Employee = function() {
var loadUserinfo = function(userid) {
return $.ajax({
type: 'GET',
data:{userid: userid},
url: '/employees.json',
dataType: 'json',
async: true,
success: function(data) {
return data;
}
});
};
var getData = function (userid) {
return loadUserinfo(userid).done();
};
return {
getData: getData,
};
};
(function () {
'use strict';
describe('Employee Module', function() {
var server,
employeeJSON = {
"employeeTemplate" : [
{
"userId": 1
}
]
};
before(function () {
server = sinon.fakeServer.create();
server.respondWith(
"GET",
"/employees.json",
[200, { "Content-Type": "application/json" }, JSON.stringify(employeeJSON)]
);
});
after(function () {
server.restore();
});
it('should get Employee by ID', function(done) {
var employee = new Employee(),
employeeData;
employee.getData(1).done( function (data) {
employeeData = data.employeeTemplate[0];
assert.equal(employeeData.userId, 1, 'Employee ID equals 1');
done();
});
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment