From ed454210157345bffc1bfed5bab1559aba1c71c7 Mon Sep 17 00:00:00 2001 From: Dmitry Dodzin Date: Tue, 7 May 2019 16:57:36 +0300 Subject: [PATCH] Docs and Stuff --- .doclets.yml | 2 +- .nycrc | 8 ------- DOCS.md | 19 ---------------- README.md | 64 ++++++++++++++++++++++++---------------------------- index.js | 14 ++++++++++++ package.json | 2 +- 6 files changed, 46 insertions(+), 63 deletions(-) delete mode 100644 .nycrc delete mode 100644 DOCS.md diff --git a/.doclets.yml b/.doclets.yml index bafa820..559dbd6 100644 --- a/.doclets.yml +++ b/.doclets.yml @@ -6,7 +6,7 @@ files: packageJson: package.json articles: - - Overview: DOCS.md + - Overview: README.md branches: - master diff --git a/.nycrc b/.nycrc deleted file mode 100644 index bcf6238..0000000 --- a/.nycrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "reporter" : ["text", "text-summary", "lcov", "html"], - "include" : ["lib/**/*.js"], - "require" : ["babel-register"], - "sourceMap" : false, - "instrument" : false, - "all" : true -} \ No newline at end of file diff --git a/DOCS.md b/DOCS.md deleted file mode 100644 index 00e84d3..0000000 --- a/DOCS.md +++ /dev/null @@ -1,19 +0,0 @@ - -# Lib Monkey -## 🔴 The docs are not finished yet. Please be patient =] - -Monkey Testing for libraries - -When there is a need to test code with random values - -Visit the [Github][repo] =] - -## License - -[MIT][license] © [Lib Monkey Team][author] - -[license]: LICENSE - -[author]: https://github.com/lib-monkey - -[repo]: https://github.com/lib-monkey/lib-monkey \ No newline at end of file diff --git a/README.md b/README.md index 9a81144..3233c15 100644 --- a/README.md +++ b/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 @@ -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``` @@ -91,25 +88,24 @@ 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
+> ```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)); ``` @@ -117,9 +113,9 @@ FunctionRunner is designed to run a single function multipe times while the Pipe 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 diff --git a/index.js b/index.js index ec5b6d6..2e5caab 100644 --- a/index.js +++ b/index.js @@ -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 diff --git a/package.json b/package.json index ee4bbbe..b4f96aa 100644 --- a/package.json +++ b/package.json @@ -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" },