var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "@web-atoms/unit-test/dist/Assert", "@web-atoms/unit-test/dist/Test", "../../core/AtomBinder", "../../core/AtomList", "../../core/AtomWatcher", "../../unit/AtomTest"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Assert_1 = require("@web-atoms/unit-test/dist/Assert");
    var Test_1 = require("@web-atoms/unit-test/dist/Test");
    var AtomBinder_1 = require("../../core/AtomBinder");
    var AtomList_1 = require("../../core/AtomList");
    var AtomWatcher_1 = require("../../core/AtomWatcher");
    var AtomTest_1 = require("../../unit/AtomTest");
    var AtomBinderTest = /** @class */ (function (_super) {
        __extends(AtomBinderTest, _super);
        function AtomBinderTest() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        AtomBinderTest.prototype.refreshValue = function () {
            AtomBinder_1.AtomBinder.refreshValue(undefined, "key");
            AtomBinder_1.AtomBinder.refreshValue(null, "key");
        };
        AtomBinderTest.prototype.emptyReturns = function () {
            AtomBinder_1.AtomBinder.add_WatchHandler(null, "", null);
            AtomBinder_1.AtomBinder.invokeItemsEvent([], "", 0, {});
            AtomBinder_1.AtomBinder.remove_WatchHandler(null, "", null);
            AtomBinder_1.AtomBinder.remove_WatchHandler({}, "a", null);
            // tslint:disable-next-line: no-empty
            var f = function () { };
            var a = {};
            AtomBinder_1.AtomBinder.add_WatchHandler(a, "a", f);
            AtomBinder_1.AtomBinder.remove_WatchHandler(a, "b", f);
            AtomBinder_1.AtomBinder.remove_WatchHandler(a, "a", f);
            AtomBinder_1.AtomBinder.remove_CollectionChanged(null, null);
            AtomBinder_1.AtomBinder.remove_CollectionChanged([], null);
            var ar = [];
            AtomBinder_1.AtomBinder.invokeItemsEvent(null, "", 0, {});
            AtomBinder_1.AtomBinder.add_WatchHandler(ar, "length", f);
            AtomBinder_1.AtomBinder.invokeItemsEvent(ar, "", 0, {});
            AtomBinder_1.AtomBinder.remove_CollectionChanged(ar, null);
        };
        AtomBinderTest.prototype.nullExceptions = function () {
            Assert_1.default.throws("Target Array to watch cannot be null", function () {
                return AtomBinder_1.AtomBinder.add_CollectionChanged(null, null);
            });
            Assert_1.default.throws("Target handle to watch an Array cannot be null", function () {
                return AtomBinder_1.AtomBinder.add_CollectionChanged([], null);
            });
        };
        AtomBinderTest.prototype.clear = function () {
            var a = [1, 2];
            AtomBinder_1.AtomBinder.clear(a);
            Assert_1.default.equals(0, a.length);
            AtomBinder_1.AtomBinder.addItem(a, 1);
            Assert_1.default.equals(1, a.length);
            AtomBinder_1.AtomBinder.removeItem(a, 4);
            Assert_1.default.equals(1, a.length);
            AtomBinder_1.AtomBinder.removeItem(a, 1);
            Assert_1.default.equals(0, a.length);
            AtomBinder_1.AtomBinder.removeItem(a, 4);
        };
        AtomBinderTest.prototype.atomList = function () {
            var a = new AtomList_1.AtomList();
            var modified = false;
            var d = a.watch(function () {
                modified = true;
            });
            a.add(1);
            Assert_1.default.isTrue(modified);
            modified = false;
            a.clear();
            Assert_1.default.isTrue(modified);
            a.add(4);
            a.add(5);
            modified = false;
            a.remove(5);
            Assert_1.default.isTrue(modified);
            d.dispose();
        };
        AtomBinderTest.prototype.plainObject = function () {
            var c = {
                firstName: "Akash",
                lastName: "Kava"
            };
            var bindable = c;
            var ba = bindable._$_bindable;
            Assert_1.default.isTrue(!ba);
            var w = new AtomWatcher_1.AtomWatcher(c, [["firstName"], ["lastName"]], function (firstName, lastName) {
                c.name = firstName + " " + lastName;
            });
            w.init(true);
            Assert_1.default.equals("Akash Kava", c.name);
            ba = bindable._$_bindable;
            Assert_1.default.isTrue(ba ? true : false);
            var i = ba.firstName;
            Assert_1.default.equals(1, i);
            c.firstName = "Simmi";
            Assert_1.default.equals("Simmi Kava", c.name);
        };
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], AtomBinderTest.prototype, "refreshValue", null);
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], AtomBinderTest.prototype, "emptyReturns", null);
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], AtomBinderTest.prototype, "nullExceptions", null);
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], AtomBinderTest.prototype, "clear", null);
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], AtomBinderTest.prototype, "atomList", null);
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], AtomBinderTest.prototype, "plainObject", null);
        return AtomBinderTest;
    }(AtomTest_1.AtomTest));
    exports.AtomBinderTest = AtomBinderTest;
});
//# sourceMappingURL=AtomBinderTest.js.map