Optimizing tests

This commit is contained in:
Dennis Eichhorn 2018-06-28 19:01:26 +02:00
parent 23b0fa4d73
commit bf3ec231dd
4 changed files with 6 additions and 102 deletions

View File

@ -62,6 +62,7 @@
login ()
{
const authRequest = new jsOMS.Message.Request.Request();
authRequest.setUri(this.uri);
authRequest.setMethod(jsOMS.Message.Request.RequestMethod.POST);
authRequest.setResponseType(jsOMS.Message.Request.RequestType.JSON);

View File

@ -1,89 +0,0 @@
/**
* CookieJar class.
*
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @since 1.0.0
*/
(function (jsOMS)
{
"use strict";
jsOMS.Autoloader.defineNamespace('jsOMS.DataStorage');
/**
* @constructor
*
* @since 1.0.0
*/
jsOMS.DataStorage.CookieJar = class {
constructor ()
{
}
/**
* Saving data to cookie
*
* @param {string} cName Cookie name
* @param {string} value Value to save
* @param {number} exdays Lifetime for the cookie
* @param {string} domain Domain for the cookie
* @param {string} path Path for the cookie
*
* @return array
*
* @method
*
* @since 1.0.0
*/
setCookie (cName, value, exdays, domain, path)
{
const exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
const cValue = encodeURI(value)
+ ((exdays === null) ? "" : "; expires="
+ exdate.toUTCString()) + ";domain="
+ domain + ";path="
+ path;
document.cookie = cName + "=" + cValue;
};
/**
* Loading cookie data
*
* @param {string} cName Cookie name
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getCookie (cName)
{
let cValue = document.cookie,
cStart = cValue.indexOf(" " + cName + "=");
if (cStart === -1) {
cStart = cValue.indexOf(cName + "=");
}
if (cStart === -1) {
cValue = null;
} else {
cStart = cValue.indexOf("=", cStart) + 1;
let cEnd = cValue.indexOf(";", cStart);
if (cEnd === -1) {
cEnd = cValue.length;
}
cValue = decodeURI(cValue.substring(cStart, cEnd));
}
return cValue;
};
};
}(window.jsOMS = window.jsOMS || {}));

View File

@ -1,12 +0,0 @@
describe('CookieJarTest', function ()
{
"use strict";
beforeEach(function ()
{
});
afterEach(function ()
{
});
});

View File

@ -23,15 +23,19 @@
<script src="../Account/AccountManager.js"></script>
<script src="../Account/AccountType.js"></script>
<script src="../Config/Options.js"></script>
<script src="../Uri/Http.js"></script>
<script src="../Uri/UriFactory.js"></script>
<!-- include spec files here... -->
<script src="Asset/AssetManagerTest.js"></script>
<script src="Account/AccountTest.js"></script>
<script src="Account/AccountManagerTest.js"></script>
<script src="Account/AccountTypeTest.js"></script>
<script src="Asset/AssetManagerTest.js"></script>
<script src="Config/OptionsTest.js"></script>
<script src="Uri/HttpTest.js"></script>
<script src="Uri/UriFactoryTest.js"></script>