Advertisement
kstoyanov

1.*C# Console-unit

Oct 27th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe('class Console static writeLine', () => {
  2.   it('should return the same string for single string argument', () => {
  3.     const string = 'One single string';
  4.     expect(Console.writeLine(string)).to.equal(string);
  5.   });
  6.   it('should return JSON string for single object argument', () => {
  7.     const object = { name: 'Pesho', age: 32 };
  8.     expect(Console.writeLine(object)).to.equal(JSON.stringify(object));
  9.   });
  10.   it('should throw error if no arguments were given', () => {
  11.     expect(() => Console.writeLine()).to.throw(TypeError);
  12.   });
  13.   it('should throw error if first argument is not string', () => {
  14.     expect(() => Console.writeLine(5, 1, 2)).to.throw(TypeError);
  15.   });
  16.   it('should throw error if placeholders are less than arguments', () => {
  17.     const string = 'This {0} should {1} replaced.';
  18.     expect(() => Console.writeLine(string, 'one', 'be', 'three')).to.throw(RangeError);
  19.   });
  20.   it('should throw error if place of placeholders is changed', () => {
  21.     const string = 'This {0} should {0} replaced.';
  22.     expect(() => Console.writeLine(string, 'one', 'be')).to.throw(RangeError);
  23.   });
  24.   it('should successfully replace placeholders with valid arguments', () => {
  25.     const string = 'This {0} should {1} replaced.';
  26.     expect(Console.writeLine(string, 'one', 'be')).to.equal('This one should be replaced.');
  27.   });
  28.   it('should throw error if invalid placeholder is given', () => {
  29.     const string = 'This {0} should {1} replaced. This one {2} not work.';
  30.     expect(() => Console.writeLine(string, 'one', 'be')).to.throw(RangeError);
  31.   });
  32.   it('should recognize the placeholder numbers well', () => {
  33.     expect(() => Console.writeLine('Not {10}', 'valid')).to.throw(RangeError);
  34.   });
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement