UNPKG

@schukai/monster

Version:

Monster is a simple library for creating fast, robust and lightweight websites.

48 lines (35 loc) 1.33 kB
import {expect} from "chai" import {Queue} from "../../../source/types/queue.mjs"; describe('Queue', function () { let queue; beforeEach(() => { queue = new Queue; }) describe('isEmpty()', function () { it('first it should empty', function () { expect(queue.isEmpty()).to.be.true; }); }) describe('add sequence peek and poll', function () { it('result a,a,a,b', function () { expect(queue.add('a')).to.be.instanceOf(Queue); expect(queue.isEmpty()).to.be.false; expect(queue.add('b')).to.be.instanceOf(Queue); expect(queue.add('c')).to.be.instanceOf(Queue); expect(queue.peek()).to.be.equal('a'); expect(queue.peek()).to.be.equal('a'); expect(queue.poll()).to.be.equal('a'); expect(queue.peek()).to.be.equal('b'); expect(queue.isEmpty()).to.be.false; }); }) describe('add and clear', function () { it('should empty', function () { expect(queue.isEmpty()).to.be.true; expect(queue.add('a')).to.be.instanceOf(Queue); expect(queue.isEmpty()).to.be.false; expect(queue.clear()).to.be.instanceOf(Queue); expect(queue.isEmpty()).to.be.true; }); }) })