import formatString from '../src/string-utils/format-string'; describe('String format utility', () => { it('checks if the utlity formats a string correctly based on one argument', () => { expect(formatString('One argument - {0}', 'foo')).toBe('One argument - foo'); }); it('checks if the utlity formats a string correctly based on multiple arguments provided serially', () => { expect(formatString('One argument - {0}, {1}, {2}, {3}', 'foo', 'bar', 'baz', 'qux')).toBe('One argument - foo, bar, baz, qux'); }); it('checks if the utlity formats a string correctly based on multiple arguments provided serially and ignores extra arguments', () => { expect(formatString('One argument - {0}, {1}, {2}, {3}, {4} = {5}', 'foo', 'bar', 'baz', 'qux')).toBe('One argument - foo, bar, baz, qux, {4} = {5}'); }); it('checks if the utlity formats a string correctly based on multiple arguments provided non-serially', () => { expect(formatString('One argument - {1}, {0}, {3}, {2}', 'foo', 'bar', 'baz', 'qux')).toBe('One argument - bar, foo, qux, baz'); }); it('checks if the utlity formats a string correctly based on same argument used multiple times', () => { expect(formatString('One argument - {0}, {1}, {0}, {1}', 'foo', 'bar')).toBe('One argument - foo, bar, foo, bar'); }); it('checks if the utlity formats a string correctly and ignores extra arguments', () => { expect(formatString('One argument - {0}, {1}', 'foo', 'bar', 'baz', 'qux')).toBe('One argument - foo, bar'); }); });