describe('.getComment', function() { this.timeout(10000); this.slow(10000); beforeEach(() => (gists = new Gists(auth))); it('should get a comment for a gist using id on options', function() { return gists.getComment('3b7a6e680ea8aa0395d92d18304e575e', '2347999') .then(res => assert.equal(res.body.body, 'this is a comment')); }); });
describe('.getUser', function () { it('should return a particular user from the user collection', function () { this.slow(200); return request(app) .get('/api/users/' +ID) .then((res) => { expect(res).to.have.status(200); expect(res.body).to.not.be.null.and.not.be.undefined; }); }); });
describe('setImmediate', function () { this.slow(RANDOM_GAP * 3); this.timeout(RANDOM_GAP * 4); it('setImmediate - Execution time', function (done) { const time = Date.now(); job.setImmediate((ready) => { // console.log('IMMEDIATE', Date.now() - time, ((RANDOM_GAP * 2) + 1), Date.now() - time < ((RANDOM_GAP * 2) + 1)); assert.equal(Date.now() - time < ((RANDOM_GAP * 2) + 1), true, 'setImmediate - executed within appropriate time'); ready(); done(); }, 'taskImmediate-0'); }); });
describe('.deleteUsers', function () { it('should delete a user from the user collection', function () { this.slow(200); return request(app) .delete('/api/users/' +ID) .set('x-access-token', token) .then((res) => { expect(res).to.have.status(200); expect(res.body).to.not.be.null.and.not.be.undefined; }); }); });
describe('setInterval', function () { this.slow(30000); this.timeout(32000); testInterval(1000); testInterval(1001); testInterval(1002); testInterval(1003); testInterval(1004); testInterval(1005); testInterval(1006); testInterval(1007); testInterval(1008); testInterval(1009); });
describe('.putUsers', function () { it('should update user info in the database', function () { this.slow(200); return request(app) .put('/api/users/' +ID) .set('x-access-token', token) .set('Content-Type', 'application/json') .send({ name: 'randomuser' }) .then((res) => { expect(res).to.have.status(200); expect(res.body).to.not.be.null.and.not.be.undefined; }); }); });
describe('setTimeout', function () { this.slow(14000); this.timeout(16000); testTimeout(1000); testTimeout(1001); testTimeout(1002); testTimeout(1003); testTimeout(1004); testTimeout(1005); testTimeout(1006); testTimeout(1007); testTimeout(1008); testTimeout(1009); });
describe('stars', function() { this.timeout(10000); this.slow(10000); beforeEach(() => (gists = new Gists(auth))); it('should star and unstar a gist using id on args', function() { return gists.star('3b7a6e680ea8aa0395d92d18304e575e') .then(() => gists.isStarred('3b7a6e680ea8aa0395d92d18304e575e')) .then(res => assert(res)) .then(() => gists.unstar('3b7a6e680ea8aa0395d92d18304e575e')) .then(() => gists.isStarred('3b7a6e680ea8aa0395d92d18304e575e')) .then(res => assert(!res)); }); });
describe('.list', function() { this.timeout(10000); this.slow(10000); beforeEach(() => (gists = new Gists(auth))); it('should return a list of gists for the user passed on args', function() { return gists.list('doowb') .then(res => { assert(Array.isArray(res.body)); assert(res.body[0]); assert.equal(typeof res.body[0], 'object'); assert.equal(typeof res.body[0].url, 'string'); }); }); });
describe('.get', function() { this.timeout(10000); this.slow(10000); beforeEach(() => (gists = new Gists(auth))); it('should get a gist', function() { return gists.get('3b7a6e680ea8aa0395d92d18304e575e') .then(res => assert(res.body.files.hasOwnProperty('fixture.txt'))); }); });
describe('.listComments', function() { this.timeout(10000); this.slow(10000); beforeEach(() => (gists = new Gists(auth))); it('should get all comments for a gist using id on options', function() { return gists.listComments('3b7a6e680ea8aa0395d92d18304e575e') .then(res => { assert(Array.isArray(res.body)); assert.equal(res.body[0].body, 'this is a comment'); }); }); });
describe('setInterval', function () { this.slow(30000); this.timeout(62000); testInterval(1024, job); testInterval(1032, job); testInterval(1040, job); testInterval(1048, job); testInterval(1056, job); testInterval(1064, job); testInterval(1072, job); testInterval(1080, job); testInterval(1088, job); testInterval(1096, job); testInterval(1104, job); });
describe('setTimeout', function () { this.slow(14000); this.timeout(26000); testTimeout(1024, job); testTimeout(1032, job); testTimeout(1040, job); testTimeout(1048, job); testTimeout(1056, job); testTimeout(1064, job); testTimeout(1072, job); testTimeout(1080, job); testTimeout(1088, job); testTimeout(1096, job); testTimeout(1104, job); });
describe('.getUsers', function () { it('should return users from the user collection', function () { this.slow(200); return request(app) .get('/api/users') .then((res) => { expect(res).to.have.status(200); expect(res.body).to.not.be.null.and.not.be.undefined; }); }); });
describe('setImmediate', function () { this.slow(RANDOM_GAP * 3); this.timeout(RANDOM_GAP * 4); it('setImmediate - Execution time', function (done) { const time = Date.now(); cron.setImmediate((ready) => { // console.log('IMMEDIATE', Date.now() - time, ((RANDOM_GAP * 2) + 1), Date.now() - time < ((RANDOM_GAP * 2) + 1)); assert.equal(Date.now() - time < ((RANDOM_GAP * 2) + 1), true, 'setImmediate - executed within appropriate time'); ready(); done(); }, 'taskImmediate-0'); }); });