UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

42 lines (40 loc) 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const utils_1 = require("./../../utils"); describe("ArrayUtils", () => { describe(`#${"isNullOrEmpty"}()`, () => { it("should return true when null", () => { chai_1.expect(utils_1.ArrayUtils.isNullOrEmpty(null)).to.equal(true); }); it("should return true when undefined", () => { chai_1.expect(utils_1.ArrayUtils.isNullOrEmpty(undefined)).to.equal(true); }); it("should return true when empty", () => { chai_1.expect(utils_1.ArrayUtils.isNullOrEmpty([])).to.equal(true); }); it("should return false when not empty", () => { chai_1.expect(utils_1.ArrayUtils.isNullOrEmpty([1])).to.equal(false); }); }); describe(`#${"getUniqueItems"}()`, () => { it("should return all the unique items in the array", () => { chai_1.expect(utils_1.ArrayUtils.getUniqueItems([1, 2, 3, 3, 2, 1])).to.eql([1, 2, 3]); }); }); describe(`#${"removeFirst"}()`, () => { it("should remove the first value", () => { const a = [1, 2, 3, 3]; const result = utils_1.ArrayUtils.removeFirst(a, 3); chai_1.expect(a).to.eql([1, 2, 3]); chai_1.expect(result).to.equal(true); }); it("should not remove if not found", () => { const a = [1, 2, 3, 3]; const result = utils_1.ArrayUtils.removeFirst(a, 4); chai_1.expect(a).to.eql([1, 2, 3, 3]); chai_1.expect(result).to.equal(false); }); }); }); //# sourceMappingURL=arrayUtilsTests.js.map