string-tool
Version:
Useful functions for Strings
26 lines (25 loc) • 1.2 kB
JavaScript
;
exports.__esModule = true;
var String_1 = require("../String");
describe('capitalize', function () {
it('should return true when the first letter was capitalized correctly', function () {
expect(String_1.capitalize('a')).toEqual('A');
expect(String_1.capitalize('ß')).toEqual('SS');
expect(String_1.capitalize('über')).toEqual('Über');
expect(String_1.capitalize('égalité')).toEqual('Égalité');
});
it('should return an empty string when the input is empty', function () {
expect(String_1.capitalize('')).toEqual('');
});
});
describe('nthIndexOf', function () {
it('should find the position of the searchString', function () {
expect(String_1.nthIndexOf('testtest test', 1, 'test')).toEqual(0);
expect(String_1.nthIndexOf('testtest test', 2, 'test')).toEqual(4);
expect(String_1.nthIndexOf('testtest test', 3, 'test')).toEqual(9);
});
it('should return undefined when the searchString does not exist', function () {
expect(String_1.nthIndexOf('testtest test', 0, 'test')).toBe(undefined);
expect(String_1.nthIndexOf('bla bla bla', 2, 'test')).toBe(undefined);
});
});