Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
idancali committed Aug 10, 2016
1 parent cf886bd commit db29e1c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,56 @@ npm run savor lint

![Example](https://raw.githubusercontent.com/idancali/savor/master/examples/example.main.2.gif)

# Working Example

[Take a look at the example](https://raw.githubusercontent.com/idancali/savor/master/examples/main) for more details on how to integrate Savor within your module.

In our example, we have a simple module in ```src/main.js``` that generates a greeting, like so:

```javascript
var main = {
createGreeting: function(name) {
return "Hello, " + name;
}
}

module.exports = main;
```

And here's how it is to test this with Savor. First, add the Savor hooks in your ```scripts``` field:

```javascript
"scripts": {
"savor": "./node_modules/.bin/savor",
"test": "./node_modules/.bin/savor test",
"lint": "./node_modules/.bin/savor lint",
"coverage": "./node_modules/.bin/savor coverage",
"coveralls": "./node_modules/.bin/savor coveralls",
"codacy": "./node_modules/.bin/savor codacy"
}
```

Next, write your test in ```test/main.js```:

```javascript
var savor = require('savor');
var main = require('../src/main');

savor.add('should create a valid greeting', function(test, done) {
var greeting = main.createGreeting('Dan');
test.expect(greeting).to.equal("Hello, Dan");
done && done();
}).

run('Greeting Tests');
```

Then just sit back and enjoy the show:

![Example](https://raw.githubusercontent.com/idancali/savor/master/examples/example.main.1.gif)
![Example](https://raw.githubusercontent.com/idancali/savor/master/examples/example.main.2.gif)
![Example](https://raw.githubusercontent.com/idancali/savor/master/examples/example.main.3.gif)

# License

Copyright (c) 2016 I. Dan Calinescu
Expand Down
3 changes: 1 addition & 2 deletions examples/main/test/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var savor = require('savor');

var main = require('../src/main');
var main = require('../src/main');

savor.add('should create a valid greeting', function(test, done) {
var greeting = main.createGreeting('Dan');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "savor",
"version": "0.1.2",
"version": "0.1.3",
"description": "A simple way of adding tests to your Node module",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit db29e1c

Please sign in to comment.