UNPKG

@schukai/monster

Version:

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

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