@variantjs/core
Version:
VariantJS common functions and utilities
23 lines (18 loc) • 530 B
text/typescript
import pad from '../helpers/pad';
describe('pad', () => {
it('adds a leading zero to a string', () => {
expect(pad('1')).toBe('01');
});
it('adds a leading zero to a number', () => {
expect(pad(1)).toBe('01');
});
it('doesnt adds more zero if already have 2 chars', () => {
expect(pad('11')).toBe('11');
});
it('doesnt adds more zero if more than 2 chars', () => {
expect(pad('111')).toBe('111');
});
it('adds up to 5 leading zeros', () => {
expect(pad('23', 5)).toBe('00023');
});
});