Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: notification store without duplicates (#7135)
closes #7133 - ensure we don't add duplicate notifications to the in process notification store
- Loading branch information
Showing
3 changed files
with
51 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var rewire = require('rewire'), | ||
/*jshint unused:false*/ | ||
should = require('should'), | ||
NotificationAPI = rewire('../../../server/api/notifications'); | ||
|
||
describe('UNIT: Notification API', function () { | ||
it('ensure non duplicates', function (done) { | ||
var options = {context: {internal: true}}, | ||
notifications = [{ | ||
type: 'info', | ||
message: 'Hello, this is dog' | ||
}], | ||
notificationStore = NotificationAPI.__get__('notificationsStore'); | ||
|
||
NotificationAPI.add({notifications: notifications}, options) | ||
.then(function () { | ||
notificationStore.length.should.eql(1); | ||
return NotificationAPI.add({notifications: notifications}, options); | ||
}) | ||
.then(function () { | ||
notificationStore.length.should.eql(1); | ||
|
||
notifications.push({ | ||
type: 'info', | ||
message: 'Hello, this is cat' | ||
}); | ||
|
||
return NotificationAPI.add({notifications: notifications}, options); | ||
}) | ||
.then(function () { | ||
notificationStore.length.should.eql(2); | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
}); |