aboutsummaryrefslogtreecommitdiff
path: root/test/unit/specs
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/specs')
-rw-r--r--test/unit/specs/modules/statuses.spec.js147
1 files changed, 30 insertions, 117 deletions
diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js
index f929192b..7d403312 100644
--- a/test/unit/specs/modules/statuses.spec.js
+++ b/test/unit/specs/modules/statuses.spec.js
@@ -247,7 +247,7 @@ describe('The Statuses module', () => {
in_reply_to_status_id: '1', // The API uses strings here...
uri: 'tag:shitposter.club,2016-08-21:fave:3895:note:773501:2016-08-21T16:52:15+00:00',
text: 'a favorited something by b',
- user: {}
+ user: { id: 99 }
}
mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' })
@@ -264,7 +264,7 @@ describe('The Statuses module', () => {
expect(state.timelines.public.visibleStatuses[0].fave_num).to.eql(1)
expect(state.timelines.public.maxId).to.eq(favorite.id)
- // If something is favorited by the current user, it also sets the 'favorited' property
+ // If something is favorited by the current user, it also sets the 'favorited' property but does not increment counter to avoid over-counting. Counter is incremented (updated, really) via response to the favorite request.
const user = {
id: 1
}
@@ -281,45 +281,11 @@ describe('The Statuses module', () => {
mutations.addNewStatuses(state, { statuses: [ownFavorite], showImmediately: true, timeline: 'public', user })
expect(state.timelines.public.visibleStatuses.length).to.eql(1)
- expect(state.timelines.public.visibleStatuses[0].fave_num).to.eql(2)
+ expect(state.timelines.public.visibleStatuses[0].fave_num).to.eql(1)
expect(state.timelines.public.visibleStatuses[0].favorited).to.eql(true)
})
describe('notifications', () => {
- it('adds a notfications for retweets if you are the retweetet', () => {
- const user = { id: 1 }
- const state = cloneDeep(defaultState)
- const status = makeMockStatus({id: 1})
- status.user = user
- const retweet = makeMockStatus({id: 2, is_post_verb: false})
- retweet.retweeted_status = status
-
- mutations.addNewStatuses(state, { statuses: [retweet], user })
-
- expect(state.notifications.length).to.eql(1)
- expect(state.notifications[0].status).to.eql(retweet)
- expect(state.notifications[0].action).to.eql(retweet)
- expect(state.notifications[0].type).to.eql('repeat')
- })
-
- it('adds a notification when you are mentioned', () => {
- const user = { id: 1 }
- const state = cloneDeep(defaultState)
- const status = makeMockStatus({id: 1})
- const mentionedStatus = makeMockStatus({id: 2})
- mentionedStatus.attentions = [user]
-
- mutations.addNewStatuses(state, { statuses: [status], user })
-
- expect(state.notifications.length).to.eql(0)
-
- mutations.addNewStatuses(state, { statuses: [mentionedStatus], user })
- expect(state.notifications.length).to.eql(1)
- expect(state.notifications[0].status).to.eql(mentionedStatus)
- expect(state.notifications[0].action).to.eql(mentionedStatus)
- expect(state.notifications[0].type).to.eql('mention')
- })
-
it('removes a notification when the notice gets removed', () => {
const user = { id: 1 }
const state = cloneDeep(defaultState)
@@ -335,92 +301,39 @@ describe('The Statuses module', () => {
deletion.uri = 'xxx'
mutations.addNewStatuses(state, { statuses: [status, otherStatus], user })
-
- expect(state.notifications.length).to.eql(1)
+ mutations.addNewNotifications(
+ state,
+ {
+ notifications: [{
+ ntype: 'mention',
+ status: otherStatus,
+ notice: otherStatus,
+ is_seen: false
+ }]
+ })
+
+ expect(state.notifications.data.length).to.eql(1)
+ mutations.addNewNotifications(
+ state,
+ {
+ notifications: [{
+ ntype: 'mention',
+ status: mentionedStatus,
+ notice: mentionedStatus,
+ is_seen: false
+ }]
+ })
mutations.addNewStatuses(state, { statuses: [mentionedStatus], user })
expect(state.allStatuses.length).to.eql(3)
- expect(state.notifications.length).to.eql(2)
- expect(state.notifications[1].status).to.eql(mentionedStatus)
- expect(state.notifications[1].action).to.eql(mentionedStatus)
- expect(state.notifications[1].type).to.eql('mention')
+ expect(state.notifications.data.length).to.eql(2)
+ expect(state.notifications.data[1].status).to.eql(mentionedStatus)
+ expect(state.notifications.data[1].action).to.eql(mentionedStatus)
+ expect(state.notifications.data[1].type).to.eql('mention')
mutations.addNewStatuses(state, { statuses: [deletion], user })
expect(state.allStatuses.length).to.eql(2)
- expect(state.notifications.length).to.eql(1)
- })
-
- it('adds the message to mentions when you are mentioned', () => {
- const user = { id: 1 }
- const state = cloneDeep(defaultState)
- const status = makeMockStatus({id: 1})
- const mentionedStatus = makeMockStatus({id: 2})
- mentionedStatus.attentions = [user]
-
- mutations.addNewStatuses(state, { statuses: [status], user })
-
- expect(state.timelines.mentions.statuses).to.have.length(0)
-
- mutations.addNewStatuses(state, { statuses: [mentionedStatus], user })
- expect(state.timelines.mentions.statuses).to.have.length(1)
- expect(state.timelines.mentions.statuses).to.eql([mentionedStatus])
- })
-
- it('adds a notfication when one of the user\'s status is favorited', () => {
- const state = cloneDeep(defaultState)
- const status = makeMockStatus({id: 1})
- const user = {id: 1}
- status.user = user
-
- const favorite = {
- id: 2,
- is_post_verb: false,
- in_reply_to_status_id: '1', // The API uses strings here...
- uri: 'tag:shitposter.club,2016-08-21:fave:3895:note:773501:2016-08-21T16:52:15+00:00',
- text: 'a favorited something by b',
- user: {}
- }
-
- mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public', user })
- mutations.addNewStatuses(state, { statuses: [favorite], showImmediately: true, timeline: 'public', user })
-
- expect(state.notifications).to.have.length(1)
- })
-
- it('adds a notification when the user is followed', () => {
- const state = cloneDeep(defaultState)
- const user = {id: 1, screen_name: 'b'}
- const follower = {id: 2, screen_name: 'a'}
-
- const follow = {
- id: 3,
- is_post_verb: false,
- activity_type: 'follow',
- text: 'a started following b',
- user: follower
- }
-
- mutations.addNewStatuses(state, { statuses: [follow], showImmediately: true, timeline: 'public', user })
-
- expect(state.notifications).to.have.length(1)
- })
-
- it('does not add a notification when an other user is followed', () => {
- const state = cloneDeep(defaultState)
- const user = {id: 1, screen_name: 'b'}
- const follower = {id: 2, screen_name: 'a'}
-
- const follow = {
- id: 3,
- is_post_verb: false,
- activity_type: 'follow',
- text: 'a started following b@shitposter.club',
- user: follower
- }
-
- mutations.addNewStatuses(state, { statuses: [follow], showImmediately: true, timeline: 'public', user })
-
- expect(state.notifications).to.have.length(0)
+ expect(state.notifications.data.length).to.eql(1)
})
})
})