414
414
'Relation with endpoint1 (relation type "relation1") was created');
418
describe('notification visual feedback', function() {
419
var env, models, notifications, notificationsView, notifierBox, views, Y;
421
before(function(done) {
422
Y = YUI(GlobalConfig).use('juju-env', 'juju-models', 'juju-views',
424
var juju = Y.namespace('juju');
425
env = new juju.Environment();
426
models = Y.namespace('juju.models');
427
views = Y.namespace('juju.views');
432
// Instantiate the notifications model list and view.
433
// Also create the notifier box and attach it as first element of the body.
434
beforeEach(function() {
435
notifications = new models.NotificationList();
436
notificationsView = new views.NotificationsView({
438
notifications: notifications
440
notifierBox = Y.Node.create('<div id="notifier-box"></div>');
441
notifierBox.setStyle('display', 'none');
442
Y.one('body').prepend(notifierBox);
445
// Destroy the notifier box created in beforeEach.
446
afterEach(function() {
447
notifierBox.remove();
448
notifierBox.destroy(true);
451
// Assert the notifier box contains the expectedNumber of notifiers.
452
var assertNumNotifiers = function(expectedNumber) {
453
assert.equal(expectedNumber, notifierBox.get('children').size());
456
it('should appear when a new error is notified', function() {
457
notifications.add({title: 'mytitle', level: 'error'});
458
assertNumNotifiers(1);
461
it('should only appear when the DOM contains the notifier box', function() {
462
notifierBox.remove();
463
notifications.add({title: 'mytitle', level: 'error'});
464
assertNumNotifiers(0);
467
it('should not appear when the notification is not an error', function() {
468
notifications.add({title: 'mytitle', level: 'info'});
469
assertNumNotifiers(0);
472
it('should not appear when the notification comes form delta', function() {
473
notifications.add({title: 'mytitle', level: 'error', isDelta: true});
474
assertNumNotifiers(0);