Re-implement broken flashMessage directive tests

Marked as pending in f99b3619.

Signed-off-by: Alex Coles <alex@alexbcoles.com>
pull/2279/head
Alex Coles 10 years ago
parent 67a85728f3
commit 4011f8759e
  1. 78
      frontend/tests/unit/tests/ui_components/flash-message-directive-test.js

@ -28,70 +28,98 @@
/*jshint expr: true*/
var activateError;
describe('flash message Directive', function() {
describe('flashMessage Directive', function() {
var compile, element, rootScope, scope;
beforeEach(angular.mock.module('openproject.uiComponents'));
beforeEach(angular.mock.module('openproject.uiComponents', function($provide) {
var configurationService = {};
configurationService.accessibilityModeEnabled = sinon.stub().returns(true);
$provide.constant('ConfigurationService', configurationService);
}));
beforeEach(module('openproject.templates'));
beforeEach(inject(function($rootScope, $compile) {
var html = '<flash-message></flash-message>';
element = angular.element(html);
rootScope = $rootScope;
scope = $rootScope.$new();
compile = function() {
element = $compile(html)(scope);
$compile(element)(scope);
scope.$digest();
};
activateError = sinon.spy();
}));
context('with no message', function() {
beforeEach(function() {
compile();
});
describe('element', function() {
xit('should render nothing initially', function() {
expect(element.html()).to.be.null;
it('should render no message initially', function() {
expect(element.text()).to.be.equal('');
});
it('should be hidden', function() {
expect(element.hasClass('ng-hide')).to.be.true;
});
});
describe('flash properties', function() {
context('with flash messages', function() {
beforeEach(function() {
compile();
});
describe('info message', function() {
var message = {text: 'Test', isError: false};
var message = {
text: 'für deine Informationen',
isError: false
};
beforeEach(function() {
rootScope.$emit('flashMessage', message);
scope.$apply();
});
it('should render message', function() {
expect(element.text().trim()).to.equal('für deine Informationen');
});
xit('should render message', function() {
var directiveScope = element.isolateScope();
it('should be visible', function() {
expect(element.hasClass('ng-hide')).to.be.false;
});
expect(directiveScope.flashClass).to.equal("flash notice icon icon-notice");
expect(directiveScope.flashId).to.be.empty;
expect(directiveScope.message.text).to.equal(message.text);
expect(directiveScope.message.isError).to.equal(message.isError);
it('should style as an info message', function() {
expect(element.attr('class').split(' ')).to
.include.members(['flash', 'icon-notice', 'notice']);
});
});
describe('error message', function() {
var message = {text: 'Error', isError: true};
var message = {
text: '¡Alerta! WARNING! Achtung!',
isError: true
};
beforeEach(function() {
rootScope.$emit('flashMessage', message);
scope.$apply();
});
xit('should render message', function() {
var directiveScope = element.isolateScope();
it('should render message', function() {
expect(element.text().trim()).to.equal('¡Alerta! WARNING! Achtung!');
});
it('should be visible', function() {
expect(element.hasClass('ng-hide')).to.be.false;
});
expect(directiveScope.flashClass).to.equal("errorExplanation");
expect(directiveScope.flashId).to.be.equal("errorExplanation");
expect(directiveScope.message.text).to.equal(message.text);
expect(directiveScope.message.isError).to.equal(message.isError);
it('should style as an error message', function() {
expect(element.attr('class').split(' ')).to
.include.members(['flash', 'icon-errorExplanation', 'errorExplanation']);
});
});
});

Loading…
Cancel
Save