Skip to content

Commit a07c264

Browse files
sarceRoopeHakulinen
authored andcommitted
Avoid creating empty flashes. (#45)
1 parent 84a549d commit a07c264

8 files changed

+24
-8
lines changed

dist/angular-flash.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! angular-flash - v2.3.0 - 2016-04-24
1+
/*! angular-flash - v2.3.0 - 2016-08-23
22
* https://github.com/sachinchoolur/angular-flash
33
* Copyright (c) 2016 Sachin; Licensed MIT */
44

dist/angular-flash.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-flash.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-flash.min.css

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-flash.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-flash.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/angular-flash.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ app.provider('Flash', function() {
142142
dataFactory.config = defaultConfig;
143143

144144
dataFactory.create = function(type, text, timeout, config, showClose) {
145+
if (!text) return false;
145146
let $this, flash;
146147
$this = this;
147148
flash = {

test/angular-flash_test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ describe('Unit testing Angular Flash', function() {
2727
expect(contents[0].nodeType).toEqual(Node.ELEMENT_NODE);
2828
});
2929

30+
it('avoid to display flash when it does not have content', function() {
31+
created = Flash.create('success', '');
32+
$rootScope.$digest();
33+
var contents = node.contents()[0];
34+
expect(contents.querySelectorAll('.alert').length).toEqual(0);
35+
expect(created).toEqual(false);
36+
});
37+
3038
it('has the class specified', function() {
3139
var testClassName = 'test-class';
3240
Flash.create('success', 'Good job', 10000, {class: testClassName});

0 commit comments

Comments
 (0)