2022-08-11 17:39:37 +03:00
|
|
|
const optionsUtil = require('../../lib/utils/options');
|
2018-11-19 20:08:48 +03:00
|
|
|
|
2019-08-19 14:41:09 +03:00
|
|
|
describe('Unit: api/shared/util/options', function () {
|
|
|
|
it('returns an array with empty string when no parameters are passed', function () {
|
2018-11-19 20:08:48 +03:00
|
|
|
optionsUtil.trimAndLowerCase().should.eql(['']);
|
|
|
|
});
|
|
|
|
|
2019-08-19 14:41:09 +03:00
|
|
|
it('returns single item array', function () {
|
2018-11-19 20:08:48 +03:00
|
|
|
optionsUtil.trimAndLowerCase('butter').should.eql(['butter']);
|
|
|
|
});
|
|
|
|
|
2019-08-19 14:41:09 +03:00
|
|
|
it('returns multiple items in array', function () {
|
2018-11-19 20:08:48 +03:00
|
|
|
optionsUtil.trimAndLowerCase('peanut, butter').should.eql(['peanut', 'butter']);
|
|
|
|
});
|
|
|
|
|
2019-08-19 14:41:09 +03:00
|
|
|
it('lowercases and trims items in the string', function () {
|
2018-11-19 20:08:48 +03:00
|
|
|
optionsUtil.trimAndLowerCase(' PeanUt, buTTer ').should.eql(['peanut', 'butter']);
|
|
|
|
});
|
|
|
|
|
2019-08-19 14:41:09 +03:00
|
|
|
it('accepts parameters in form of an array', function () {
|
2018-11-19 20:08:48 +03:00
|
|
|
optionsUtil.trimAndLowerCase([' PeanUt', ' buTTer ']).should.eql(['peanut', 'butter']);
|
|
|
|
});
|
|
|
|
});
|