Skip to content

Commit

Permalink
Add orientationchange to Karma tests
Browse files Browse the repository at this point in the history
[Issue] #1313
[Problem] Orienattionchange line coverage is low
[Solution] Add orientationchange to Karma tests. Modify tests.

Signed-off-by: Lukasz Slachciak <l.slachciak@samsung.com>
  • Loading branch information
lmslachciak committed Jul 20, 2020
1 parent a1b6426 commit 4470e56
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
35 changes: 19 additions & 16 deletions tests/js/core/event/orientationchange/orientationchange.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/*global window, start */
(function (window, document, tau, QUnit, define) {
/* global QUnit, define, start, tau */
(function () {
"use strict";

QUnit.config.reorder = false;

function runTests(orientation, helpers) {
var mockWindow = {
matchMedia: null,
Expand All @@ -27,10 +25,21 @@
},
originalSupport = false;

orientation = orientation || window.ns.event.orientationchange;
helpers = helpers || window.helpers;

function initHTML() {
var HTML = helpers.loadHTMLFromFile("/base/tests/js/core/event/orientationchange/test-data/sample.html"),
parent = document.getElementById("qunit-fixture") || helpers.initFixture();

parent.innerHTML = HTML;
}

QUnit.module("core/event/orientationchange", {
setup: function () {
orientation._window = mockWindow;
originalSupport = orientation.supported;
initHTML();
},
teardown: function () {
orientation._window = window;
Expand Down Expand Up @@ -174,18 +183,12 @@
});
}

if (define) {
define(
[
"../../../../../src/js/core/event/orientationchange",
"../../../../karma/tests/helpers"
],
function (engine, event, orientation, helpers) {
return runTests.bind(null, orientation, helpers);
}
);
if (typeof define === "function") {
define(function () {
return runTests;
});
} else {
runTests(tau.event.orientationchange, window.helpers);
runTests(tau.event.orientationchange, window.helpers)
}

}(window, window.document, window.tau, window.QUnit, window.define));
}());
3 changes: 3 additions & 0 deletions tests/js/core/event/orientationchange/test-data/sample.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div data-role="page" id="first">
<div data-role="mock" id="mock1">Mock</div>
</div>
2 changes: 1 addition & 1 deletion tests/karma/single.test.path.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*global testPaths:true */
testPaths = [
"core/widget/core/Drawer"
"core/event/orientationchange"
];

// For test:
Expand Down
1 change: 1 addition & 0 deletions tests/karma/testPaths.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ testPaths = [
"core/event/gesture/LongPress",
"core/event/gesture/Pinch",
"core/event/gesture/Swipe",
"core/event/orientationchange",
"profile/wearable/router/route/grid",
"core/router/Router",
"core/widget/core/tab/SubTab",
Expand Down

0 comments on commit 4470e56

Please sign in to comment.