Skip to content

Commit

Permalink
[TC] Improve the coverage of the Scrollview widget
Browse files Browse the repository at this point in the history
[Issue] N/A
[Problem] Scrollview coverage is low
[Solution] Add new test cases

Signed-off-by: Hunseop Jeong <hs85.jeong@samsung.com>
  • Loading branch information
HunseopJeong authored and singa2000 committed Sep 11, 2020
1 parent 37190b6 commit a9593bc
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions tests/js/profile/wearable/widget/wearable/Scrollview/Scrollview.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,74 @@
helpers.restoreStub(ns.support.shape, "circle");
});

QUnit.test("_init", 4, function (assert) {
var element = document.getElementById("scrollview-page-w"),
scrollview = new Scrollview();

helpers.stub(scrollview, "_setBouncingEffect", function () {
assert.ok(true, "_setBouncingEffect should be called");
});

scrollview.element = element;
scrollview._init();

assert.equal(scrollview.maxScrollX, 0, "maxScrollX is 0");
assert.equal(scrollview.maxScrollY, 0, "maxScrollY is 0");
assert.notEqual(scrollview.bouncingEffect, undefined, "bouncing effect is created");

helpers.restoreStub(scrollview, "_setBouncingEffect");
});

QUnit.test("_start & _end", 6, function (assert) {
var element = document.getElementById("scrollview-page-w"),
scrollview = new Scrollview();

helpers.stub(scrollview, "_setBouncingEffect", function () {
assert.ok(true, "_setBouncingEffect should be called");
});

scrollview.element = element;
scrollview._build(element);
scrollview._init();

scrollview._start();

assert.equal(scrollview.scrolled, false, "scrolled is false");
assert.equal(scrollview.dragging, true, "dragging is true");
assert.equal(scrollview.scrollCanceled, false, "scrollCanceled is false");

helpers.stub(scrollview.bouncingEffect, "dragEnd", function () {
assert.ok(true, "dragEnd should be called");
});

scrollview._end();

assert.equal(scrollview.dragging, false, "dragging is false");

helpers.restoreStub(scrollview.bouncingEffect, "dragEnd");
helpers.restoreStub(scrollview, "_setBouncingEffect");
});

QUnit.test("showBouncingEffect & hideBouncingEffect", 4, function (assert) {
var scrollview = new Scrollview();

scrollview.bouncingEffect = {
drag: function (x, y) {
assert.ok(true, "drag should be called");
assert.equal(x, 0, "x is 0");
assert.equal(y, 0, "y is 0");
},
dragEnd: function () {
assert.ok(true, "dragEnd should be called");
}
}

scrollview.showBouncingEffect();
scrollview.hideBouncingEffect();

helpers.restoreStub(scrollview.bouncingEffect, "dragEnd");
helpers.restoreStub(scrollview, "_setBouncingEffect");
});
}
if (typeof define === "function") {
define(function () {
Expand Down

0 comments on commit a9593bc

Please sign in to comment.