Dependencies
Installing via npm
or bower
will bring in the above dependencies as well.
npm
$ npm install leonardojs
bower
$ bower install leonardo
Angular (tested with v1.3) Angular Mocks module (tested with v1.3)
<!DOCTYPE HTML>
<html>
<body ng-app="app">
//.....
<script src="[bower_componenets|node_modules|other]/angular/angular.js"></script>
<script src="[bower_componenets|node_modules|other]/angular-mocks/angular-mocks.js"></script>
//.....
<script src="[bower_componenets|node_modules|other]/leonardo/leonardo.js"></script>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
//.....
<link rel="stylesheet" media="all" href="[bower_componenets|node_modules|other]/leonardo/leonardo.min.css" />
</head>
</html>
<!DOCTYPE HTML>
<html>
<body ng-app="app">
//.....
<script>
var myApp = angular.module("app", ["leonardo"]);
//.....
</script>
</body>
</html>
<!DOCTYPE HTML>
<html>
<body ng-app="app" leo-activator>
//.....
</body>
</html>
//.....
myApp.run(["leoConfiguration", function(leoConfiguration){
leoConfiguration.addStates([
{
name: 'Get Data',
url: '/api/user/43435',
options: [
{name: 'success', status: 200, data: { name: "Master Splinter" }},
{name: 'error 500', status: 500},
{name: 'error 401', status: 401}
]
},
{
name: 'Update Data',
url: '/api/user/43435',
verb: 'PUT',
options: [
{name: 'success', status: 200},
{name: 'error 500', status: 500},
{name: 'error 400', status: 400}
]
}
]);
}]);
Activates state option, mocked response will be returned when calling the state url
//.....
leoConfiguration.activateStateOption('Update Data', 'success');
$http.put('/api/user/43435', { name: "Master Splinter" }).success(function(data, status) {
console.log(status); // 200
});
leoConfiguration.activateStateOption('Update Data', 'error 500');
$http.put('/api/user/43435', { name: "Master Splinter" }).error(function(data, status) {
console.log(status); // 500
});
//.....
Deactivates a specific state, when calling the state url request will pass through to the server
//.....
leoConfiguration.deactivateState('Update Data');
//.....
http://outbrain.github.io/Leonardo/docs/configuration.srv.html
cd
into the project folder
npm run compile
This compiles the code as well as documentation.
To automatically recompile the files on each change run
npm run compile:watch
Note that this does not recompile the documentation.
Note that this does not auto-refreshes the browser.
Running npm run compile
compiles the documentation. But if you need to recompile it later also,
(for example when running with gulp watch
) run
npm run compile:docs
Run local server and navigate to index.html
.
or cd
into the project folder
gulp serve
Copyright © 2015 MIT License