@mdsfe/mds-ui
Version:
A set of enterprise-class Vue UI components.
43 lines (36 loc) • 1.01 kB
JavaScript
;
var _switchcase = require('../switchcase.js');
describe('Util Switchcase', function () {
var rateMap = function rateMap(rate) {
return (0, _switchcase.switchcase)({
'1': 'Bad',
'2': 'Normal',
'3': 'Good'
})('No Info')(rate);
};
var rateFunctionMap = function rateFunctionMap(rate) {
return (0, _switchcase.switchcaseF)({
bad: function bad() {
return 1;
},
normal: function normal() {
return 2;
},
good: function good() {
return 3;
}
})('No Info')(rate);
};
it('should return the correct value', function () {
expect(rateMap('1')).toBe('Bad');
});
it('should return the default value', function () {
expect(rateMap('5')).toBe('No Info');
});
it('should execute the correct function', function () {
expect(rateFunctionMap('bad')).toBe(1);
});
it('should execute the correct function', function () {
expect(rateFunctionMap('what')).toBe('No Info');
});
});