From e48e64456d5cc1ebe8612afd6af6a235966c24a9 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Wed, 22 Jul 2020 07:33:55 +1000 Subject: [PATCH] FIX: test for fillGapBefore (#10272) Missing test for that PR https://github.com/discourse/discourse/pull/10264 --- test/javascripts/models/post-stream-test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/javascripts/models/post-stream-test.js b/test/javascripts/models/post-stream-test.js index dbcc4b5ca8b..d68f767fb79 100644 --- a/test/javascripts/models/post-stream-test.js +++ b/test/javascripts/models/post-stream-test.js @@ -247,6 +247,23 @@ QUnit.test("findPostIdForPostNumber", assert => { assert.equal(postStream.findPostIdForPostNumber(8), 60, "it respects gaps"); }); +QUnit.test("fillGapBefore", assert => { + const postStream = buildStream(1234, [60]); + sandbox.stub(postStream, "findPostsByIds").returns(Promise.resolve([])); + let post = postStream.store.createRecord("post", { id: 60, post_number: 60 }); + postStream.set("gaps", { + before: { 60: [51, 52, 53, 54, 55, 56, 57, 58, 59] } + }); + + postStream.fillGapBefore(post, [51, 52, 53, 54, 55, 56, 57, 58, 59]); + + assert.deepEqual( + postStream.stream, + [51, 52, 53, 54, 55, 60], + "partial results are included in the stream" + ); +}); + QUnit.test("toggleParticipant", assert => { const postStream = buildStream(1236); sandbox.stub(postStream, "refresh").returns(Promise.resolve());