From 65ef03931661561db0791ee7d560292dda6b7d48 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Thu, 25 Jul 2019 08:03:41 -0400
Subject: add unit test for elimination logic
---
test/unit/specs/components/timeline.spec.js | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 test/unit/specs/components/timeline.spec.js
(limited to 'test/unit/specs/components/timeline.spec.js')
diff --git a/test/unit/specs/components/timeline.spec.js b/test/unit/specs/components/timeline.spec.js
new file mode 100644
index 00000000..b13d3e20
--- /dev/null
+++ b/test/unit/specs/components/timeline.spec.js
@@ -0,0 +1,17 @@
+import { getExcludedStatusIdsByPinning } from 'src/components/timeline/timeline.js'
+import { difference } from 'lodash'
+
+describe('Timeline', () => {
+ describe('getExcludedStatusIdsByPinning', () => {
+ it('should not return unpinned status ids', () => {
+ const statuses = [
+ { id: 1 },
+ { id: 2 },
+ { id: 3 },
+ { id: 4 }
+ ]
+ const pinnedStatusIds = [1, 3]
+ expect(difference(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds), pinnedStatusIds)).to.eql([])
+ })
+ })
+})
\ No newline at end of file
--
cgit v1.2.3-70-g09d2
From a443a5203e19eb43cdff76b1e3e6502a5b917bc9 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Thu, 25 Jul 2019 14:17:48 -0400
Subject: add more unit tests for elimination logic
---
test/unit/specs/components/timeline.spec.js | 31 ++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
(limited to 'test/unit/specs/components/timeline.spec.js')
diff --git a/test/unit/specs/components/timeline.spec.js b/test/unit/specs/components/timeline.spec.js
index b13d3e20..48796cd3 100644
--- a/test/unit/specs/components/timeline.spec.js
+++ b/test/unit/specs/components/timeline.spec.js
@@ -3,15 +3,28 @@ import { difference } from 'lodash'
describe('Timeline', () => {
describe('getExcludedStatusIdsByPinning', () => {
- it('should not return unpinned status ids', () => {
- const statuses = [
- { id: 1 },
- { id: 2 },
- { id: 3 },
- { id: 4 }
- ]
- const pinnedStatusIds = [1, 3]
+ 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]
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)
+ })
})
-})
\ No newline at end of file
+})
--
cgit v1.2.3-70-g09d2
From d785ed5a05b3123d95e8627a0f82f0f9cddec33f Mon Sep 17 00:00:00 2001
From: taehoon
Date: Thu, 25 Jul 2019 23:34:56 -0400
Subject: rewrite unit tests
---
test/unit/specs/components/timeline.spec.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
(limited to 'test/unit/specs/components/timeline.spec.js')
diff --git a/test/unit/specs/components/timeline.spec.js b/test/unit/specs/components/timeline.spec.js
index 48796cd3..c1fdd0dd 100644
--- a/test/unit/specs/components/timeline.spec.js
+++ b/test/unit/specs/components/timeline.spec.js
@@ -1,5 +1,4 @@
import { getExcludedStatusIdsByPinning } from 'src/components/timeline/timeline.js'
-import { difference } from 'lodash'
describe('Timeline', () => {
describe('getExcludedStatusIdsByPinning', () => {
@@ -8,14 +7,14 @@ describe('Timeline', () => {
it('should not return any unpinned status ids', () => {
const statuses = mockStatuses([1, 2, 3, 4])
const pinnedStatusIds = [1, 3, 5]
- expect(difference(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds), pinnedStatusIds)).to.eql([])
+ expect(pinnedStatusIds).to.include.members(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds))
})
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([])
+ expect(statusIds).to.include.members(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds))
})
it('should return ids of pinned statuses not posted before any unpinned status', () => {
--
cgit v1.2.3-70-g09d2
From 18a41e785ed85531f032a0aa1b6bfdce5a892fa9 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Sun, 28 Jul 2019 16:55:34 -0400
Subject: update unit test
---
test/unit/specs/components/timeline.spec.js | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
(limited to 'test/unit/specs/components/timeline.spec.js')
diff --git a/test/unit/specs/components/timeline.spec.js b/test/unit/specs/components/timeline.spec.js
index c1fdd0dd..0c8674a8 100644
--- a/test/unit/specs/components/timeline.spec.js
+++ b/test/unit/specs/components/timeline.spec.js
@@ -4,17 +4,15 @@ describe('Timeline', () => {
describe('getExcludedStatusIdsByPinning', () => {
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]
- expect(pinnedStatusIds).to.include.members(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds))
- })
-
- it('should not return any status ids not listed in the given statuses', () => {
+ 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]
- expect(statusIds).to.include.members(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds))
+ 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', () => {
--
cgit v1.2.3-70-g09d2