Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/ui/public/stringify/__tests__/_ip.js
Original file line number Diff line number Diff line change
@@ -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('-');
});

});
1 change: 1 addition & 0 deletions src/ui/public/stringify/types/Ip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down