Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
    linkedin#52:  Adding test SKIP_CYCLE constant
  • Loading branch information
SparshithNR committed Jun 24, 2017
1 parent 43fb172 commit 3983438
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
5 changes: 3 additions & 2 deletions test/constants.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const constants = {
time: {
IMPRESSION_THRESHOLD : 100,
RAF_THRESHOLD : 22,
RAF_THRESHOLD : 16,
SMALL: 5
},
ITEM_TO_OBSERVE: 5
ITEM_TO_OBSERVE: 5,
SKIP_CYCLE: 3
};


Expand Down
10 changes: 5 additions & 5 deletions test/headless/specs/watcher/exposed-event.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {

import constants from './../../../constants.js';

const { time: { RAF_THRESHOLD }, ITEM_TO_OBSERVE } = constants;
const { time: { RAF_THRESHOLD }, ITEM_TO_OBSERVE, SKIP_CYCLE } = constants;

testModule('Watcher Exposed Event', class extends WatcherTestClass {
['@test should not fire if item is not exposed']() {
Expand Down Expand Up @@ -40,13 +40,13 @@ testModule('Watcher Exposed Event', class extends WatcherTestClass {
['@test should fire twice if moved in, out, and then back in viewport']() {
return this.context.scrollTo(100)
.scrollTo(140)
.wait(RAF_THRESHOLD * 2)
.wait(RAF_THRESHOLD * SKIP_CYCLE)
.scrollTo(120)
.wait(RAF_THRESHOLD * 2)
.wait(RAF_THRESHOLD * SKIP_CYCLE)
.scrollTo(0)
.wait(RAF_THRESHOLD * 2)
.wait(RAF_THRESHOLD * SKIP_CYCLE)
.scrollTo(50)
.wait(RAF_THRESHOLD * 2)
.wait(RAF_THRESHOLD * SKIP_CYCLE)
.assertEvent(ITEM_TO_OBSERVE, 'exposed', 2)
.done();
}
Expand Down
8 changes: 4 additions & 4 deletions test/headless/specs/watcher/impression-complete-event.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {

import constants from './../../../constants.js';

const { time: { IMPRESSION_THRESHOLD, RAF_THRESHOLD }, ITEM_TO_OBSERVE } = constants;
const { time: { IMPRESSION_THRESHOLD, RAF_THRESHOLD }, ITEM_TO_OBSERVE, SKIP_CYCLE } = constants;

testModule('Impression Complete event', class extends WatcherTestClass {
['@test should not fire if item is not exposed']() {
Expand Down Expand Up @@ -56,7 +56,7 @@ testModule('Impression Complete event', class extends WatcherTestClass {
return this.context.scrollTo(200)
.wait(IMPRESSION_THRESHOLD + RAF_THRESHOLD * 4)
.unwatch(ITEM_TO_OBSERVE)
.wait(RAF_THRESHOLD * 2)
.wait(RAF_THRESHOLD * SKIP_CYCLE)
.assertOnce(ITEM_TO_OBSERVE, 'impression-complete')
.done();
}
Expand All @@ -65,7 +65,7 @@ testModule('Impression Complete event', class extends WatcherTestClass {
return this.context.scrollTo(150)
.wait(IMPRESSION_THRESHOLD * 5)
.scrollTo(0)
.wait(RAF_THRESHOLD * 3)
.wait(RAF_THRESHOLD * SKIP_CYCLE)
.assert(function(e) {
return e.meta.duration >= 495 && e.meta.duration <= 545 && e.id === 5 && e.e === 'impression-complete';
}, 1)
Expand All @@ -91,7 +91,7 @@ testModule('Impression Complete event', class extends WatcherTestClass {
.scrollTo(250)
.wait(IMPRESSION_THRESHOLD + RAF_THRESHOLD * 4)
.scrollTo(0)
.wait(RAF_THRESHOLD)
.wait(RAF_THRESHOLD * SKIP_CYCLE)
.assertEvent(ITEM_TO_OBSERVE, 'impression-complete', 2)
.done();
}
Expand Down
4 changes: 2 additions & 2 deletions test/headless/specs/watcher/impression-event.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {

import constants from './../../../constants.js';

const { time: { IMPRESSION_THRESHOLD, RAF_THRESHOLD, SMALL }, ITEM_TO_OBSERVE } = constants;
const { time: { IMPRESSION_THRESHOLD, RAF_THRESHOLD, SMALL }, ITEM_TO_OBSERVE, SKIP_CYCLE } = constants;

testModule('Impression event', class extends WatcherTestClass {
['@test should not fire if item is exposed but not impressed']() {
Expand Down Expand Up @@ -65,7 +65,7 @@ testModule('Impression event', class extends WatcherTestClass {
.wait(RAF_THRESHOLD)
.assertNever(ITEM_TO_OBSERVE, 'impressed')
.scrollTo(200)
.wait(IMPRESSION_THRESHOLD + RAF_THRESHOLD * 2)
.wait(IMPRESSION_THRESHOLD + RAF_THRESHOLD * SKIP_CYCLE)
.assertOnce(ITEM_TO_OBSERVE, 'impressed')
.done();
}
Expand Down

0 comments on commit 3983438

Please sign in to comment.