dress
Version:
missing javascript prototypes(experimental)
47 lines (40 loc) • 1.63 kB
text/coffeescript
describe 'String::$starts', ->
it 'should control the string whether it stars with the parameter', (done) ->
string = 'This is a test string'
expect(string.$starts('This is')).to.be.true
expect(string.$starts('this is')).to.be.false
done()
describe 'String::$ends', ->
it 'should control the string whether it ends with the parameter', (done) ->
string = 'This is a test string'
expect(string.$ends('test string')).to.be.true
expect(string.$ends('test')).to.be.false
done()
describe 'String::$capitalize', ->
it 'should make the first letter up case', (done) ->
expect('nikola tesla'.$capitalize()).to.equal 'Nikola tesla'
done()
describe 'String::$titleize', ->
it 'should make every first letter upcase for every word', (done) ->
expect('nikola tesla'.$titleize()).to.equal 'Nikola Tesla'
done()
describe 'String::$integer', ->
it 'should return integer', (done) ->
expect('1'.$integer()).to.equal 1
expect('1.2'.$integer()).to.equal 1
done()
describe 'String::$number', ->
it 'should return number', (done) ->
expect('1.2'.$number()).to.equal 1.2
expect('1'.$number()).to.equal 1
done()
describe 'String::$date', ->
it 'should return correct date', (done) ->
expect('10.10.2010'.$date().getTime()).to.equal 1286658000000
expect('2010-10-07'.$date().getTime()).to.equal 1286409600000
expect('10.10.2010 10:11:12'.$date().getTime()).to.equal 1286694672000
done()
describe 'String::$parse', ->
it 'should parse json', (done) ->
expect('{ "a": 12, "b": "test" }'.$parse()).to.eql { a: 12, b: 'test' }
done()