2019-07-25 22:03:41 +10:00
|
|
|
import { getExcludedStatusIdsByPinning } from 'src/components/timeline/timeline.js'
|
|
|
|
|
|
|
|
describe('Timeline', () => {
|
|
|
|
describe('getExcludedStatusIdsByPinning', () => {
|
2019-07-26 04:17:48 +10:00
|
|
|
const mockStatuses = (ids) => ids.map(id => ({ id }))
|
|
|
|
|
|
|
|
it('should not return any unpinned status ids', () => {
|
|
|
|
const statuses = mockStatuses([1, 2, 3, 4])
|
|
|
|
const pinnedStatusIds = [1, 3, 5]
|
2019-07-26 13:34:56 +10:00
|
|
|
expect(pinnedStatusIds).to.include.members(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds))
|
2019-07-25 22:03:41 +10:00
|
|
|
})
|
2019-07-26 04:17:48 +10:00
|
|
|
|
|
|
|
it('should not return any status ids not listed in the given statuses', () => {
|
|
|
|
const statusIds = [1, 2, 3, 4]
|
|
|
|
const statuses = mockStatuses(statusIds)
|
|
|
|
const pinnedStatusIds = [1, 3, 5]
|
2019-07-26 13:34:56 +10:00
|
|
|
expect(statusIds).to.include.members(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds))
|
2019-07-26 04:17:48 +10:00
|
|
|
})
|
|
|
|
|
|
|
|
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)
|
|
|
|
})
|
2019-07-25 22:03:41 +10:00
|
|
|
})
|
2019-07-26 04:17:48 +10:00
|
|
|
})
|