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", "../../core/AtomList", "@web-atoms/unit-test/dist/Assert", "@web-atoms/unit-test/dist/Test", "@web-atoms/unit-test/dist/TestItem"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var AtomList_1 = require("../../core/AtomList");
    var Assert_1 = require("@web-atoms/unit-test/dist/Assert");
    var Test_1 = require("@web-atoms/unit-test/dist/Test");
    var TestItem_1 = require("@web-atoms/unit-test/dist/TestItem");
    var AtomListTest = /** @class */ (function (_super) {
        __extends(AtomListTest, _super);
        function AtomListTest() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        AtomListTest.prototype.remove = function () {
            var list = new AtomList_1.AtomList();
            Assert_1.default.isFalse(list.remove(4));
            Assert_1.default.isFalse(list.remove(function (item) { return 5; }));
            list.addAll([1, 2]);
            Assert_1.default.isFalse(list.remove(4));
            Assert_1.default.isFalse(list.remove(function (item) { return item === 5; }));
            Assert_1.default.isTrue(list.remove(1));
            Assert_1.default.isTrue(list.remove(function (item) { return item === 2; }));
            Assert_1.default.isEmpty(list.length);
        };
        AtomListTest.prototype.removeMultiple = function () {
            var list = [1, 2, 3, 4, 5];
            // remove all even numbers...
            list.remove(function (x) { return (x % 2) === 0; });
            Assert_1.default.equals(3, list.length);
        };
        AtomListTest.prototype.insert = function () {
            var list = new AtomList_1.AtomList();
            list.addAll([1, 2]);
            list.insert(1, 5);
            Assert_1.default.equals(5, list[1]);
        };
        AtomListTest.prototype.wrap = function () {
            var list = [1, 2];
            var d = list.watch(function (x) {
                var a = x;
                Assert_1.default.isTrue(typeof a[1] === "string");
            }, true);
            list.add(1);
        };
        AtomListTest.prototype.replace = function () {
            var list = new AtomList_1.AtomList();
            list.add(2);
            var r = [1, 2];
            list.replace(r);
            Assert_1.default.equals(2, r.length);
        };
        AtomListTest.prototype.replacePaging = function () {
            var list = new AtomList_1.AtomList();
            var r = [1, 2];
            r.total = 10;
            list.addAll(r);
            var a = [4, 5];
            a.total = 10;
            list.replace(a, 2, 2);
            Assert_1.default.equals(2, list.start);
            Assert_1.default.equals(2, list.size);
            Assert_1.default.equals(10, list.total);
            list.next();
            Assert_1.default.equals(4, list.start);
            list.prev();
            Assert_1.default.equals(2, list.start);
            list.prev();
            Assert_1.default.equals(0, list.start);
            list.prev();
            Assert_1.default.equals(0, list.start);
            list.start = 0;
            list.size = 2;
        };
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], AtomListTest.prototype, "remove", null);
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], AtomListTest.prototype, "removeMultiple", null);
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], AtomListTest.prototype, "insert", null);
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], AtomListTest.prototype, "wrap", null);
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], AtomListTest.prototype, "replace", null);
        __decorate([
            Test_1.default,
            __metadata("design:type", Function),
            __metadata("design:paramtypes", []),
            __metadata("design:returntype", void 0)
        ], AtomListTest.prototype, "replacePaging", null);
        return AtomListTest;
    }(TestItem_1.default));
    exports.AtomListTest = AtomListTest;
});
//# sourceMappingURL=AtomListTests.js.map