This file contains hidden or 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
const schema = Joi.object().keys({ | |
title: Joi.string(), | |
director: Joi.string(), | |
actors: Joi.array(Joi.string()) | |
}); | |
const options = { | |
name: 'Film', | |
args: { id: Joi.string().guid() }, | |
resolve: (root, args) => { |
This file contains hidden or 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
{ | |
"name": "Luke Skywalker", | |
"height": "172", | |
"mass": "77", | |
"hair_color": "blond", | |
"skin_color": "fair", | |
"eye_color": "blue", | |
"birth_year": "19BBY", | |
"gender": "male", | |
"homeworld": "http://swapi.co/api/planets/1/", |
This file contains hidden or 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
{ | |
"title": "The Empire Strikes Back", | |
"episode_id": 5, | |
"opening_crawl": "It is a dark time for the\r\nRebellion. Although the Death\r\nStar has been destroyed,\r\nImperial troops have driven the\r\nRebel forces from their hidden\r\nbase and pursued them across\r\nthe galaxy.\r\n\r\nEvading the dreaded Imperial\r\nStarfleet, a group of freedom\r\nfighters led by Luke Skywalker\r\nhas established a new secret\r\nbase on the remote ice world\r\nof Hoth.\r\n\r\nThe evil lord Darth Vader,\r\nobsessed with finding young\r\nSkywalker, has dispatched\r\nthousands of remote probes into\r\nthe far reaches of space....", | |
"director": "Irvin Kershner", | |
"producer": "Gary Kurtz, Rick McCallum", | |
"release_date": "1980-05-17", | |
"characters": [ | |
"http://swapi.co/api/people/1/", | |
"http://swapi.co/api/people/2/", |
This file contains hidden or 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 Promise = require('bluebird'); | |
var numbers = []; | |
function test(){ | |
for(var i=1; i <= 1000000; i++) { | |
numbers.push(i); | |
} |
This file contains hidden or 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 Async = require('async'); | |
var numbers = []; | |
function test(){ | |
for(var i=1; i <= 1000000; i++) { | |
numbers.push(i); | |
} | |
Async.map(numbers, function(num, callback) { |
This file contains hidden or 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
const validateResult = require('../src/helper').validateResult; | |
it('should throw ValidationError when mappedResult === `FOOBAR`', function() { | |
return Promise | |
.resolve() | |
.bind({ | |
mappedResult: 'FOOBAR' | |
}) | |
.then(validateResult) | |
.catch(function(error) { |
This file contains hidden or 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
const validateResult = function(){ | |
if (this.mappedResult === 'FOOBAR') { | |
throw new ValidationError('unexpected status'); | |
} | |
}; | |
module.exports = validateResult |
This file contains hidden or 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
const mapResult = require('../src/helper').mapResult; | |
it('should create mapResult when the request is valid', function() { | |
return Promise | |
.resolve() | |
.bind({ | |
resultFromXYZ : { | |
status : 200 | |
} | |
}) |
This file contains hidden or 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
const mapResult = function(){ | |
this.mappedResult = return this.resultFromXYZ.status === 200 ? 'AWESOME' : 'FOOBAR' | |
}; | |
module.exports = mapResult |
This file contains hidden or 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
const getFromXYZ = require('../src/helper').getFromXYZ; | |
it('should respond with good option', function() { | |
return Promise | |
.resolve() | |
.bind({ | |
option: { | |
url: 'http://xyz.com/endpoint' | |
} | |
}) |