FIX: Allow qunit tests to run in browser by stubbing new functionality
This commit is contained in:
parent
bc52b72145
commit
3ceadbd5b8
|
@ -10,6 +10,12 @@ export default Ember.Mixin.create(Ember.ViewTargetActionSupport, Scrolling, {
|
||||||
if (eyeline) { eyeline.update(); }
|
if (eyeline) { eyeline.update(); }
|
||||||
},
|
},
|
||||||
|
|
||||||
|
loadMoreUnlessFull() {
|
||||||
|
if (this.screenNotFull()) {
|
||||||
|
this.send("loadMore");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
@on("didInsertElement")
|
@on("didInsertElement")
|
||||||
_bindEyeline() {
|
_bindEyeline() {
|
||||||
const eyeline = new Eyeline(this.get('eyelineSelector') + ":last");
|
const eyeline = new Eyeline(this.get('eyelineSelector') + ":last");
|
||||||
|
|
|
@ -16,6 +16,10 @@ const ScrollingDOMMethods = {
|
||||||
name = name || 'default';
|
name = name || 'default';
|
||||||
$(window).unbind(`scroll.discourse-${name}`);
|
$(window).unbind(`scroll.discourse-${name}`);
|
||||||
$(document).unbind(`touchmove.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);
|
ScrollingDOMMethods.bindOnScroll(onScrollMethod, opts.name);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
screenNotFull: () => ScrollingDOMMethods.screenNotFull(),
|
||||||
|
|
||||||
unbindScrolling(name) {
|
unbindScrolling(name) {
|
||||||
ScrollingDOMMethods.unbindOnScroll(name);
|
ScrollingDOMMethods.unbindOnScroll(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ export default Ember.View.extend(LoadMore, UrlRefresh, {
|
||||||
const scrollTo = this.session.get('topicListScrollPosition');
|
const scrollTo = this.session.get('topicListScrollPosition');
|
||||||
if (scrollTo && scrollTo >= 0) {
|
if (scrollTo && scrollTo >= 0) {
|
||||||
Ember.run.schedule('afterRender', () => $(window).scrollTop(scrollTo + 1));
|
Ember.run.schedule('afterRender', () => $(window).scrollTop(scrollTo + 1));
|
||||||
} else if ($(window).height() >= $(document).height()) {
|
} else {
|
||||||
this.send("loadMore");
|
this.loadMoreUnlessFull();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ QUnit.testStart(function(ctx) {
|
||||||
PreloadStore.reset();
|
PreloadStore.reset();
|
||||||
|
|
||||||
window.sandbox = sinon.sandbox.create();
|
window.sandbox = sinon.sandbox.create();
|
||||||
|
window.sandbox.stub(ScrollingDOMMethods, "screenNotFull");
|
||||||
window.sandbox.stub(ScrollingDOMMethods, "bindOnScroll");
|
window.sandbox.stub(ScrollingDOMMethods, "bindOnScroll");
|
||||||
window.sandbox.stub(ScrollingDOMMethods, "unbindOnScroll");
|
window.sandbox.stub(ScrollingDOMMethods, "unbindOnScroll");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue