diff --git a/Account/Account.js b/Account/Account.js index c0f7d0f..d1de4e1 100644 --- a/Account/Account.js +++ b/Account/Account.js @@ -1,5 +1,5 @@ /** - * Account Manager. + * Account. * * @copyright Dennis Eichhorn * @license OMS License 1.0 diff --git a/Math/MathProcessor.js b/Math/MathProcessor.js index ed6e583..5f405dd 100644 --- a/Math/MathProcessor.js +++ b/Math/MathProcessor.js @@ -1,3 +1,11 @@ +/** + * Math formula evaluator + * + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @since 1.0.0 + */ (function (jsOMS) { "use strict"; diff --git a/Message/Response/ResponseResultType.js b/Message/Response/ResponseResultType.js deleted file mode 100644 index 68baa8d..0000000 --- a/Message/Response/ResponseResultType.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Response result type enum. - * - * @copyright Dennis Eichhorn - * @license OMS License 1.0 - * @version 1.0.0 - * @since 1.0.0 - */ -(function (jsOMS) -{ - "use strict"; - - /** @namespace jsOMS.Message.Response */ - jsOMS.Autoloader.defineNamespace('jsOMS.Message.Response'); - - jsOMS.Message.Response.ResponseResultType = Object.freeze({ - MULTI: 0, - MESSAGE: 1, - INFO: 2, - DATA: 3, - LIST: 4 - }); -}(window.jsOMS = window.jsOMS || {})); diff --git a/Models/Account.js b/Models/Account.js deleted file mode 100644 index 78d9a2c..0000000 --- a/Models/Account.js +++ /dev/null @@ -1,10 +0,0 @@ -(function (jsOMS) { - "use strict"; - - jsOMS.Account = function () { - this.login = ''; - this.password = ''; - this.id = 0; - this.auth = null; - }; -}(window.jsOMS = window.jsOMS || {})); diff --git a/Module/ModuleManager.js b/Module/ModuleManager.js index 992c5c0..3553a68 100644 --- a/Module/ModuleManager.js +++ b/Module/ModuleManager.js @@ -1,5 +1,5 @@ /** - * Module factory. + * Module manager. * * @copyright Dennis Eichhorn * @license OMS License 1.0 diff --git a/Utils/ArrayUtils.js b/Utils/ArrayUtils.js index 4490c32..ad1c59d 100644 --- a/Utils/ArrayUtils.js +++ b/Utils/ArrayUtils.js @@ -13,7 +13,7 @@ "use strict"; /** - * Trim char from string + * Get value from array/object * * @param {string} path Array path * @param {Object} data Object @@ -25,10 +25,10 @@ * * @since 1.0.0 */ - jsOMS.getArray = function(path, data, delim) + jsOMS.getArray = function(path, data, delim = '/') { - const pathParts = path.split(delim); - let current = data; + let pathParts = path.split(delim); + let current = data; for (let key in pathParts) { if (!pathParts.hasOwnProperty(key)) { @@ -39,7 +39,7 @@ return null; } - current = current[key]; + current = current[pathParts[key]]; } return current; diff --git a/Utils/StringUtils.js b/Utils/StringUtils.js index b44e995..dd12353 100644 --- a/Utils/StringUtils.js +++ b/Utils/StringUtils.js @@ -79,14 +79,15 @@ str += ''; substr += ''; - if (substr.length <= 0) { + const step = substr.length; + + if (step <= 0) { return (str.length + 1); } let n = 0, - pos = 0, - step = substr.length; - + pos = 0; + while (true) { pos = str.indexOf(substr, pos); @@ -126,14 +127,17 @@ jsOMS.strpbrk = function (haystack, chars) { - const length = haystack.length; + const length = chars.length; + let found = haystack.length; + let min = haystack.length; + for (let i = 0; i < length; ++i) { - if (chars.indexOf(haystack.charAt(i)) >= 0) { - return haystack.slice(i); + if ((found = haystack.indexOf(chars.charAt(i))) >= 0 && min > found) { + min = found; } } - return false; + return haystack.slice(min); }; jsOMS.htmlspecialchars = function (text, quotes) { diff --git a/tests/Message/Response/ResponseResultTypeTest.enum b/tests/Message/Response/ResponseResultTypeTest.enum deleted file mode 100644 index c7d20b7..0000000 --- a/tests/Message/Response/ResponseResultTypeTest.enum +++ /dev/null @@ -1,12 +0,0 @@ -describe('ResponseResultTypeTest', function () -{ - "use strict"; - - beforeEach(function () - { - }); - - afterEach(function () - { - }); -} diff --git a/tests/Message/Response/ResponseTypeTest.enum b/tests/Message/Response/ResponseTypeTest.enum deleted file mode 100644 index b6951a4..0000000 --- a/tests/Message/Response/ResponseTypeTest.enum +++ /dev/null @@ -1,12 +0,0 @@ -describe('ResponseTypeTest', function () -{ - "use strict"; - - beforeEach(function () - { - }); - - afterEach(function () - { - }); -} diff --git a/tests/Message/Response/ResponseTypeTest.js b/tests/Message/Response/ResponseTypeTest.js new file mode 100644 index 0000000..9dee8ae --- /dev/null +++ b/tests/Message/Response/ResponseTypeTest.js @@ -0,0 +1,22 @@ +describe('ResponseTypeTest', function () +{ + "use strict"; + + describe('testEnum', function () + { + it('Testing amount of enums', function () + { + expect(Object.keys(jjsOMS.Message.Response.ResponseType).length).toBe(6); + }); + + it('Testing values of enums', function () + { + expect(jjsOMS.Message.Response.ResponseType.TEXT).toBe('text'); + expect(jjsOMS.Message.Response.ResponseType.JSON).toBe('json'); + expect(jjsOMS.Message.Response.ResponseType.DOCUMENT).toBe('document'); + expect(jjsOMS.Message.Response.ResponseType.BLOB).toBe('blob'); + expect(jjsOMS.Message.Response.ResponseType.ARRAYBUFFER).toBe('arraybuffer'); + expect(jjsOMS.Message.Response.ResponseType.DEFAULT).toBe(''); + }); + }); +}); diff --git a/tests/SpecRunner.html b/tests/SpecRunner.html index 1e1ea3c..ee73102 100644 --- a/tests/SpecRunner.html +++ b/tests/SpecRunner.html @@ -47,6 +47,10 @@ + + + + @@ -74,6 +78,10 @@ + + + + diff --git a/tests/Utils/ArrayUtilsTest.js b/tests/Utils/ArrayUtilsTest.js new file mode 100644 index 0000000..8e34e2d --- /dev/null +++ b/tests/Utils/ArrayUtilsTest.js @@ -0,0 +1,28 @@ +describe('ArrayUtilsTest', function () +{ + "use strict"; + + describe('testGetArray', function () + { + it('Testing get functionality', function () + { + const expected = { + 'a' : { + 'aa' : 1, + 'ab' : [ + 'aba', + 'ab0', + [ + 3, + 'c', + ], + 4, + ], + }, + 2 : '2a', + }; + + expect(jsOMS.getArray('a/ab/1', expected)).toBe('ab0'); + }); + }); +}); \ No newline at end of file diff --git a/tests/Utils/GeneralUtilsTest.js b/tests/Utils/GeneralUtilsTest.js deleted file mode 100644 index 0434004..0000000 --- a/tests/Utils/GeneralUtilsTest.js +++ /dev/null @@ -1,12 +0,0 @@ -describe('GeneralUtilsTest', function () -{ - "use strict"; - - beforeEach(function () - { - }); - - afterEach(function () - { - }); -} diff --git a/tests/Utils/Markdown/MarkdownTest.js b/tests/Utils/Markdown/MarkdownTest.js deleted file mode 100644 index f9501d5..0000000 --- a/tests/Utils/Markdown/MarkdownTest.js +++ /dev/null @@ -1,12 +0,0 @@ -describe('MarkdownTest', function () -{ - "use strict"; - - beforeEach(function () - { - }); - - afterEach(function () - { - }); -}); diff --git a/tests/Utils/StringUtilsTest.js b/tests/Utils/StringUtilsTest.js index 35e6352..d029a43 100644 --- a/tests/Utils/StringUtilsTest.js +++ b/tests/Utils/StringUtilsTest.js @@ -2,11 +2,55 @@ describe('StringUtilsTest', function () { "use strict"; - beforeEach(function () + describe('testTrim', function () { + it('Testing trim functionality', function () + { + expect(jsOMS.trim(' hello ')).toBe('hello'); + expect(jsOMS.trim(' hello')).toBe('hello'); + expect(jsOMS.trim('hello ')).toBe('hello'); + }); + + it('Testing rtrim functionality', function () + { + expect(jsOMS.rtrim(' hello ')).toBe(' hello'); + expect(jsOMS.rtrim(' hello')).toBe(' hello'); + expect(jsOMS.rtrim('hello ')).toBe('hello'); + }); + + it('Testing ltrim functionality', function () + { + expect(jsOMS.ltrim(' hello ')).toBe('hello '); + expect(jsOMS.ltrim(' hello')).toBe('hello'); + expect(jsOMS.ltrim('hello ')).toBe('hello '); + }); }); - afterEach(function () + describe('testStrpbrk', function () { + it('Testing strpbrk functionality', function () + { + expect(jsOMS.strpbrk('This is a simple text.', 'ai')).toBe('is is a simple text.'); + expect(jsOMS.strpbrk('This is a simple text.', 'mt')).toBe('mple text.'); + expect(jsOMS.strpbrk('This is a simple text.', 'z')).toBe(''); + }); }); -} + + describe('testSubstrCount', function () + { + it('Testing substring cound functionality', function () + { + expect(jsOMS.substr_count('This is a simple text.', 'is')).toBe(2); + expect(jsOMS.substr_count('This is a simple text.', 'text')).toBe(1); + expect(jsOMS.substr_count('This is a simple text.', 'imples')).toBe(0); + }); + }); + + describe('testSpecialchars', function () + { + it('Testing htmlspecialchars functionality', function () + { + expect(jsOMS.htmlspecialchars('Test')).toBe('<a href="test">Test</a>'); + }); + }); +}); \ No newline at end of file diff --git a/tests/Utils/UiUtilsTest.js b/tests/Utils/UiUtilsTest.js deleted file mode 100644 index ecbe1cb..0000000 --- a/tests/Utils/UiUtilsTest.js +++ /dev/null @@ -1,12 +0,0 @@ -describe('UiUtilsTest', function () -{ - "use strict"; - - beforeEach(function () - { - }); - - afterEach(function () - { - }); -}