Skip to content

Commit

Permalink
Docs and Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryDodzin committed May 7, 2019
1 parent 6c063a7 commit ed45421
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .doclets.yml
Expand Up @@ -6,7 +6,7 @@ files:
packageJson: package.json

articles:
- Overview: DOCS.md
- Overview: README.md

branches:
- master
Expand Down
8 changes: 0 additions & 8 deletions .nycrc

This file was deleted.

19 changes: 0 additions & 19 deletions DOCS.md

This file was deleted.

64 changes: 30 additions & 34 deletions README.md
@@ -1,6 +1,7 @@
# lib-monkey

[![Travis](https://img.shields.io/travis/lib-monkey/lib-monkey.svg)](https://travis-ci.org/lib-monkey/lib-monkey) [![Coveralls github](https://img.shields.io/coveralls/github/lib-monkey/lib-monkey.svg)](https://coveralls.io/github/lib-monkey/lib-monkey) [![David](https://img.shields.io/david/lib-monkey/lib-monkey.svg)](https://david-dm.org/lib-monkey/lib-monkey) [![Dependency Status](https://dependencyci.com/github/lib-monkey/lib-monkey/badge)](https://dependencyci.com/github/lib-monkey/lib-monkey) [![npm](https://img.shields.io/npm/v/lib-monkey.svg)](https://www.npmjs.com/package/lib-monkey) [![API Doc](https://doclets.io/lib-monkey/lib-monkey/master.svg)](https://doclets.io/lib-monkey/lib-monkey/master/overview)
[![Travis](https://img.shields.io/travis/lib-monkey/lib-monkey.svg)](https://travis-ci.org/lib-monkey/lib-monkey) [![Coveralls github](https://img.shields.io/coveralls/github/lib-monkey/lib-monkey.svg)](https://coveralls.io/github/lib-monkey/lib-monkey) [![David](https://img.shields.io/david/lib-monkey/lib-monkey.svg)](https://david-dm.
/lib-monkey/lib-monkey) [![Dependency Status](https://dependencyci.com/github/lib-monkey/lib-monkey/badge)](https://dependencyci.com/github/lib-monkey/lib-monkey) [![npm](https://img.shields.io/npm/v/lib-monkey.svg)](https://www.npmjs.com/package/lib-monkey) [![API Doc](https://doclets.io/lib-monkey/lib-monkey/master.svg)](https://doclets.io/lib-monkey/lib-monkey/master/overview)

Monkey Testing for libraries

Expand Down Expand Up @@ -38,33 +39,29 @@ There are multiple jokers and runners to use for the library but the basic idea

const monkey = require('lib-monkey');

monkey
.fnr
.params(monkey.int.min(0).max(10))
.register(a => {
describe('test', () => {

it('test sync or prommise', () =>
monkey.it(() => {

const a = monkey.generate(monkey.int.min(0).max(10));

// Do some tests with a as ranom value
// Will accept sync or prommise based results

})
.exec(n_times, concurrency)
.then(() => { // Passed })
.catch(err => { //There is an error })

monkey
.fnr
.params(monkey.int.min(0).max(10))
.register((a, done) => {
})
.do(n_times, concurrency));

it('test callback async', () =>
monkey.it((done) => {
const a = monkey.generate(monkey.int.min(0).max(10));

// Do some tests with a as ranom value

// Call done after async tests

})
.exec(n_times, concurrency)
.then(() => { // Passed })
.catch(err => { //There is an error })

})
.do(n_times, concurrency));
});
```

## ```Jokers```
Expand All @@ -91,35 +88,34 @@ Currently there are the following jokers:
- pick (from array), array (of jokers), map, object (deep map), typed (of specific type)


## ```Runners```
## ```monkey.it```

Currently there are two runners avialbe, ```FunctionRunner - fnr``` and ```PipedRunner - pnr```
It's basicaly every it function in every test framework, except that it's nameless and supports contexts <br/>
> ```monkey.it(fn, context)``` where fn will have it's ```this``` equal context.
FunctionRunner is designed to run a single function multipe times while the PipedRunner is designed to run several function and piping the result from one to the other
And this it will forward and enritch any assertion error that

#### Example

```javascript

monkey
.pnr
.params(monkey.natural.max(10))
.register(num => num + 1)
.register(num => num + 1)
.register(num => num + 1)
.params(monkey.syllable)
.register((num, randomSylibalValue) => console.log('Will be the original num + 3', num, randomSylibalValue))
.exec(3)
monkey.it(async () => {
const foo = monkey.generate(monkey.bool); // foo will be 50/50 true false pretty much

// Do Some tests and
})
.do(5)
.catch(err => console.error(err) || process.exit(-1));

```

## Roadmap
This project should co-exist with all the avialbe test runners like mocha or jasmin and be used as a tool for random value testing

- [x] Add more Jokers and Runners
- [ ] Add self assertion api
- [ ] ~~Add self assertion api~~
- [ ] Finish the docs
- [ ] Create code coverage for the library
- [x] Create code coverage for the library
- [x] Maybe change the api to be dot chainable


Expand Down
14 changes: 14 additions & 0 deletions index.js
Expand Up @@ -8,10 +8,24 @@ let lm = { };
monkey.ApiCreator.create(lm);
monkey.JokerCreator.create(lm);

/** Description of the function
@name it
@function
@param {function} fn Call function
@param {object|null} context call context for {fn monkey.it.fn}
*/
/** Get value from joker
@name generate
@function
@param {Joker} joker The joker to generate
*/

/**
* Lib-Monky.
* @module lib-monkey
* @autor Team of Monkeys
* @param {it} it The function to call twice
* @param {generate} generate The function to call twice
* @property {Jokers.BooleanJoker} bool - return instance of the BooleanJoker
* @property {Jokers.CharJoker} char - return instance of the CharJoker
* @property {Jokers.FloatJoker} float - return instance of the FloatJoker
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -12,7 +12,7 @@
"test": "mocha --require @babel/register",
"build": "yarn build-babel && yarn build-docs",
"build-babel": "babel lib --out-dir dist",
"build-docs": "jsdoc --readme DOCS.md -c .jsdocrc -d ./docs/ -r",
"build-docs": "jsdoc --readme README.md -c .jsdocrc -d ./docs/ -r",
"cover": "cross-env NODE_ENV=test nyc mocha",
"coveralls": "yarn cover && cat ./coverage/lcov.info | coveralls"
},
Expand Down

0 comments on commit ed45421

Please sign in to comment.