<html>
<head>
  <meta charset="utf-8">
  <title>Mocha Tests</title>
  <link href="https://unpkg.com/mocha@5.2.0/mocha.css" rel="stylesheet" />
</head>
<body>
  <div id="mocha"></div>

  <script src="https://unpkg.com/chai/chai.js"></script>
  <script src="https://unpkg.com/mocha@5.2.0/mocha.js"></script>

  <div></div>
  

</body>
</html>
class Node{
  
  constructor(data){
    this.data = data;
    this.next = null;
  }
  
}



class Queue{
   constructor(){
     this.first = null;
     this.last = null
     this.size = 0
   }
  
  
  enqueue(data){
    
    let node = new Node(data)
    
    if(!this.first){
      this.first = node
      this.last = node
    }else{
      this.last.next = node
      this.last = node
    }
    
    this.size++
  }
  
  dequeue(){
    
    if(!this.first) return null;
    
    let node = this.first
    
   if(node.next){
     node = node.next
     this.first = node
   }else{
     this.first = null
     this.last = null
   }
    
    this.size--
  }

}



mocha.setup('bdd');


var assert = chai.assert;

describe('Queues',()=>{
  
  it("should add  new node at the end",()=>{
    
    const queue = new Queue();
    queue.enqueue(10);
    queue.enqueue(9);
    queue.enqueue(8); 
    
    assert.equal(3,queue.size)
    assert.equal(8,queue.last.data)
      
  })

     it("should remove the node ",()=>{
    const queue = new Queue();
    queue.enqueue(10);
    queue.enqueue(9);
    queue.enqueue(8); 
    queue.enqueue(7); 
   
   
       queue.dequeue();
       queue.dequeue();
       queue.dequeue();
       
       
       
    assert.equal(7,queue.last.data)
  })
  
  
 
  
})



mocha.run()

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.