UNPKG

rc-js-util

Version:

A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.

25 lines (21 loc) 716 B
import { Test_setDefaultFlags } from "../../test-util/test_set-default-flags.js"; import { LifecycleStack } from "./lifecycle-stack.js"; import { Test_resetLifeCycle } from "../../test-util/test_reset-life-cycle.js"; describe("=> LifecycleStack", () => { beforeEach(() => { Test_setDefaultFlags(); Test_resetLifeCycle(); }); it("| returns consistently from push and pop", () => { const stack = new LifecycleStack(); const first = stack.push(); const second = stack.push(); expect(second).not.toBe(first); expect(stack.pop()).toBe(second); expect(stack.pop()).toBe(first); expect(() => stack.pop()).toThrow(); }); });