add more unit tests for elimination logic
This commit is contained in:
parent
65ef039316
commit
a443a5203e
@ -3,15 +3,28 @@ import { difference } from 'lodash'
|
|||||||
|
|
||||||
describe('Timeline', () => {
|
describe('Timeline', () => {
|
||||||
describe('getExcludedStatusIdsByPinning', () => {
|
describe('getExcludedStatusIdsByPinning', () => {
|
||||||
it('should not return unpinned status ids', () => {
|
const mockStatuses = (ids) => ids.map(id => ({ id }))
|
||||||
const statuses = [
|
|
||||||
{ id: 1 },
|
it('should not return any unpinned status ids', () => {
|
||||||
{ id: 2 },
|
const statuses = mockStatuses([1, 2, 3, 4])
|
||||||
{ id: 3 },
|
const pinnedStatusIds = [1, 3, 5]
|
||||||
{ id: 4 }
|
|
||||||
]
|
|
||||||
const pinnedStatusIds = [1, 3]
|
|
||||||
expect(difference(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds), pinnedStatusIds)).to.eql([])
|
expect(difference(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds), pinnedStatusIds)).to.eql([])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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]
|
||||||
|
expect(difference(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds), statusIds)).to.eql([])
|
||||||
|
})
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
Loading…
Reference in New Issue
Block a user