Skip to content

Instantly share code, notes, and snippets.

@mike-north
Created October 9, 2015 18:50
Show Gist options
  • Select an option

  • Save mike-north/0b28b2e1e764fdab13a8 to your computer and use it in GitHub Desktop.

Select an option

Save mike-north/0b28b2e1e764fdab13a8 to your computer and use it in GitHub Desktop.
function json(obj, status=200) {
return [status, { 'Content-Type' : 'text/json'}, JSON.stringify(obj)];
}
var server = new Pretender(function(){
this.get('https://api.github.com/orgs/:id',
() => json({
id: 99,
login: 'emberjs',
name: 'Ember.js'
}));
this.get('https://api.github.com/orgs/:id/:repoid',
() => json([{
id: 123,
name: 'data'
}]));
this.get('https://api.github.com/repos/:id/:repoid',
() => json({
id: 123,
name: 'data'
}));
this.get('https://api.github.com/repos/:id/:repoid/issues',
() => json([
{id: 1, title: 'Issue 1'},
{id: 2, title: 'Issue 2'}
]));
this.get('https://api.github.com/repos/:id/:repoid/contributors',
() => json([
{id: 1, login: 'contributor1'},
{id: 2, login: 'contributor2'}
]));
});
// after each test is done
server.shutdown();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment