handle undefined, add test
This commit is contained in:
parent
d895aa5147
commit
cad6504ae1
|
@ -7,6 +7,7 @@ define(function (require) {
|
|||
* @returns {string}
|
||||
*/
|
||||
return function (text) {
|
||||
if (_.isUndefined(text)) return '';
|
||||
if (_.isString(text)) return text;
|
||||
if (_.isObject(text)) {
|
||||
if (text.query_string) return text.query_string.query;
|
||||
|
|
|
@ -182,6 +182,11 @@ define(function (require) {
|
|||
});
|
||||
|
||||
describe('model presentation formatter', function () {
|
||||
it('should present undefined as empty string', function () {
|
||||
var notDefined;
|
||||
expect(toUser(notDefined)).to.be('');
|
||||
});
|
||||
|
||||
it('should present objects as strings', function () {
|
||||
expect(toUser({foo: 'bar'})).to.be('{"foo":"bar"}');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue