2014-01-12 21:57:53 +04:00
|
|
|
/**
|
|
|
|
* ownCloud
|
|
|
|
*
|
|
|
|
* @author Vincent Petry
|
|
|
|
* @copyright 2014 Vincent Petry <pvince81@owncloud.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simulate the variables that are normally set by PHP code
|
|
|
|
*/
|
|
|
|
|
|
|
|
// from core/js/config.php
|
|
|
|
window.TESTING = true;
|
|
|
|
window.datepickerFormatDate = 'MM d, yy';
|
|
|
|
window.dayNames = [
|
|
|
|
'Sunday',
|
|
|
|
'Monday',
|
|
|
|
'Tuesday',
|
|
|
|
'Wednesday',
|
|
|
|
'Thursday',
|
|
|
|
'Friday',
|
|
|
|
'Saturday'
|
|
|
|
];
|
2015-08-21 10:17:36 +03:00
|
|
|
window.dayNamesShort = [
|
|
|
|
'Sun.',
|
|
|
|
'Mon.',
|
|
|
|
'Tue.',
|
|
|
|
'Wed.',
|
|
|
|
'Thu.',
|
|
|
|
'Fri.',
|
|
|
|
'Sat.'
|
|
|
|
];
|
|
|
|
window.dayNamesMin = [
|
|
|
|
'Su',
|
|
|
|
'Mo',
|
|
|
|
'Tu',
|
|
|
|
'We',
|
|
|
|
'Th',
|
|
|
|
'Fr',
|
|
|
|
'Sa'
|
|
|
|
];
|
2014-01-12 21:57:53 +04:00
|
|
|
window.monthNames = [
|
|
|
|
'January',
|
|
|
|
'February',
|
|
|
|
'March',
|
|
|
|
'April',
|
|
|
|
'May',
|
|
|
|
'June',
|
|
|
|
'July',
|
|
|
|
'August',
|
|
|
|
'September',
|
|
|
|
'October',
|
|
|
|
'November',
|
|
|
|
'December'
|
|
|
|
];
|
2015-08-21 10:17:36 +03:00
|
|
|
window.monthNamesShort = [
|
|
|
|
'Jan.',
|
|
|
|
'Feb.',
|
|
|
|
'Mar.',
|
|
|
|
'Apr.',
|
|
|
|
'May.',
|
|
|
|
'Jun.',
|
|
|
|
'Jul.',
|
|
|
|
'Aug.',
|
|
|
|
'Sep.',
|
|
|
|
'Oct.',
|
|
|
|
'Nov.',
|
|
|
|
'Dec.'
|
|
|
|
];
|
2014-01-12 21:57:53 +04:00
|
|
|
window.firstDay = 0;
|
|
|
|
|
|
|
|
// setup dummy webroots
|
2014-06-06 11:55:32 +04:00
|
|
|
/* jshint camelcase: false */
|
|
|
|
window.oc_debug = true;
|
2019-05-02 17:03:58 +03:00
|
|
|
// FIXME: OC.webroot is supposed to be only the path!!!
|
|
|
|
OC.webroot = location.href + '/';
|
2019-05-07 10:03:14 +03:00
|
|
|
OC.appswebroots = {
|
2019-05-02 17:03:58 +03:00
|
|
|
"files": window.webroot + '/apps/files/',
|
|
|
|
"files_sharing": window.webroot + '/apps/files_sharing/'
|
2014-01-12 21:57:53 +04:00
|
|
|
};
|
2019-04-29 19:04:45 +03:00
|
|
|
OC.config = {
|
2014-02-04 16:56:41 +04:00
|
|
|
session_lifetime: 600 * 1000,
|
2017-02-13 18:51:23 +03:00
|
|
|
session_keepalive: false,
|
|
|
|
blacklist_files_regex: '\.(part|filepart)$',
|
2014-02-04 16:56:41 +04:00
|
|
|
};
|
2019-05-03 09:42:42 +03:00
|
|
|
OC.appConfig = {
|
2014-05-13 13:15:06 +04:00
|
|
|
core: {}
|
|
|
|
};
|
2019-05-14 12:14:29 +03:00
|
|
|
OC.theme = {
|
2018-06-12 17:16:29 +03:00
|
|
|
docPlaceholderUrl: 'https://docs.example.org/PLACEHOLDER'
|
|
|
|
};
|
2018-11-01 18:22:22 +03:00
|
|
|
window.oc_capabilities = {
|
|
|
|
}
|
2014-01-12 21:57:53 +04:00
|
|
|
|
2014-06-06 11:55:32 +04:00
|
|
|
/* jshint camelcase: true */
|
|
|
|
|
2014-06-05 19:06:21 +04:00
|
|
|
// mock for Snap.js plugin
|
|
|
|
window.Snap = function() {};
|
2014-06-06 11:55:32 +04:00
|
|
|
window.Snap.prototype = {
|
|
|
|
enable: function() {},
|
|
|
|
disable: function() {},
|
|
|
|
close: function() {}
|
|
|
|
};
|
2014-06-05 19:06:21 +04:00
|
|
|
|
2014-02-18 15:29:05 +04:00
|
|
|
window.isPhantom = /phantom/i.test(navigator.userAgent);
|
|
|
|
|
2014-01-12 21:57:53 +04:00
|
|
|
// global setup for all tests
|
|
|
|
(function setupTests() {
|
2014-02-04 16:56:41 +04:00
|
|
|
var fakeServer = null,
|
2015-12-10 20:08:40 +03:00
|
|
|
$testArea = null,
|
|
|
|
ajaxErrorStub = null;
|
2014-01-12 21:57:53 +04:00
|
|
|
|
2014-08-15 18:19:50 +04:00
|
|
|
/**
|
|
|
|
* Utility functions for testing
|
|
|
|
*/
|
|
|
|
var TestUtil = {
|
|
|
|
/**
|
|
|
|
* Returns the image URL set on the given element
|
|
|
|
* @param $el element
|
|
|
|
* @return {String} image URL
|
|
|
|
*/
|
|
|
|
getImageUrl: function($el) {
|
|
|
|
// might be slightly different cross-browser
|
|
|
|
var url = $el.css('background-image');
|
|
|
|
var r = url.match(/url\(['"]?([^'")]*)['"]?\)/);
|
|
|
|
if (!r) {
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
return r[1];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-01-12 21:57:53 +04:00
|
|
|
beforeEach(function() {
|
2014-03-06 15:50:18 +04:00
|
|
|
// test area for elements that need absolute selector access or measure widths/heights
|
|
|
|
// which wouldn't work for detached or hidden elements
|
2014-06-24 18:27:39 +04:00
|
|
|
$testArea = $('<div id="testArea" style="position: absolute; width: 1280px; height: 800px; top: -3000px; left: -3000px; opacity: 0;"></div>');
|
2014-03-06 15:50:18 +04:00
|
|
|
$('body').append($testArea);
|
2014-01-12 21:57:53 +04:00
|
|
|
// enforce fake XHR, tests should not depend on the server and
|
|
|
|
// must use fake responses for expected calls
|
|
|
|
fakeServer = sinon.fakeServer.create();
|
|
|
|
|
|
|
|
// make it globally available, so that other tests can define
|
|
|
|
// custom responses
|
|
|
|
window.fakeServer = fakeServer;
|
2014-08-15 18:19:50 +04:00
|
|
|
|
|
|
|
if (!OC.TestUtil) {
|
|
|
|
OC.TestUtil = TestUtil;
|
|
|
|
}
|
2014-12-01 18:17:28 +03:00
|
|
|
|
2015-08-06 16:45:41 +03:00
|
|
|
moment.locale('en');
|
|
|
|
|
2014-12-01 18:17:28 +03:00
|
|
|
// reset plugins
|
|
|
|
OC.Plugins._plugins = [];
|
2014-10-31 13:41:07 +03:00
|
|
|
|
|
|
|
// dummy select2 (which isn't loaded during the tests)
|
2015-11-30 17:40:17 +03:00
|
|
|
$.fn.select2 = function() { return this; };
|
2015-12-10 20:08:40 +03:00
|
|
|
|
|
|
|
ajaxErrorStub = sinon.stub(OC, '_processAjaxError');
|
2014-01-12 21:57:53 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
// uncomment this to log requests
|
|
|
|
// console.log(window.fakeServer.requests);
|
|
|
|
fakeServer.restore();
|
2014-03-06 15:50:18 +04:00
|
|
|
|
|
|
|
$testArea.remove();
|
2014-10-31 13:41:07 +03:00
|
|
|
|
|
|
|
delete($.fn.select2);
|
2015-12-10 20:08:40 +03:00
|
|
|
|
|
|
|
ajaxErrorStub.restore();
|
2017-02-27 12:06:53 +03:00
|
|
|
|
|
|
|
// reset pop state handlers
|
|
|
|
OC.Util.History._handlers = [];
|
|
|
|
|
2014-01-12 21:57:53 +04:00
|
|
|
});
|
|
|
|
})();
|
|
|
|
|