aboutsummaryrefslogtreecommitdiff
path: root/test/unit/specs/components/timeline.spec.js
diff options
context:
space:
mode:
authorHJ <30-hj@users.noreply.git.pleroma.social>2019-07-28 21:05:22 +0000
committerHJ <30-hj@users.noreply.git.pleroma.social>2019-07-28 21:05:22 +0000
commit8aa3e7d52ea067c12dd12c711121fda190b5979d (patch)
tree751002679ee4e672b3929b43b07fe61a06063ec7 /test/unit/specs/components/timeline.spec.js
parent4827e4d972f8ee11e606693e24ae4ca21711c6b1 (diff)
parent18a41e785ed85531f032a0aa1b6bfdce5a892fa9 (diff)
Merge branch '549' into 'develop'
Prevent showing pinned statuses twice Closes #549 See merge request pleroma/pleroma-fe!812
Diffstat (limited to 'test/unit/specs/components/timeline.spec.js')
-rw-r--r--test/unit/specs/components/timeline.spec.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/unit/specs/components/timeline.spec.js b/test/unit/specs/components/timeline.spec.js
new file mode 100644
index 00000000..0c8674a8
--- /dev/null
+++ b/test/unit/specs/components/timeline.spec.js
@@ -0,0 +1,27 @@
+import { getExcludedStatusIdsByPinning } from 'src/components/timeline/timeline.js'
+
+describe('Timeline', () => {
+ describe('getExcludedStatusIdsByPinning', () => {
+ const mockStatuses = (ids) => ids.map(id => ({ id }))
+
+ it('should return only members of both pinnedStatusIds and ids of the given statuses', () => {
+ const statusIds = [1, 2, 3, 4]
+ const statuses = mockStatuses(statusIds)
+ const pinnedStatusIds = [1, 3, 5]
+ const result = getExcludedStatusIdsByPinning(statuses, pinnedStatusIds)
+ result.forEach(item => {
+ expect(item).to.be.oneOf(statusIds)
+ expect(item).to.be.oneOf(pinnedStatusIds)
+ })
+ })
+
+ it('should return ids of pinned statuses not posted before any unpinned status', () => {
+ const pinnedStatusIdSet1 = ['PINNED1', 'PINNED2']
+ const pinnedStatusIdSet2 = ['PINNED3', 'PINNED4']
+ const pinnedStatusIds = [...pinnedStatusIdSet1, ...pinnedStatusIdSet2]
+ const statusIds = [...pinnedStatusIdSet1, 'UNPINNED1', ...pinnedStatusIdSet2]
+ const statuses = mockStatuses(statusIds)
+ expect(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds)).to.eql(pinnedStatusIdSet1)
+ })
+ })
+})