UNPKG

disposable-cls

Version:

Provides disposable continuation local storage for Node.js.

30 lines (29 loc) 1.32 kB
"use strict"; var chai_1 = require("chai"); var ContextStackItem_1 = require("../src/ContextStackItem"); /* * Test fixture for ContextStackItem */ describe("ContextStackItem", function () { describe("when initialized", function () { it("should have a single reference count", function () { chai_1.expect(new ContextStackItem_1.ContextStackItem(undefined, null).refCount).to.equal(1); }); }); describe("when referenced", function () { it("should have an incremented reference count", function () { var stackItem = new ContextStackItem_1.ContextStackItem(undefined, null); var currentRefCount = stackItem.refCount; chai_1.expect(stackItem.addRef()).to.equal(currentRefCount + 1); chai_1.expect(stackItem.refCount).to.equal(currentRefCount + 1); }); }); describe("when released", function () { it("should have a decremented reference count", function () { var stackItem = new ContextStackItem_1.ContextStackItem(undefined, null); var currentRefCount = stackItem.refCount; chai_1.expect(stackItem.release()).to.equal(currentRefCount - 1); chai_1.expect(stackItem.refCount).to.equal(currentRefCount - 1); }); }); });