diff --git a/src/ui/public/stringify/__tests__/_ip.js b/src/ui/public/stringify/__tests__/_ip.js index e8c07e9051c0..208816c08ce3 100644 --- a/src/ui/public/stringify/__tests__/_ip.js +++ b/src/ui/public/stringify/__tests__/_ip.js @@ -1,16 +1,21 @@ describe('IP Address Format', function () { - let fieldFormats; let expect = require('expect.js'); let ngMock = require('ngMock'); + let ip; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { - fieldFormats = Private(require('ui/registry/field_formats')); + const fieldFormats = Private(require('ui/registry/field_formats')); + ip = fieldFormats.getInstance('ip'); })); it('convers a value from a decimal to a string', function () { - let ip = fieldFormats.getInstance('ip'); expect(ip.convert(1186489492)).to.be('70.184.100.148'); }); + it('converts null and undefined to -', function () { + expect(ip.convert(null)).to.be('-'); + expect(ip.convert(undefined)).to.be('-'); + }); + }); diff --git a/src/ui/public/stringify/types/Ip.js b/src/ui/public/stringify/types/Ip.js index 2741d44dfcb8..ca5e860f38f2 100644 --- a/src/ui/public/stringify/types/Ip.js +++ b/src/ui/public/stringify/types/Ip.js @@ -13,6 +13,7 @@ define(function (require) { Ip.fieldType = 'ip'; Ip.prototype._convert = function (val) { + if (val === undefined || val === null) return '-'; if (!isFinite(val)) return val; // shazzam!