Skip to content

Instantly share code, notes, and snippets.

@sagivf sagivf/add-ajax-state.js
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.