diff options
Diffstat (limited to 'test/unit')
| -rw-r--r-- | test/unit/specs/components/timeline.spec.js | 27 |
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) + }) + }) +}) |
