UNPKG

priority-queue-with-custom-comparator

Version:

Priority queue data structure where you are able to set your own compare function.

24 lines (23 loc) 951 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const queue_1 = __importDefault(require("../src/queue")); const test_helper_1 = require("./test.helper"); afterEach(() => { jest.clearAllMocks(); }); test('initial state (created with initialElements)', () => { const numberPriorityQueue = new queue_1.default({ comparator: test_helper_1.defaultMaxComparator, initialElements: [2, 6, 7], }); expect(numberPriorityQueue.values().toString()).toBe([7, 6, 2].toString()); }); test('initial state (created without initialElements)', () => { const numberPriorityQueue = new queue_1.default({ comparator: test_helper_1.defaultMaxComparator, }); expect(numberPriorityQueue.values().toString()).toBe([].toString()); });