Commit acb0a67a authored by Robert Knight's avatar Robert Knight

Convert "flash" service to JS

Remove `angular.bind` dependency since `Function.prototype.bind` is now
ubiquitous.
parent 134aec53
module.exports = ['toastr', (toastr) ->
info: angular.bind(toastr, toastr.info)
success: angular.bind(toastr, toastr.success)
warning: angular.bind(toastr, toastr.warning)
error: angular.bind(toastr, toastr.error)
]
'use strict';
/**
* A service for displaying "flash" notification messages.
*/
// @ngInject
function flash(toastr) {
return {
info: toastr.info.bind(toastr),
success: toastr.success.bind(toastr),
warning: toastr.warning.bind(toastr),
error: toastr.error.bind(toastr),
};
}
module.exports = flash;
'use strict';
var flash = require('../flash');
describe('sidebar.flash', () => {
['info', 'success', 'warning', 'error'].forEach(method => {
describe(`#${method}`, () => {
it(`calls toastr's "${method}" method`, () => {
var fakeToastr = {
info: sinon.stub(),
success: sinon.stub(),
warning: sinon.stub(),
error: sinon.stub(),
};
var svc = flash(fakeToastr);
svc[method]('message', 'title');
assert.calledWith(fakeToastr[method], 'message', 'title');
});
});
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment