FIX: Allow qunit tests to run in browser by stubbing new functionality

This commit is contained in:
Robin Ward 2015-09-09 16:20:08 -04:00
parent bc52b72145
commit 3ceadbd5b8
4 changed files with 15 additions and 2 deletions

View File

@ -10,6 +10,12 @@ export default Ember.Mixin.create(Ember.ViewTargetActionSupport, Scrolling, {
if (eyeline) { eyeline.update(); }
},
loadMoreUnlessFull() {
if (this.screenNotFull()) {
this.send("loadMore");
}
},
@on("didInsertElement")
_bindEyeline() {
const eyeline = new Eyeline(this.get('eyelineSelector') + ":last");

View File

@ -16,6 +16,10 @@ const ScrollingDOMMethods = {
name = name || 'default';
$(window).unbind(`scroll.discourse-${name}`);
$(document).unbind(`touchmove.discourse-${name}`);
},
screenNotFull() {
return $(window).height() >= $(document).height();
}
};
@ -41,6 +45,8 @@ const Scrolling = Ember.Mixin.create({
ScrollingDOMMethods.bindOnScroll(onScrollMethod, opts.name);
},
screenNotFull: () => ScrollingDOMMethods.screenNotFull(),
unbindScrolling(name) {
ScrollingDOMMethods.unbindOnScroll(name);
}

View File

@ -26,8 +26,8 @@ export default Ember.View.extend(LoadMore, UrlRefresh, {
const scrollTo = this.session.get('topicListScrollPosition');
if (scrollTo && scrollTo >= 0) {
Ember.run.schedule('afterRender', () => $(window).scrollTop(scrollTo + 1));
} else if ($(window).height() >= $(document).height()) {
this.send("loadMore");
} else {
this.loadMoreUnlessFull();
}
},

View File

@ -105,6 +105,7 @@ QUnit.testStart(function(ctx) {
PreloadStore.reset();
window.sandbox = sinon.sandbox.create();
window.sandbox.stub(ScrollingDOMMethods, "screenNotFull");
window.sandbox.stub(ScrollingDOMMethods, "bindOnScroll");
window.sandbox.stub(ScrollingDOMMethods, "unbindOnScroll");