72 lines
6.7 KiB
JavaScript
72 lines
6.7 KiB
JavaScript
"use strict";
|
|
require("typings-test");
|
|
const lik = require("../dist/index");
|
|
require("should");
|
|
describe("lik", function () {
|
|
describe("Stringmap", function () {
|
|
let testStringmap;
|
|
let testString1 = "testString1";
|
|
let testString2 = "testString2";
|
|
let testString3 = "testString3";
|
|
it("should create an instance of Stringmap", function () {
|
|
testStringmap = new lik.Stringmap();
|
|
testStringmap.should.be.instanceof(lik.Stringmap);
|
|
});
|
|
it("should return false for an string not in Stringmap", function () {
|
|
testStringmap.checkString(testString1).should.be.false();
|
|
});
|
|
it("should add an string to Stringmap", function () {
|
|
testStringmap.addString(testString1);
|
|
testStringmap.addString(testString2);
|
|
testStringmap.addString(testString3);
|
|
testStringmap.checkString(testString1).should.be.true();
|
|
testStringmap.checkString(testString2).should.be.true();
|
|
testStringmap.checkString(testString3).should.be.true();
|
|
testStringmap.checkMinimatch("*String1").should.be.true();
|
|
testStringmap.checkMinimatch("*String2").should.be.true();
|
|
testStringmap.checkMinimatch("*String4").should.be.false();
|
|
});
|
|
it("should remove a string from Stringmap", function () {
|
|
testStringmap.removeString(testString2);
|
|
testStringmap.checkString(testString2).should.be.false();
|
|
});
|
|
it("should register a function to trigger when empty", function () {
|
|
testStringmap.registerUntilTrue(() => { return testStringmap.checkIsEmpty(); }, () => { console.log("Stringmap now is empty"); });
|
|
});
|
|
it("should remove wipe and then notify", function () {
|
|
testStringmap.wipe();
|
|
});
|
|
});
|
|
describe("Objectmap", function () {
|
|
let testObjectmap;
|
|
let testObject1 = {
|
|
propOne: "hello",
|
|
propTwo: "hello2"
|
|
};
|
|
let testObject2 = {
|
|
propOne: "hello",
|
|
propTwo: "hello2"
|
|
};
|
|
it("should correctly instantiate an Objectmap", function () {
|
|
testObjectmap = new lik.Objectmap();
|
|
testObjectmap.should.be.instanceof(lik.Objectmap);
|
|
});
|
|
it("should correctly add an object to Objectmap", function () {
|
|
testObjectmap.add(testObject1);
|
|
testObjectmap.checkForObject(testObject1).should.be.true;
|
|
testObjectmap.checkForObject(testObject2).should.be.false;
|
|
});
|
|
it("should correctly remove an object to Objectmap", function () {
|
|
testObjectmap.add(testObject2);
|
|
testObjectmap.remove(testObject1);
|
|
testObjectmap.checkForObject(testObject1).should.be.false;
|
|
testObjectmap.checkForObject(testObject2).should.be.true;
|
|
});
|
|
it("should correctly run a function forEach map object", function () {
|
|
testObjectmap.forEach(itemArg => {
|
|
itemArg.should.have.ownProperty("propOne");
|
|
});
|
|
});
|
|
});
|
|
});
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsTUFBTyxHQUFHLFdBQVcsZUFBZSxDQUFDLENBQUM7QUFDdEMsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUVoQixRQUFRLENBQUMsS0FBSyxFQUFDO0lBQ1gsUUFBUSxDQUFDLFdBQVcsRUFBQztRQUNqQixJQUFJLGFBQTJCLENBQUM7UUFDaEMsSUFBSSxXQUFXLEdBQUcsYUFBYSxDQUFDO1FBQ2hDLElBQUksV0FBVyxHQUFHLGFBQWEsQ0FBQztRQUNoQyxJQUFJLFdBQVcsR0FBRyxhQUFhLENBQUM7UUFDaEMsRUFBRSxDQUFDLHdDQUF3QyxFQUFDO1lBQ3hDLGFBQWEsR0FBRyxJQUFJLEdBQUcsQ0FBQyxTQUFTLEVBQUUsQ0FBQztZQUNwQyxhQUFhLENBQUMsTUFBTSxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsR0FBRyxDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBQ3RELENBQUMsQ0FBQyxDQUFDO1FBQ0gsRUFBRSxDQUFDLG9EQUFvRCxFQUFDO1lBQ3BELGFBQWEsQ0FBQyxX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