Created
August 21, 2015 22:40
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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