Skip to content

Instantly share code, notes, and snippets.

View samueljoli's full-sized avatar
🔒
lalilulelo

Samuel Joli samueljoli

🔒
lalilulelo
View GitHub Profile
@samueljoli
samueljoli / transmuteType.js
Created October 5, 2017 00:28
Joi2GQL example
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) => {
@samueljoli
samueljoli / skywalker.json
Created September 11, 2017 18:36
Luke Skywalker
{
"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/",
@samueljoli
samueljoli / TESB.json
Created September 11, 2017 18:30
The Empire Strikes Back
{
"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/",
var Promise = require('bluebird');
var numbers = [];
function test(){
for(var i=1; i <= 1000000; i++) {
numbers.push(i);
}
var Async = require('async');
var numbers = [];
function test(){
for(var i=1; i <= 1000000; i++) {
numbers.push(i);
}
Async.map(numbers, function(num, callback) {
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) {
const validateResult = function(){
if (this.mappedResult === 'FOOBAR') {
throw new ValidationError('unexpected status');
}
};
module.exports = validateResult
const mapResult = require('../src/helper').mapResult;
it('should create mapResult when the request is valid', function() {
return Promise
.resolve()
.bind({
resultFromXYZ : {
status : 200
}
})
const mapResult = function(){
this.mappedResult = return this.resultFromXYZ.status === 200 ? 'AWESOME' : 'FOOBAR'
};
module.exports = mapResult
const getFromXYZ = require('../src/helper').getFromXYZ;
it('should respond with good option', function() {
return Promise
.resolve()
.bind({
option: {
url: 'http://xyz.com/endpoint'
}
})