Skip to content

Instantly share code, notes, and snippets.

@sagivf
Last active August 29, 2015 14:27
Show Gist options
  • Save sagivf/2eef31571454c5f6441c to your computer and use it in GitHub Desktop.
Save sagivf/2eef31571454c5f6441c to your computer and use it in GitHub Desktop.
Angular DRY mocking
leoConfiguration.addStates([
{
name: 'flicker-images',
verb: "jsonp",
url: 'http://api.flickr.com/services/feeds/photos_public.gne',
options: [
{
name: 'get ninja turtles', status: 200,
data: {
"items": [
{ "id": "20054214406", "farm": 1, "title": "leo1"},
{ "id": "19896041068", "farm": 1, "title": "017580"}
]
}
},{
name: 'get ninja enemies', status: 200,
data: {
"items": [
{ "id": "20058148116", "title": "the_shredder"},
{ "id": "20102720711", "title": "the_ninjas" }
]
}
}
]
}
]);
leoConfiguration.addState({
name: 'Set Mission',
options: [
{ name: 'turtles', data: "Protect April o'neil" },
{ name: 'shredder', data: 'Destroy the ninja turtles' }
]
});
leoConfiguration.addState({
name: 'Set Mission',
options: [
{ name: 'turtles', data: "Protect April o'neil" },
{ name: 'shredder', data: 'Destroy the ninja turtles' }
]
});
$rootScope.$on('leonardo:setStates', function(){
var debug = leoConfiguration.getState('debug');
$rootScope.debug = !!debug;
});
var mission = leoConfiguration.getState('Set Mission');
$rootScope.mission = mission ? mission.data : "";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment