mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: Allow qunit tests to run in browser by stubbing new functionality
This commit is contained in:
parent
bc52b72145
commit
3ceadbd5b8
4 changed files with 15 additions and 2 deletions
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
Loading…
Reference in a new issue