Merge pull request #1097 from h3poteto/iss-1096
closes #1096 Reject duplicated status when append statuses in mutations
This commit is contained in:
commit
0e66bba0c2
@ -85,30 +85,7 @@ const status2: Status = {
|
||||
pinned: null
|
||||
}
|
||||
|
||||
describe('TimelineSpace/Contents/DirectMessages', () => {
|
||||
describe('mutations', () => {
|
||||
let state: DirectMessagesState
|
||||
|
||||
describe('deleteToot', () => {
|
||||
describe('message is not reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be deleted', () => {
|
||||
DirectMessages.mutations![MUTATION_TYPES.DELETE_TOOT](state, status1.id)
|
||||
expect(state.timeline).toEqual([status2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('message is reblogged', () => {
|
||||
beforeEach(() => {
|
||||
const rebloggedStatus: Status = {
|
||||
const rebloggedStatus: Status = {
|
||||
id: '3',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
@ -138,7 +115,31 @@ describe('TimelineSpace/Contents/DirectMessages', () => {
|
||||
} as Application,
|
||||
language: null,
|
||||
pinned: null
|
||||
}
|
||||
|
||||
describe('TimelineSpace/Contents/DirectMessages', () => {
|
||||
describe('mutations', () => {
|
||||
let state: DirectMessagesState
|
||||
|
||||
describe('deleteToot', () => {
|
||||
describe('message is not reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be deleted', () => {
|
||||
DirectMessages.mutations![MUTATION_TYPES.DELETE_TOOT](state, status1.id)
|
||||
expect(state.timeline).toEqual([status2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('message is reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
@ -153,5 +154,79 @@ describe('TimelineSpace/Contents/DirectMessages', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('appendTimeline', () => {
|
||||
describe('heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be updated timeline', () => {
|
||||
DirectMessages.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [rebloggedStatus, status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not be updated timeline', () => {
|
||||
DirectMessages.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('not heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be updated timeline', () => {
|
||||
DirectMessages.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([rebloggedStatus])
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
timeline: [rebloggedStatus, status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not be updated timeline', () => {
|
||||
DirectMessages.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -85,30 +85,7 @@ const status2: Status = {
|
||||
pinned: null
|
||||
}
|
||||
|
||||
describe('TimelineSpace/Contents/Hashtag/Tag', () => {
|
||||
describe('mutations', () => {
|
||||
let state: TagState
|
||||
|
||||
describe('deleteToot', () => {
|
||||
describe('message is not reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be deleted', () => {
|
||||
Tag.mutations![MUTATION_TYPES.DELETE_TOOT](state, status1.id)
|
||||
expect(state.timeline).toEqual([status2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('message is reblogged', () => {
|
||||
beforeEach(() => {
|
||||
const rebloggedStatus: Status = {
|
||||
const rebloggedStatus: Status = {
|
||||
id: '3',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
@ -138,7 +115,31 @@ describe('TimelineSpace/Contents/Hashtag/Tag', () => {
|
||||
} as Application,
|
||||
language: null,
|
||||
pinned: null
|
||||
}
|
||||
|
||||
describe('TimelineSpace/Contents/Hashtag/Tag', () => {
|
||||
describe('mutations', () => {
|
||||
let state: TagState
|
||||
|
||||
describe('deleteToot', () => {
|
||||
describe('message is not reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be deleted', () => {
|
||||
Tag.mutations![MUTATION_TYPES.DELETE_TOOT](state, status1.id)
|
||||
expect(state.timeline).toEqual([status2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('message is reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
@ -153,5 +154,79 @@ describe('TimelineSpace/Contents/Hashtag/Tag', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('appendTimeline', () => {
|
||||
describe('heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be updated timeline', () => {
|
||||
Tag.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [rebloggedStatus, status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not be updated timeline', () => {
|
||||
Tag.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('not heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be updated timeline', () => {
|
||||
Tag.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([rebloggedStatus])
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
timeline: [rebloggedStatus, status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not be updated timeline', () => {
|
||||
Tag.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -116,6 +116,7 @@ describe('TimelineSpace/Contents/Home', () => {
|
||||
|
||||
describe('appendTimeline', () => {
|
||||
describe('heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
@ -134,7 +135,28 @@ describe('TimelineSpace/Contents/Home', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: '',
|
||||
showReblogs: true,
|
||||
showReplies: true
|
||||
}
|
||||
})
|
||||
it('should not update timeline', () => {
|
||||
Home.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, status2)
|
||||
expect(state.timeline).toEqual([status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('not heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
@ -152,6 +174,25 @@ describe('TimelineSpace/Contents/Home', () => {
|
||||
expect(state.unreadTimeline).toEqual([status2])
|
||||
})
|
||||
})
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
timeline: [],
|
||||
unreadTimeline: [status2, status1],
|
||||
filter: '',
|
||||
showReblogs: true,
|
||||
showReplies: true
|
||||
}
|
||||
})
|
||||
it('should not update unreadTimeline', () => {
|
||||
Home.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, status2)
|
||||
expect(state.timeline).toEqual([])
|
||||
expect(state.unreadTimeline).toEqual([status2, status1])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('mergeTimeline', () => {
|
||||
|
@ -85,30 +85,7 @@ const status2: Status = {
|
||||
pinned: null
|
||||
}
|
||||
|
||||
describe('TimelineSpace/Contents/Lists/Show', () => {
|
||||
describe('mutations', () => {
|
||||
let state: ShowState
|
||||
|
||||
describe('deleteToot', () => {
|
||||
describe('message is not reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be deleted', () => {
|
||||
Show.mutations![MUTATION_TYPES.DELETE_TOOT](state, status1.id)
|
||||
expect(state.timeline).toEqual([status2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('message is reblogged', () => {
|
||||
beforeEach(() => {
|
||||
const rebloggedStatus: Status = {
|
||||
const rebloggedStatus: Status = {
|
||||
id: '3',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
@ -138,7 +115,31 @@ describe('TimelineSpace/Contents/Lists/Show', () => {
|
||||
} as Application,
|
||||
language: null,
|
||||
pinned: null
|
||||
}
|
||||
|
||||
describe('TimelineSpace/Contents/Lists/Show', () => {
|
||||
describe('mutations', () => {
|
||||
let state: ShowState
|
||||
|
||||
describe('deleteToot', () => {
|
||||
describe('message is not reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be deleted', () => {
|
||||
Show.mutations![MUTATION_TYPES.DELETE_TOOT](state, status1.id)
|
||||
expect(state.timeline).toEqual([status2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('message is reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
@ -153,5 +154,79 @@ describe('TimelineSpace/Contents/Lists/Show', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('appendTimeline', () => {
|
||||
describe('heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be updated timeline', () => {
|
||||
Show.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [rebloggedStatus, status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not be updated timeline', () => {
|
||||
Show.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('not heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be updated timeline', () => {
|
||||
Show.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([rebloggedStatus])
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
timeline: [rebloggedStatus, status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not be updated timeline', () => {
|
||||
Show.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -85,30 +85,7 @@ const status2: Status = {
|
||||
pinned: null
|
||||
}
|
||||
|
||||
describe('TimelineSpace/Contents/Local', () => {
|
||||
describe('mutations', () => {
|
||||
let state: LocalState
|
||||
|
||||
describe('deleteToot', () => {
|
||||
describe('message is not reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be deleted', () => {
|
||||
Local.mutations![MUTATION_TYPES.DELETE_TOOT](state, status1.id)
|
||||
expect(state.timeline).toEqual([status2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('message is reblogged', () => {
|
||||
beforeEach(() => {
|
||||
const rebloggedStatus: Status = {
|
||||
const rebloggedStatus: Status = {
|
||||
id: '3',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
@ -138,7 +115,31 @@ describe('TimelineSpace/Contents/Local', () => {
|
||||
} as Application,
|
||||
language: null,
|
||||
pinned: null
|
||||
}
|
||||
|
||||
describe('TimelineSpace/Contents/Local', () => {
|
||||
describe('mutations', () => {
|
||||
let state: LocalState
|
||||
|
||||
describe('deleteToot', () => {
|
||||
describe('message is not reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be deleted', () => {
|
||||
Local.mutations![MUTATION_TYPES.DELETE_TOOT](state, status1.id)
|
||||
expect(state.timeline).toEqual([status2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('message is reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
@ -153,5 +154,78 @@ describe('TimelineSpace/Contents/Local', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
describe('appendTimeline', () => {
|
||||
describe('heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be updated timeline', () => {
|
||||
Local.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [rebloggedStatus, status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not be updated timeline', () => {
|
||||
Local.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('not heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be updated timeline', () => {
|
||||
Local.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([rebloggedStatus])
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
timeline: [rebloggedStatus, status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not be updated timeline', () => {
|
||||
Local.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -172,6 +172,7 @@ describe('TimelineSpace/Contents/Mentions', () => {
|
||||
|
||||
describe('appendMentions', () => {
|
||||
describe('heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
@ -187,7 +188,27 @@ describe('TimelineSpace/Contents/Mentions', () => {
|
||||
expect(state.unreadMentions).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
mentions: [notification2, notification1],
|
||||
unreadMentions: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not be updated mentions', () => {
|
||||
Mentions.mutations![MUTATION_TYPES.APPEND_MENTIONS](state, notification2)
|
||||
expect(state.mentions).toEqual([notification2, notification1])
|
||||
expect(state.unreadMentions).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('not heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
@ -203,6 +224,24 @@ describe('TimelineSpace/Contents/Mentions', () => {
|
||||
expect(state.unreadMentions).toEqual([notification2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
mentions: [notification1],
|
||||
unreadMentions: [notification2],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not be updated mentions', () => {
|
||||
Mentions.mutations![MUTATION_TYPES.APPEND_MENTIONS](state, notification2)
|
||||
expect(state.mentions).toEqual([notification1])
|
||||
expect(state.unreadMentions).toEqual([notification2])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('mergeMentions', () => {
|
||||
|
@ -184,5 +184,78 @@ describe('TimelineSpace/Contents/Notifications', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('appendTimeline', () => {
|
||||
describe('heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
notifications: [notification1],
|
||||
unreadNotifications: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should update timeline', () => {
|
||||
Notifications.mutations![MUTATION_TYPES.APPEND_NOTIFICATIONS](state, notification2)
|
||||
expect(state.notifications).toEqual([notification2, notification1])
|
||||
expect(state.unreadNotifications).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
notifications: [notification2, notification1],
|
||||
unreadNotifications: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not update timeline', () => {
|
||||
Notifications.mutations![MUTATION_TYPES.APPEND_NOTIFICATIONS](state, notification2)
|
||||
expect(state.notifications).toEqual([notification2, notification1])
|
||||
expect(state.unreadNotifications).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('not heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
notifications: [notification1],
|
||||
unreadNotifications: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should update unreadTimeline', () => {
|
||||
Notifications.mutations![MUTATION_TYPES.APPEND_NOTIFICATIONS](state, notification2)
|
||||
expect(state.notifications).toEqual([notification1])
|
||||
expect(state.unreadNotifications).toEqual([notification2])
|
||||
})
|
||||
})
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
notifications: [notification1],
|
||||
unreadNotifications: [notification2],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not update unreadTimeline', () => {
|
||||
Notifications.mutations![MUTATION_TYPES.APPEND_NOTIFICATIONS](state, notification2)
|
||||
expect(state.notifications).toEqual([notification1])
|
||||
expect(state.unreadNotifications).toEqual([notification2])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -85,30 +85,7 @@ const status2: Status = {
|
||||
pinned: null
|
||||
}
|
||||
|
||||
describe('TimelineSpace/Contents/Local', () => {
|
||||
describe('mutations', () => {
|
||||
let state: PublicState
|
||||
|
||||
describe('deleteToot', () => {
|
||||
describe('message is not reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be deleted', () => {
|
||||
Public.mutations![MUTATION_TYPES.DELETE_TOOT](state, status1.id)
|
||||
expect(state.timeline).toEqual([status2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('message is reblogged', () => {
|
||||
beforeEach(() => {
|
||||
const rebloggedStatus: Status = {
|
||||
const rebloggedStatus: Status = {
|
||||
id: '3',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
@ -138,7 +115,31 @@ describe('TimelineSpace/Contents/Local', () => {
|
||||
} as Application,
|
||||
language: null,
|
||||
pinned: null
|
||||
}
|
||||
|
||||
describe('TimelineSpace/Contents/Local', () => {
|
||||
describe('mutations', () => {
|
||||
let state: PublicState
|
||||
|
||||
describe('deleteToot', () => {
|
||||
describe('message is not reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be deleted', () => {
|
||||
Public.mutations![MUTATION_TYPES.DELETE_TOOT](state, status1.id)
|
||||
expect(state.timeline).toEqual([status2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('message is reblogged', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
@ -153,5 +154,79 @@ describe('TimelineSpace/Contents/Local', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('appendTimeline', () => {
|
||||
describe('heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be updated timeline', () => {
|
||||
Public.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [rebloggedStatus, status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not be updated timeline', () => {
|
||||
Public.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('not heading', () => {
|
||||
describe('normal', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
timeline: [status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should be updated timeline', () => {
|
||||
Public.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([rebloggedStatus])
|
||||
})
|
||||
})
|
||||
|
||||
describe('duplicated status', () => {
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
lazyLoading: false,
|
||||
heading: false,
|
||||
timeline: [rebloggedStatus, status2, status1],
|
||||
unreadTimeline: [],
|
||||
filter: ''
|
||||
}
|
||||
})
|
||||
it('should not be updated timeline', () => {
|
||||
Public.mutations![MUTATION_TYPES.APPEND_TIMELINE](state, rebloggedStatus)
|
||||
expect(state.timeline).toEqual([rebloggedStatus, status2, status1])
|
||||
expect(state.unreadTimeline).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -40,11 +40,14 @@ const mutations: MutationTree<DirectMessagesState> = {
|
||||
state.heading = value
|
||||
},
|
||||
[MUTATION_TYPES.APPEND_TIMELINE]: (state, update: Status) => {
|
||||
// Reject duplicated status in timeline
|
||||
if (!state.timeline.find(item => item.id === update.id) && !state.unreadTimeline.find(item => item.id === update.id)) {
|
||||
if (state.heading) {
|
||||
state.timeline = [update].concat(state.timeline)
|
||||
} else {
|
||||
state.unreadTimeline = [update].concat(state.unreadTimeline)
|
||||
}
|
||||
}
|
||||
},
|
||||
[MUTATION_TYPES.UPDATE_TIMELINE]: (state, messages: Array<Status>) => {
|
||||
state.timeline = messages
|
||||
|
@ -39,11 +39,14 @@ const mutations: MutationTree<TagState> = {
|
||||
state.heading = value
|
||||
},
|
||||
[MUTATION_TYPES.APPEND_TIMELINE]: (state, update: Status) => {
|
||||
// Reject duplicated status in timeline
|
||||
if (!state.timeline.find(item => item.id === update.id) && !state.unreadTimeline.find(item => item.id === update.id)) {
|
||||
if (state.heading) {
|
||||
state.timeline = [update].concat(state.timeline)
|
||||
} else {
|
||||
state.unreadTimeline = [update].concat(state.unreadTimeline)
|
||||
}
|
||||
}
|
||||
},
|
||||
[MUTATION_TYPES.UPDATE_TIMELINE]: (state, timeline: Array<Status>) => {
|
||||
state.timeline = timeline
|
||||
|
@ -46,11 +46,14 @@ const mutations: MutationTree<HomeState> = {
|
||||
state.heading = value
|
||||
},
|
||||
[MUTATION_TYPES.APPEND_TIMELINE]: (state, update: Status) => {
|
||||
// Reject duplicated status in timeline
|
||||
if (!state.timeline.find(item => item.id === update.id) && !state.unreadTimeline.find(item => item.id === update.id)) {
|
||||
if (state.heading) {
|
||||
state.timeline = [update].concat(state.timeline)
|
||||
} else {
|
||||
state.unreadTimeline = [update].concat(state.unreadTimeline)
|
||||
}
|
||||
}
|
||||
},
|
||||
[MUTATION_TYPES.UPDATE_TIMELINE]: (state, messages: Array<Status>) => {
|
||||
state.timeline = messages
|
||||
|
@ -39,11 +39,14 @@ const mutations: MutationTree<ShowState> = {
|
||||
state.heading = value
|
||||
},
|
||||
[MUTATION_TYPES.APPEND_TIMELINE]: (state, update: Status) => {
|
||||
// Reject duplicated status in timeline
|
||||
if (!state.timeline.find(item => item.id === update.id) && !state.unreadTimeline.find(item => item.id === update.id)) {
|
||||
if (state.heading) {
|
||||
state.timeline = [update].concat(state.timeline)
|
||||
} else {
|
||||
state.unreadTimeline = [update].concat(state.unreadTimeline)
|
||||
}
|
||||
}
|
||||
},
|
||||
[MUTATION_TYPES.UPDATE_TIMELINE]: (state, timeline: Array<Status>) => {
|
||||
state.timeline = timeline
|
||||
|
@ -37,11 +37,14 @@ const mutations: MutationTree<LocalState> = {
|
||||
state.heading = value
|
||||
},
|
||||
[MUTATION_TYPES.APPEND_TIMELINE]: (state, update: Status) => {
|
||||
// Reject duplicated status in timeline
|
||||
if (!state.timeline.find(item => item.id === update.id) && !state.unreadTimeline.find(item => item.id === update.id)) {
|
||||
if (state.heading) {
|
||||
state.timeline = [update].concat(state.timeline)
|
||||
} else {
|
||||
state.unreadTimeline = [update].concat(state.unreadTimeline)
|
||||
}
|
||||
}
|
||||
},
|
||||
[MUTATION_TYPES.UPDATE_TIMELINE]: (state, messages: Array<Status>) => {
|
||||
state.timeline = messages
|
||||
|
@ -40,11 +40,14 @@ const mutations: MutationTree<MentionsState> = {
|
||||
state.heading = value
|
||||
},
|
||||
[MUTATION_TYPES.APPEND_MENTIONS]: (state, update: Notification) => {
|
||||
// Reject duplicated status in timeline
|
||||
if (!state.mentions.find(item => item.id === update.id) && !state.unreadMentions.find(item => item.id === update.id)) {
|
||||
if (state.heading) {
|
||||
state.mentions = [update].concat(state.mentions)
|
||||
} else {
|
||||
state.unreadMentions = [update].concat(state.unreadMentions)
|
||||
}
|
||||
}
|
||||
},
|
||||
[MUTATION_TYPES.UPDATE_MENTIONS]: (state, messages: Array<Notification>) => {
|
||||
state.mentions = messages
|
||||
|
@ -41,11 +41,17 @@ const mutations: MutationTree<NotificationsState> = {
|
||||
state.heading = value
|
||||
},
|
||||
[MUTATION_TYPES.APPEND_NOTIFICATIONS]: (state, notification: Notification) => {
|
||||
// Reject duplicated status in timeline
|
||||
if (
|
||||
!state.notifications.find(item => item.id === notification.id) &&
|
||||
!state.unreadNotifications.find(item => item.id === notification.id)
|
||||
) {
|
||||
if (state.heading) {
|
||||
state.notifications = [notification].concat(state.notifications)
|
||||
} else {
|
||||
state.unreadNotifications = [notification].concat(state.unreadNotifications)
|
||||
}
|
||||
}
|
||||
},
|
||||
[MUTATION_TYPES.UPDATE_NOTIFICATIONS]: (state, notifications: Array<Notification>) => {
|
||||
state.notifications = notifications
|
||||
|
@ -37,11 +37,14 @@ const mutations: MutationTree<PublicState> = {
|
||||
state.heading = value
|
||||
},
|
||||
[MUTATION_TYPES.APPEND_TIMELINE]: (state, update: Status) => {
|
||||
// Reject duplicated status in timeline
|
||||
if (!state.timeline.find(item => item.id === update.id) && !state.unreadTimeline.find(item => item.id === update.id)) {
|
||||
if (state.heading) {
|
||||
state.timeline = [update].concat(state.timeline)
|
||||
} else {
|
||||
state.unreadTimeline = [update].concat(state.unreadTimeline)
|
||||
}
|
||||
}
|
||||
},
|
||||
[MUTATION_TYPES.UPDATE_TIMELINE]: (state, messages: Array<Status>) => {
|
||||
state.timeline = messages
|
||||
|
Loading…
x
Reference in New Issue
Block a user