From cc7f7a29cf8435cc2486122976504c38ffe75c33 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 7 Nov 2016 18:36:11 +0100 Subject: Better retweet handling. Fixes problems with liking + likes count. --- test/unit/specs/modules/statuses.spec.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'test/unit/specs/modules/statuses.spec.js') diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js index 00a129e0..75736133 100644 --- a/test/unit/specs/modules/statuses.spec.js +++ b/test/unit/specs/modules/statuses.spec.js @@ -1,11 +1,11 @@ import { cloneDeep } from 'lodash' import { defaultState, mutations } from '../../../../src/modules/statuses.js' -const makeMockStatus = ({id}) => { +const makeMockStatus = ({id, text}) => { return { id, name: 'status', - text: `Text number ${id}`, + text: text || `Text number ${id}`, fave_num: 0, uri: '' } @@ -34,6 +34,24 @@ describe('The Statuses module', () => { expect(state.timelines.public.visibleStatuses).to.eql([status]) }) + it('splits retweets from their status and links them', () => { + const state = cloneDeep(defaultState) + const status = makeMockStatus({id: 1}) + const retweet = makeMockStatus({id: 2}) + const modStatus = makeMockStatus({id: 1, text: 'something else'}) + + retweet.retweeted_status = status + + // It adds both statuses + mutations.addNewStatuses(state, { statuses: [retweet], timeline: 'public' }) + expect(state.allStatuses).to.eql([retweet, status]) + + // It refers to the modified status. + mutations.addNewStatuses(state, { statuses: [modStatus], timeline: 'public' }) + expect(state.allStatuses).to.eql([retweet, modStatus]) + expect(retweet.retweeted_status).to.eql(modStatus) + }) + it('replaces existing statuses with the same id', () => { const state = cloneDeep(defaultState) const status = makeMockStatus({id: 1}) -- cgit v1.2.3-70-g09d2