Files
weave-scope/client/app/scripts/utils/__tests__/string-utils-test.js
Filip Barl d15e884cb1 Table-mode: sort ips numerically (#2007)
Fix #1746 - sort IPs numerically in the table mode
2016-11-22 11:05:59 +01:00

33 lines
872 B
JavaScript

describe('StringUtils', () => {
const StringUtils = require('../string-utils');
describe('formatMetric', () => {
const f = StringUtils.formatMetric;
it('it should render 0', () => {
expect(f(0)).toBe('0.00');
});
});
describe('longestCommonPrefix', () => {
const f = StringUtils.longestCommonPrefix;
it('it should return the longest common prefix', () => {
expect(f(['interspecies', 'interstellar'])).toBe('inters');
expect(f(['space', 'space'])).toBe('space');
expect(f([''])).toBe('');
expect(f(['prefix', 'suffix'])).toBe('');
});
});
describe('ipToPaddedString', () => {
const f = StringUtils.ipToPaddedString;
it('it should return the formatted IP', () => {
expect(f('10.244.253.4')).toBe('010.244.253.004');
expect(f('0.24.3.4')).toBe('000.024.003.004');
});
});
});