Skip to content

Commit

Permalink
Merge branch 'feature/jsdoc' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryDodzin committed Nov 3, 2017
2 parents 48d830a + b5678ed commit bbe011b
Show file tree
Hide file tree
Showing 16 changed files with 563 additions and 64 deletions.
13 changes: 13 additions & 0 deletions .doclets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

dir: lib
files:
- index.js

packageJson: package.json

articles:
- Overview: DOCS.md

branches:
- master
- dev
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ typings/
.env

# Dist Folder for the library
dist
dist


# Local docs - moved to doclet see https://doclets.io/lib-monkey/lib-monkey
docs
7 changes: 7 additions & 0 deletions .jsdocrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recurseDepth": 10,
"source": {
"include": ["index.js", "lib/"]
},
"sourceType": "module"
}
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,8 @@ typings/
# UnCompiled Code from lib
lib

# docs
docs

# package-lock
package-lock.json
19 changes: 19 additions & 0 deletions DOCS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

# 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
17 changes: 17 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,21 @@ let lm = { };
monkey.JokerCreator.create(lm);
monkey.RunnerCreator.create(lm);

/**
* Lib-Monky.
* @module lib-monkey
* @autor Team of Monkeys
* @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
* @property {Jokers.LetterJoker} letter - return instance of the LetterJoker
* @property {Jokers.NaturalJoker} natural - return instance of the NaturalJoker
* @property {Jokers.StringJoker} string - return instance of the StringJoker
* @property {Jokers.ParagraphJoker} paragraph - return instance of the ParagraphJoker
* @property {Jokers.SentenceJoker} sentence - return instance of the SentenceJoker
* @property {Jokers.DateJoker} date - return instance of the DateJoker
* @property {Jokers.HammertimeJoker} hammertime - return instance of the HammertimeJoker
* @property {Jokers.TimestampJoker} timestamp - return instance of the TimestampJoker
* @property {Jokers.TimezoneJoker} timezone - return instance of the TimezoneJoker
*/
module.exports = lm;
19 changes: 17 additions & 2 deletions lib/common/joker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ const mNullable = Symbol('nullable');
const mRandomiser = Symbol('randomiser');
const mOptions = Symbol('options');

export default class Joker {
/**
* Base Class for all jokers.
*/
class Joker {
/**
* Create the Joker
* @param {chacne} randomiser - Chance's randomiser.
* @param {object} options - preconfigured options for the Joker
*/
constructor(randomiser, options={}) {
Object.assign(this, {
[mRandomiser]: randomiser,
Expand Down Expand Up @@ -43,6 +51,11 @@ export default class Joker {
return this.toString();
}

/**
* Sets wether the joker value will be nullable or not
* @param {(number|bool)} value - defaults to 50 if true or null
* @return {Joker} self
*/
nullable(value=true) {
if(!value){
this[mNullable] = 0;
Expand All @@ -54,4 +67,6 @@ export default class Joker {
return this;
}

}
}

export default Joker;
43 changes: 40 additions & 3 deletions lib/common/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,66 @@
import throat from 'throat';
import Runable from '../common/runable';

export default class Runner {

/**
* Base Class for the runners.
*/
class Runner {

params() {
return {
register: this.register.bind(this, Array.from(arguments))
};
}

register(params, fn, ctx) {

register(params, fn, ctx) {
if(typeof params === 'function'){
[fn, params, ctx] = [params, undefined, fn]; // Rewrite the params if params is not provided
}
let runnable = new Runable(fn, params, ctx);
return this.withRunable(runnable);
}

/**
* Should create the execution quque before execution
* @abstract
* @param {number} cycles - the amount of cycles that should be executed
* @return {function[]} - self
*/
createRunQueue(cycles) {
throw new Error('Not Implemted');
}

/**
* Should register the runnable created in the Runner.register function
* @abstract
* @param {Runable} runable - runnable from Runner.register
* @see Runner#register
* @return {Runner} - self
*/
withRunable(runable) {
throw new Error('Not Implemted');
}

/**
* If there is an asserion error, this should the the added message to the error
* @abstract
* @param {any[]} params - the params passed to the executed function
* @param {object} extend - extend object passed to the runnable
* @param {Runnable} runnable - the instance of the runnable that was executed
* @return {string}
*/
asertionErrorMessage(params, extend, runnable) {
return '';
}

/**
* Execute the runner and return a promise representing the test run
* @param {number} cycles - the amount of cycles that should be executed
* @param {number} concurrency - amoun of cuncurrent runnables that can run in parallel
* @return {Promise}
*/
exec(cycles, concurrency=1) {
let i = 0;
let queue = this.createRunQueue(cycles);
Expand All @@ -48,5 +84,6 @@ export default class Runner {
}
});
}
}

}
export default Runner;
5 changes: 4 additions & 1 deletion lib/creators/joker.factory.creator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

/**
* @namespace Jokers
*/

import * as BasicJokers from '../jokers/basic';
import * as TextJokers from '../jokers/text';
import * as DateJokers from '../jokers/date';
Expand Down
Loading

0 comments on commit bbe011b

Please sign in to comment.