Advertisement
xapu

Untitled

Jul 10th, 2017
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. const assert = require('chai').assert
  2. const makeList = require('../makeList.js').makeList
  3.  
  4.  
  5.  
  6. // may crash with NaN
  7. describe('creating a list', function () {
  8. let myList = makeList()
  9. let testInput = [
  10. '',
  11. 1,
  12. -30,
  13. 'panda',
  14. { testObj: 'pandisimo' },
  15. [1, 2, 3, 4]
  16. ]
  17.  
  18. it('the list must begin as an empty one',function (){
  19. assert.equal(myList.toString(),'', 'on init the list is not empty')
  20. })
  21.  
  22. it('it should add firstElem in list', function () {
  23. for (let testElem of testInput) {
  24. myList.addLeft(testElem)
  25. let output = Array.from(myList.toString().split(', '))
  26. assert.equal(output[0], testElem, 'dosent crate elem in empty list')
  27. }
  28. })
  29.  
  30. // toString
  31.  
  32.  
  33. it('it should return string splited by comma and space',function(){
  34. let tempTest = myList.toString()
  35. let output = Array.from(tempTest.split(', '))
  36.  
  37. assert.equal(output.length,testInput.length, 'dosent Split Correctly')
  38.  
  39. })
  40.  
  41.  
  42. // add last elem
  43. it('it should add lastElem in list', function () {
  44.  
  45. for (let testElem of testInput) {
  46. myList.addRight(testElem)
  47. let output = Array.from(myList.toString().split(', '))
  48. assert.equal(output[output.length-1], testElem, 'dosent crate elem in empty list')
  49. }
  50. })
  51. // clear the list
  52. it('it should clear the arr', function(){
  53. myList.clear()
  54. assert.equal(myList.toString(),'', 'dosent clear the list')
  55. })
  56.  
  57. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement