Skip to content

Commit

Permalink
Changed function name to be more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
MilosPaunovic committed Apr 25, 2021
1 parent 6b63f41 commit 0d36df4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const randomer = require('complete-randomer');
randomer.NUMBER.INTEGER(min, max);

// Random string
randomer.STRING.WORD(length);
randomer.STRING.GIBBERISH(length);

// Random boolean
randomer.BOOLEAN.IS();
Expand Down
2 changes: 1 addition & 1 deletion modules/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @param {Number} length Number of character for your random string
* @return {String} Resulting string
*/
exports.WORD = function (length) {
exports.GIBBERISH = function (length) {
// Arguments checking
if (arguments.length !== 1) throw new TypeError('One parameter required');

Expand Down
12 changes: 6 additions & 6 deletions test/string.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
const { assert } = require('chai');
const { WORD } = require('../modules/string');
const { GIBBERISH } = require('../modules/string');

describe('STRING()', function () {
it('Should throw TypeError if less than 1 parameter is sent', function () {
assert.throw(() => { WORD() }, TypeError, 'One parameter required');
assert.throw(() => { GIBBERISH() }, TypeError, 'One parameter required');
});

it('Should throw TypeError if more than 2 parameter are sent', function () {
assert.throw(() => { WORD(1, 2) }, TypeError, 'One parameter required');
assert.throw(() => { GIBBERISH(1, 2) }, TypeError, 'One parameter required');
});

it('Should throw TypeError if parameter is not Number', function () {
assert.throw(() => { WORD(true) }, TypeError, 'Length parameter must be Number');
assert.throw(() => { GIBBERISH(true) }, TypeError, 'Length parameter must be Number');
});

it('Should return random string consisting of 30 character', function () {
const result = WORD(30);
const result = GIBBERISH(30);
assert.lengthOf(result, 30);
});

it('Should test if returned value is Number', function () {
const result = WORD(30);
const result = GIBBERISH(30);
assert.isString(result);
});
});

0 comments on commit 0d36df4

Please sign in to comment.