mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-01-11 01:48:40 +00:00
Test implementations + fixes
This commit is contained in:
parent
8d63d48fe4
commit
953dad708a
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Account Manager.
|
||||
* Account.
|
||||
*
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
|
|||
|
|
@ -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 || {}));
|
||||
|
|
@ -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 || {}));
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Module factory.
|
||||
* Module manager.
|
||||
*
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
describe('ResponseResultTypeTest', function ()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
beforeEach(function ()
|
||||
{
|
||||
});
|
||||
|
||||
afterEach(function ()
|
||||
{
|
||||
});
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
describe('ResponseTypeTest', function ()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
beforeEach(function ()
|
||||
{
|
||||
});
|
||||
|
||||
afterEach(function ()
|
||||
{
|
||||
});
|
||||
}
|
||||
22
tests/Message/Response/ResponseTypeTest.js
Normal file
22
tests/Message/Response/ResponseTypeTest.js
Normal file
|
|
@ -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('');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -47,6 +47,10 @@
|
|||
<script src="../Uri/Http.js"></script>
|
||||
<script src="../Uri/UriFactory.js"></script>
|
||||
|
||||
<script src="../Utils/ArrayUtils.js"></script>
|
||||
<script src="../Utils/GeneralUtils.js"></script>
|
||||
<script src="../Utils/StringUtils.js"></script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script src="Log/LoggerTest.js"></script>
|
||||
<script src="Log/LogLevelTest.js"></script>
|
||||
|
|
@ -74,6 +78,10 @@
|
|||
|
||||
<script src="Uri/HttpTest.js"></script>
|
||||
<script src="Uri/UriFactoryTest.js"></script>
|
||||
|
||||
<script src="Utils/ArrayUtilsTest.js"></script>
|
||||
<script src="Utils/GeneralUtilsTest.js"></script>
|
||||
<script src="Utils/StringUtilsTest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
|
|
|
|||
28
tests/Utils/ArrayUtilsTest.js
Normal file
28
tests/Utils/ArrayUtilsTest.js
Normal file
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
describe('GeneralUtilsTest', function ()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
beforeEach(function ()
|
||||
{
|
||||
});
|
||||
|
||||
afterEach(function ()
|
||||
{
|
||||
});
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
describe('MarkdownTest', function ()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
beforeEach(function ()
|
||||
{
|
||||
});
|
||||
|
||||
afterEach(function ()
|
||||
{
|
||||
});
|
||||
});
|
||||
|
|
@ -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('<a href="test">Test</a>')).toBe('<a href="test">Test</a>');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
describe('UiUtilsTest', function ()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
beforeEach(function ()
|
||||
{
|
||||
});
|
||||
|
||||
afterEach(function ()
|
||||
{
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user