Files
weave-scope/client/app/scripts/utils/__tests__/string-utils-test.js

25 lines
677 B
JavaScript

jest.dontMock('../string-utils');
describe('StringUtils', () => {
const StringUtils = require('../string-utils');
describe('formatMetric', () => {
const formatMetric = StringUtils.formatMetric;
it('it should render 0', () => {
expect(formatMetric(0)).toBe('0.00');
});
});
describe('longestCommonPrefix', () => {
const fun = StringUtils.longestCommonPrefix;
it('it should return the longest common prefix', () => {
expect(fun(['interspecies', 'interstellar'])).toBe('inters');
expect(fun(['space', 'space'])).toBe('space');
expect(fun([''])).toBe('');
expect(fun(['prefix', 'suffix'])).toBe('');
});
});
});