@@ -107,10 +107,10 @@ describe('Tests for NotificationsStore', function () {
107
107
108
108
jest . runAllTimers ( ) ;
109
109
110
- var repository = NotificationsStore . _notifications [ 0 ] [ 0 ] . repository ;
111
- var subject = NotificationsStore . _notifications [ 0 ] [ 0 ] . subject ;
110
+ var repository = NotificationsStore . _notifications [ 0 ] . repository ;
111
+ var subjectTitle = NotificationsStore . _notifications [ 0 ] . subject . title ;
112
112
expect ( repository . full_name ) . toBe ( 'octocat/Hello-World' ) ;
113
- expect ( subject . title ) . toBe ( 'Greetings' ) ;
113
+ expect ( subjectTitle ) . toBe ( 'Greetings' ) ;
114
114
expect ( NotificationsStore . trigger ) . toHaveBeenCalled ( ) ;
115
115
116
116
} ) ;
@@ -133,7 +133,7 @@ describe('Tests for NotificationsStore', function () {
133
133
134
134
} ) ;
135
135
136
- it ( 'should FAIL to create a booking via the API' , function ( ) {
136
+ it ( 'should FAIL to get the notifications from the GitHub API' , function ( ) {
137
137
138
138
spyOn ( NotificationsStore , 'trigger' ) ;
139
139
spyOn ( NotificationsStore , 'onGetNotificationsFailed' ) ;
@@ -149,4 +149,53 @@ describe('Tests for NotificationsStore', function () {
149
149
150
150
} ) ;
151
151
152
+ it ( 'should mark a notification as read - remove single notification from store' , function ( ) {
153
+
154
+ spyOn ( NotificationsStore , 'trigger' ) ;
155
+
156
+ NotificationsStore . _notifications = [ 'abc' , 'def' ] ;
157
+
158
+ expect ( NotificationsStore . _notifications . length ) . toBe ( 2 ) ;
159
+
160
+ Actions . removeNotification ( 'abc' ) ;
161
+
162
+ jest . runAllTimers ( ) ;
163
+
164
+ expect ( NotificationsStore . _notifications . length ) . toBe ( 1 ) ;
165
+ expect ( NotificationsStore . trigger ) . toHaveBeenCalled ( ) ;
166
+
167
+ } ) ;
168
+
169
+ it ( 'should mark a repo as read - remove notifications from store' , function ( ) {
170
+
171
+ spyOn ( NotificationsStore , 'trigger' ) ;
172
+
173
+ NotificationsStore . _notifications = [
174
+ {
175
+ 'id' : '1' ,
176
+ 'repository' : {
177
+ 'full_name' : 'ekonstantinidis/gitify'
178
+ } ,
179
+ 'unread' : true
180
+ } ,
181
+ {
182
+ 'id' : '2' ,
183
+ 'repository' : {
184
+ 'full_name' : 'ekonstantinidis/gitify'
185
+ } ,
186
+ 'reason' : 'subscribed'
187
+ }
188
+ ] ;
189
+
190
+ expect ( NotificationsStore . _notifications . length ) . toBe ( 2 ) ;
191
+
192
+ Actions . removeRepoNotifications ( 'ekonstantinidis/gitify' ) ;
193
+
194
+ jest . runAllTimers ( ) ;
195
+
196
+ expect ( NotificationsStore . _notifications . length ) . toBe ( 0 ) ;
197
+ expect ( NotificationsStore . trigger ) . toHaveBeenCalled ( ) ;
198
+
199
+ } ) ;
200
+
152
201
} ) ;
0 commit comments