-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check that alerts can be registered and displayed via the alerts module
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
var test = require('tap-only'); | ||
var testUtils = require('./utils'); | ||
var alerts = require('../lib/alerts'); | ||
|
||
var exampleAlert = function (id, type) { | ||
type = type || 'info'; | ||
return { | ||
msg: 'Example alert ' + id, | ||
type: type, | ||
}; | ||
} | ||
|
||
test('register an alert', function (t) { | ||
t.plan(1); | ||
|
||
alerts.registerAlerts([ exampleAlert(1) ]); | ||
t.equal(alerts.displayAlerts().trim(), exampleAlert(1).msg, | ||
'alert is displayed'); | ||
}); | ||
|
||
test('register the same alert multiple times', function (t) { | ||
t.plan(1); | ||
|
||
alerts.registerAlerts([ exampleAlert(1) ]); | ||
alerts.registerAlerts([ exampleAlert(1) ]); | ||
t.equal(alerts.displayAlerts().trim(), exampleAlert(1).msg, | ||
'alert is only displayed once'); | ||
}); | ||
|
||
test('register two different alerts', function (t) { | ||
t.plan(2); | ||
|
||
alerts.registerAlerts([ exampleAlert(1) ]); | ||
alerts.registerAlerts([ exampleAlert(2) ]); | ||
const displayedAlerts = alerts.displayAlerts(); | ||
t.contains(displayedAlerts, exampleAlert(1).msg, | ||
'first alert is displayed'); | ||
t.contains(displayedAlerts, exampleAlert(2).msg, | ||
'second alert is displayed'); | ||
}); |