Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { expect } = require('chai');
- const stringOperations = require('./03.StringOperations');
- describe('StringOperations', () => {
- it('stringSlicer', () => {
- const str1 = 'Pesho';
- const str2 = 'Pe'
- expect(stringOperations.stringSlicer(str1)).to.equal('Pes...');
- expect(stringOperations.stringSlicer(str2)).to.equal('Pe...');
- });
- it('wordChecker', () => {
- const word1 = 'Pesho';
- const text1 = 'Pesho e ot selo';
- const text2 = 'Gosho e ot selo';
- expect(stringOperations.wordChecker(word1, text1)).to.equal('pesho');
- expect(stringOperations.wordChecker(word1, text2)).to.equal(`${word1.toLowerCase()} not found!`);
- });
- it('printEveryNthElement', () => {
- const n1 = 2;
- const n2 = 'asfsfa';
- const arr1 = ['a', 'b', 'c', 'd'];
- const arr2 = true;
- expect(stringOperations.printEveryNthElement(n1, arr1)).to.deep.equal(['a', 'c']);
- expect(() => stringOperations.printEveryNthElement(n2, arr1)).to.throw('The input is not valid!');
- expect(() => stringOperations.printEveryNthElement(n1, arr2)).to.throw('The input is not valid!');
- expect(() => stringOperations.printEveryNthElement(n2, arr2)).to.throw('The input is not valid!');
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment