"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
let assert = require('assert');
const multipleInstanceManager_1 = require("../multipleInstanceManager");
const settings_1 = require("../settings");
let calledDestroy = false;
class Temp {
    constructor(token = "test") {
        this.id = "default";
        let config = settings_1.default.Instance.getCustom(token);
        this.id = config.id;
    }
    getId() {
        return this.id;
    }
    destroy() {
        calledDestroy = true;
    }
    getStatus() {
        return "ok";
    }
    isFunctional() {
        return true;
    }
}
let conf = {
    id: "global"
};
describe('test multiple instance manager', function () {
    it('complete test', function (done) {
        settings_1.default.Instance.setCustom("global", conf);
        let manager = new multipleInstanceManager_1.default(Temp);
        let instance = manager.get();
        assert.notEqual(instance, null);
        if (instance)
            assert.equal(instance.getId(), conf.id);
        assert.equal(manager.get("custom"), null);
        settings_1.default.Instance.setCustom("custom", { id: "custom" });
        manager.newInstance("custom");
        instance = manager.get("custom");
        assert.notEqual(instance, null);
        if (instance)
            assert.equal(instance.getId(), "custom");
        assert.equal(calledDestroy, false);
        manager.delete("custom");
        assert.equal(calledDestroy, true);
        assert.equal(manager.get("custom"), null);
        settings_1.default.Instance.setCustom("test", { id: "custom2" });
        let custom2 = new Temp();
        manager.set(custom2, "custom");
        instance = manager.get("custom");
        assert.notEqual(instance, null);
        if (instance)
            assert.equal(instance.getId(), "custom2");
        done();
    });
});
//# sourceMappingURL=test-multiple-instance-manager.js.map