/**
 * Copyright (c) 2016-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */ import * as Maybe from '../maybe' ; import * as Queue from '../queue' ; describe ( 'Queue' , function ( ) { describe ( '#dequeue' , function ( ) { it ( 'gives back nothing when nothing has been added' , function ( ) { const queue = Queue . Empty < number > ( ) ; const result = Queue . dequeue ( queue ) ; const expectedResult = { value : null , queue : Queue . Empty < number > ( ) } ; expect ( result ) . toEqualJSON ( expectedResult ) ; } ) ; it ( 'gives back a single value and an empty queue one thing has been added' , function ( ) { const queue = Queue . Empty < number > ( ) ; const updatedQueue = Queue . enqueue ( 1 , queue ) ; const result = Queue . dequeue ( updatedQueue ) ; const expectedResult = { value : 1 , queue : Queue . Empty < number > ( ) } ; expect ( result ) . toEqualJSON ( expectedResult ) ; } ) ; it ( 'gives back a single value and a non empty queue two things has been added' , function ( ) { const queue = Queue . Empty < number > ( ) ; const updatedQueue1 = Queue . enqueue ( 1 , queue ) ; const updatedQueue2 = Queue . enqueue ( 2 , updatedQueue1 ) ; const result = Queue . dequeue ( updatedQueue2 ) ; const expectedResult = { value : 1 , queue : Queue . of < number > ( 2 ) } ; expect ( result ) . toEqualJSON ( expectedResult ) ; } ) ; it ( 'gives back a single value and an empty queue two things has been added and then ' + 'dequeued' , function ( ) { const queue = Queue . Empty < number > ( ) ; const updatedQueue1 = Queue . enqueue ( 1 , queue ) ; const updatedQueue2 = Queue . enqueue ( 2 , updatedQueue1 ) ; const result1 = Queue . dequeue ( updatedQueue2 ) ; const result2 = Queue . dequeue ( result1 . queue ) ; const expectedResult = { value : 2 , queue : Queue . Empty < number > ( ) } ; expect ( result2 ) . toEqualJSON ( expectedResult ) ; } ) ; } ) ; } ) ;