Skip to content

Commit

Permalink
Merge pull request #7259 from elastic/jasper/backport/7257/4.5
Browse files Browse the repository at this point in the history
[backport] PR #7257 to 4.5
  • Loading branch information
jbudz committed May 20, 2016
2 parents 05e232b + 6e5835a commit 5847228
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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

0 comments on commit 5847228

Please sign in to comment.