Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('', function () {
- let list = {};
- beforeEach('', function () {
- list = a();
- });
- describe('testing add function', function () {
- it('should return empty string', function () {
- expect(list.toString()).to.be.equal('');
- });
- it('should add only 312', function () {
- list.add(312);
- expect(list.toString()).to.be.equal("312");
- });
- it('should add only 22.3', function () {
- list.add(22.3);
- expect(list.toString()).to.be.equal("22.3");
- });
- it('should add 5 pesho and Stamat to array', function () {
- list.add(5);
- list.add('pesho');
- list.add('Stamat');
- expect(list.toString()).to.be.equal("5, pesho, Stamat");
- });
- it('should add "-1" to array', function () {
- list.add("-1");
- list.add({name:"Pesho"});
- expect(list.toString()).to.be.equal('-1, [object Object]');
- });
- it('should add "[2]" to array', function () {
- list.add("[2]");
- expect(list.toString()).to.be.equal('[2]');
- });
- });
- describe('testing delete function', function () {
- it('should delete at position 1', function () {
- list.add("Pesho");
- list.add("1");
- list.add("3");
- expect(list.toString()).to.be.equal('Pesho, 1, 3');
- expect(list.delete(1)).to.be.equal("1");
- expect(list.toString()).to.be.equal('Pesho, 3')
- });
- it('should return correct result with valid input',function () {
- list.add(4);
- list.add(8);
- list.add("Ivan");
- list.add("Pesho");
- expect(list.toString()).to.be.equal('4, 8, Ivan, Pesho');
- expect(list.delete(2)).to.be.equal('Ivan');
- expect(list.toString()).to.be.equal('4, 8, Pesho');
- });
- it('should return correct result with valid input',function () {
- list.add(4);
- list.add(8);
- list.add("Ivan");
- list.add("Pesho");
- expect(list.toString()).to.be.equal('4, 8, Ivan, Pesho');
- expect(list.delete(2)).to.be.equal('Ivan');
- expect(list.toString()).to.be.equal('4, 8, Pesho');
- });
- it('should return undefined for non integer index',function () {
- list.add(5);
- list.add(133);
- list.add(-12);
- list.add("Stamat");
- list.add(5);
- expect(list.toString()).to.be.equal('5, 133, -12, Stamat, 5');
- expect(list.delete("Pesho")).to.be.equal(undefined);
- });
- it('should return undefined for negative index',function () {
- list.add(5);
- list.add(133);
- expect(list.delete(1)).to.be.equal(133);
- list.add(-12);
- list.add("Stamat");
- list.add(5);
- expect(list.toString()).to.be.equal('5, -12, Stamat, 5');
- expect(list.delete(-1)).to.be.equal(undefined);
- });
- it('should return undefined for index == arr.length',function () {
- list.add(5);
- list.add(133);
- expect(list.delete(1)).to.be.equal(133);
- list.add(-12);
- list.add("Stamat");
- list.add(5);
- expect(list.toString()).to.be.equal('5, -12, Stamat, 5');
- expect(list.delete(4)).to.be.equal(undefined);
- });
- it('should return undefined for index > arr.length',function () {
- list.add(5);
- list.add(133);
- expect(list.delete(1)).to.be.equal(133);
- list.add(-12);
- list.add("Stamat");
- list.add(5);
- expect(list.toString()).to.be.equal('5, -12, Stamat, 5');
- expect(list.delete(23)).to.be.equal(undefined);
- });
- it('should return undefined for floating point index',function () {
- list.add(5);
- list.add(12.5);
- expect(list.delete(0)).to.be.equal(5,'didnt delete correct item');
- list.add(-12);
- list.add("Stamat");
- list.add(5);
- expect(list.toString()).to.be.equal('12.5, -12, Stamat, 5');
- expect(list.delete(1.2)).to.be.equal(undefined);
- });
- });
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement