aboutsummaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/specs/modules/statuses.spec.js141
1 files changed, 27 insertions, 114 deletions
diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js
index f929192b..ba459b38 100644
--- a/test/unit/specs/modules/statuses.spec.js
+++ b/test/unit/specs/modules/statuses.spec.js
@@ -286,40 +286,6 @@ describe('The Statuses module', () => {
})
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)
})
})
})