string format test

This commit is contained in:
antelle 2020-03-21 11:37:55 +01:00
parent a1a02d5098
commit 5cac16a632
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
import { expect } from 'chai';
import { StringFormat } from 'util/formatting/string-format';
describe('StringFormat', () => {
it('should capitalize first character', () => {
expect(StringFormat.capFirst('xYz')).to.eql('XYz');
});
it('should add number padding when required', () => {
expect(StringFormat.pad(123, 5)).to.eql('00123');
});
it('should not add number padding when not required', () => {
expect(StringFormat.pad(123, 3)).to.eql('123');
});
it('should add string padding when required', () => {
expect(StringFormat.padStr('abc', 5)).to.eql('abc ');
});
it('should not add string padding when not required', () => {
expect(StringFormat.padStr('abc', 3)).to.eql('abc');
});
it('should convert kebab case to camel case', () => {
expect(StringFormat.camelCase('aa-bbb-c')).to.eql('aaBbbC');
});
});