fsp.stat(filePath) .then((stats) => { if (stats.isFile()) { return when(filePath); } return when.reject(new Error('file not found or is a reference to a directory')); })
describe('#Spark.roomUpdate()', () => { it('returns a spark room object', () => { // skip roomUpdate if newRoomId is not set (happens if previous test fails) if (!newRoom) { this.skip(); return when.reject(new Error('dependent test failed')); } newRoom.title = '! node-sparky roomUpdate() test :: (safe to delete)'; return spark.roomUpdate(newRoom) .then(room => when(assert((validator.isRoom(room) && newRoom.title === room.title), 'invalid response'))); }); });
User.findByEmail(request.payload.email).then(function (user) { return user.comparePassword(payload.password).then(function (isMatch) { return isMatch ? Promise.resolve(user) : Promise.reject('Password not correct') }) }).then(function (user) { request.cookieAuth.set(user) return reply.redirect('/profile') }).catch(function (error) { return reply.view('login', { errormessage: error.message }) })
describe('#Spark.teamMembershipsGet(teamId)', () => { it('returns an array of spark membership objects', () => spark.teamsGet(5) .then((teams) => { if (teams && teams instanceof Array && teams.length > 0) { return when(teams[0].id); } return when.reject(new Error('No teams found for user token')); }) .then(teamId => spark.teamMembershipsGet(teamId)) .then(teamMemberships => when(assert(validator.isTeamMemberships(teamMemberships), 'invalid response')))); });
/** * List resources in the container. * @param {String} container container name * @return {Promise} Promise of the action */ var _listContainer = function (container) { return nodefn.call(client.list, {prefix: container}) .then(function (data) { return when.resolve(_.pluck(data.contents, 'key')) }, function (err) { logger.error('Error while listing data from S3 container: %s', container, err) return when.reject(err) }) }
describe('#Spark.licenseGet(licenseId)', () => { it('returns spark license object', () => { // skip licensesGet if orgLicenses is not defined if (!(orgLicenses instanceof Array && orgLicenses.length > 0)) { this.skip(); return when.reject(new Error('org licenses not found')); } return spark.licenseGet(orgLicenses[0].id) .then(license => when(assert(validator.isLicense(license), 'invalid response'))); }); });
strPayload.then((pl) => { hmac.update(pl); if (cryptoTimingSafeEqualStr(signature, hmac.digest('hex'))) { return when(payload); } return when.reject(new Error('received an invalid payload')); })
describe('#Spark.roomRemove()', () => { it('returns a successful response', () => { // skip roomRemove if newRoomId is not set (happens if previous test fails) if (!newRoom) { this.skip(); return when.reject(new Error('dependent test failed')); } return spark.roomRemove(newRoom.id) .then(ok => when(assert(ok, 'invalid response'))); }); });
fsp.stat(dirPath) .then((stats) => { if (stats.isDir()) { return when(dirPath); } return when.reject(new Error('dir not found or is a reference to a file')); })
describe('#Spark.roomGet(roomId)', () => { it('returns a spark room object', () => { // skip roomGet if personRooms is not defined if (!(personRooms instanceof Array && personRooms.length > 0)) { this.skip(); return when.reject(new Error('dependent test failed')); } return spark.roomGet(personRooms[0].id) .then(room => when(assert(validator.isRoom(room), 'invalid response'))); }); });
describe('#Spark.membershipGet(membershipId)', () => { it('returns a spark membership object', () => { // skip membershipGet if personMemberships is not defined if (!(personMemberships instanceof Array && personMemberships.length > 0)) { this.skip(); return when.reject(new Error('membership not found')); } return spark.membershipGet(personMemberships[0].id) .then(membership => when(assert(validator.isMembership(membership), 'invalid response'))); }); });
describe('#Spark.eventGet(eventId)', () => { it('returns spark event object', () => { if (!(orgEvents instanceof Array && orgEvents.length > 0)) { this.skip(); return when.reject(new Error('org events not found')); } return spark.eventGet(orgEvents[0].id) .then(event => when(assert(validator.isEvent(event), 'invalid response'))); }); });