Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('class Console static writeLine', () => {
- it('should return the same string for single string argument', () => {
- const string = 'One single string';
- expect(Console.writeLine(string)).to.equal(string);
- });
- it('should return JSON string for single object argument', () => {
- const object = { name: 'Pesho', age: 32 };
- expect(Console.writeLine(object)).to.equal(JSON.stringify(object));
- });
- it('should throw error if no arguments were given', () => {
- expect(() => Console.writeLine()).to.throw(TypeError);
- });
- it('should throw error if first argument is not string', () => {
- expect(() => Console.writeLine(5, 1, 2)).to.throw(TypeError);
- });
- it('should throw error if placeholders are less than arguments', () => {
- const string = 'This {0} should {1} replaced.';
- expect(() => Console.writeLine(string, 'one', 'be', 'three')).to.throw(RangeError);
- });
- it('should throw error if place of placeholders is changed', () => {
- const string = 'This {0} should {0} replaced.';
- expect(() => Console.writeLine(string, 'one', 'be')).to.throw(RangeError);
- });
- it('should successfully replace placeholders with valid arguments', () => {
- const string = 'This {0} should {1} replaced.';
- expect(Console.writeLine(string, 'one', 'be')).to.equal('This one should be replaced.');
- });
- it('should throw error if invalid placeholder is given', () => {
- const string = 'This {0} should {1} replaced. This one {2} not work.';
- expect(() => Console.writeLine(string, 'one', 'be')).to.throw(RangeError);
- });
- it('should recognize the placeholder numbers well', () => {
- expect(() => Console.writeLine('Not {10}', 'valid')).to.throw(RangeError);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement