76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
|
import { padLeft, padRight, padCenter, stringToPascal } from '../../../lib'
|
||
|
import { expect } from 'chai'
|
||
|
|
||
|
describe('util -> support -> string -> padLeft', () => {
|
||
|
it('should return the original string greater than the min', () => {
|
||
|
expect(padLeft('a longer string', 5))
|
||
|
.to.be.equal('a longer string')
|
||
|
})
|
||
|
|
||
|
it('should add spaces to the left of the string', () => {
|
||
|
expect(padLeft('string', 10))
|
||
|
.to.be.equal(' string')
|
||
|
})
|
||
|
|
||
|
it('should respect the pad parameter', () => {
|
||
|
expect(padLeft('string', 10, '*'))
|
||
|
.to.be.equal('****string')
|
||
|
})
|
||
|
})
|
||
|
|
||
|
describe('util -> support -> string -> padRight', () => {
|
||
|
it('should return the original string greater than the min', () => {
|
||
|
expect(padRight('a longer string', 5))
|
||
|
.to.be.equal('a longer string')
|
||
|
})
|
||
|
|
||
|
it('should add spaces to the right of the string', () => {
|
||
|
expect(padRight('string', 10))
|
||
|
.to.be.equal('string ')
|
||
|
})
|
||
|
|
||
|
it('should respect the pad parameter', () => {
|
||
|
expect(padRight('string', 10, '*'))
|
||
|
.to.be.equal('string****')
|
||
|
})
|
||
|
})
|
||
|
|
||
|
describe('util -> support -> string -> padCenter', () => {
|
||
|
it('should return the original string greater than the min', () => {
|
||
|
expect(padCenter('a longer string', 5))
|
||
|
.to.be.equal('a longer string')
|
||
|
})
|
||
|
|
||
|
it('should add spaces to both sides of the string', () => {
|
||
|
expect(padCenter('string', 10))
|
||
|
.to.be.equal(' string ')
|
||
|
})
|
||
|
|
||
|
it('should respect the pad parameter', () => {
|
||
|
expect(padCenter('string', 10, '*'))
|
||
|
.to.be.equal('**string**')
|
||
|
})
|
||
|
})
|
||
|
|
||
|
describe('util -> support -> string -> stringToPascal', () => {
|
||
|
it('should split inputs on spaces', () => {
|
||
|
expect(stringToPascal('foo bar baz'))
|
||
|
.to.be.equal('FooBarBaz')
|
||
|
})
|
||
|
|
||
|
it('should split inputs on underscores', () => {
|
||
|
expect(stringToPascal('foo_bar_baz'))
|
||
|
.to.be.equal('FooBarBaz')
|
||
|
})
|
||
|
|
||
|
it('should split inputs on dashes', () => {
|
||
|
expect(stringToPascal('foo-bar-baz'))
|
||
|
.to.be.equal('FooBarBaz')
|
||
|
})
|
||
|
|
||
|
it('should work with all delimiters', () => {
|
||
|
expect(stringToPascal('foo_bar-baz bin'))
|
||
|
.to.be.equal('FooBarBazBin')
|
||
|
})
|
||
|
})
|