Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const assert = require('chai').assert
- const makeList = require('../makeList.js').makeList
- // may crash with NaN
- describe('creating a list', function () {
- let myList = makeList()
- let testInput = [
- '',
- 1,
- -30,
- 'panda',
- { testObj: 'pandisimo' },
- [1, 2, 3, 4]
- ]
- it('the list must begin as an empty one',function (){
- assert.equal(myList.toString(),'', 'on init the list is not empty')
- })
- it('it should add firstElem in list', function () {
- for (let testElem of testInput) {
- myList.addLeft(testElem)
- let output = Array.from(myList.toString().split(', '))
- assert.equal(output[0], testElem, 'dosent crate elem in empty list')
- }
- })
- // toString
- it('it should return string splited by comma and space',function(){
- let tempTest = myList.toString()
- let output = Array.from(tempTest.split(', '))
- assert.equal(output.length,testInput.length, 'dosent Split Correctly')
- })
- // add last elem
- it('it should add lastElem in list', function () {
- for (let testElem of testInput) {
- myList.addRight(testElem)
- let output = Array.from(myList.toString().split(', '))
- assert.equal(output[output.length-1], testElem, 'dosent crate elem in empty list')
- }
- })
- // clear the list
- it('it should clear the arr', function(){
- myList.clear()
- assert.equal(myList.toString(),'', 'dosent clear the list')
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement