Skip to content
Snippets Groups Projects
Commit e129f684 authored by Vincent Petry's avatar Vincent Petry
Browse files

Added testArea for JS Unit tests

Added a testArea that is outside the viewport but still considered as
visible from the jQuery code.

The testArea is useful when:
- tested code tries to access DOM elements using global ids
- tested code is requiring some UI elements to be visible to activate
  themselves
parent 1785c0c9
No related branches found
No related tags found
No related merge requests found
......@@ -68,9 +68,14 @@ window.oc_defaults = {};
// global setup for all tests
(function setupTests() {
var fakeServer = null,
$testArea = null,
routesRequestStub;
beforeEach(function() {
// test area for elements that need absolute selector access or measure widths/heights
// which wouldn't work for detached or hidden elements
$testArea = $('<div id="testArea" style="position: absolute; width: 1280px; height: 800px; top: -3000px; left: -3000px;"></div>');
$('body').append($testArea);
// enforce fake XHR, tests should not depend on the server and
// must use fake responses for expected calls
fakeServer = sinon.fakeServer.create();
......@@ -101,6 +106,8 @@ window.oc_defaults = {};
// uncomment this to log requests
// console.log(window.fakeServer.requests);
fakeServer.restore();
$testArea.remove();
});
})();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment