Advertisement
Lulunga

Unit Testing 05. String Builder

Oct 21st, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe('StringBuilder', function() {
  2.      it('Simple input test', function () {
  3.         let str = new StringBuilder('hello');
  4.          str.append(', there');
  5.          str.prepend('User, ');
  6.         str.insertAt('woop', 5);
  7.          str.remove(6, 3);
  8.  
  9.         expect(str.toString()).equal('User,w hello, there');
  10.      })
  11.  
  12.     it('Should throw error if not string input', function(){
  13.          expect(() => new StringBuilder(2)).to.throw();
  14.          let str = new StringBuilder('asd');
  15.         expect(() => str.append(234)).to.throw();
  16.     })
  17.  
  18.      it('Should have instance type', function(){
  19.          expect(StringBuilder.prototype).to.have.property('append');
  20.          expect(StringBuilder.prototype).to.have.property('prepend');
  21.          expect(StringBuilder.prototype).to.have.property('insertAt');
  22.          expect(StringBuilder.prototype).to.have.property('remove');
  23.          expect(StringBuilder.prototype).to.have.property('toString');
  24.     })
  25.  })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement