/*
 * Copyright (c) 2017. tom@axisj.com
 * - github.com/thomasjang
 * - www.axisj.com
 */

describe('ax5binder TEST', function () {
    var myUI;

    var tmpl = '<form class name="binder-form" onsubmit="return false;" style="border: 1px solid #ccc;padding: 10px;border-radius: 10px;">' +
        '<div class="form-group">' +
        '<label>Email address</label>' +
        '<input type="email" class="form-control" data-ax-path="email">' +
        '</div>' +
        '<div class="form-group">' +
        '<label>Password</label>' +
        '<input type="password" class="form-control" data-ax-path="password"></div>' +
        '<div class="form-group">' +
        '<label>Select</label>' +
        '<select class="form-control" data-ax-path="select"><option value></option><option value="A">A</option><option value="B">B</option></select></div>' +
        '<div class="checkbox"><label><input type="checkbox" data-ax-path="useYn" value="Y">Y/N</label></div>' +
        '<div class="radio"><label><input type="radio" name="radio" data-ax-path="sex" value="M">M</label>' +
        '<label><input type="radio" name="radio" data-ax-path="sex" value="F">F</label>' +
        '</div>' +
        '</form>';

    $(document.body).append(tmpl);


    ///
    it('new ax5binder', function (done) {
        try {
            myUI = new ax5.ui.binder();
            done();
        } catch (e) {
            done(e);
        }
    });

    it('setModel ax5binder', function (done) {
        myUI.setModel({
            email: "tom@axisj.com",
            password: "12345",
            select: "B",
            useYn: "Y",
            sex: "F"
        }, jQuery(document["binder-form"]));

        done(myUI.get("email") == "tom@axisj.com" ? "" : "setModel error");
    });


    it('set[select] ax5binder', function (done) {
        myUI.set("select", "A");
        done(myUI.get("select") == "A" ? "" : "set error");
    });

    it('set[checkbox] ax5binder', function (done) {
        myUI.set("useYn", "N");
        done(myUI.get("useYn") == "N" ? "" : "set error");
    });

    it('set[radio] ax5binder', function (done) {
        myUI.set("sex", "M");
        done(myUI.get("sex") == "M" ? "" : "set error");
    });


    it('onchange input value ax5binder', function (done) {
        jQuery('[data-ax-path="email"]')
            .val("brant")
            .trigger("change");

        done(myUI.get("email") == "brant" ? "" : "onchange input value");
    });

});
@@ -2450,12 +2450,1047 @@
     %7D);%0A
+%7D);%0A%0Adescribe('Operate list item TEST', function()%7B%0A    var myUI;%0A    beforeEach(function()%7B%0A        myUI = new ax5.ui.binder();%0A        myUI.setModel(%7B%0A            %22list%22: %5B%7BA: 1%7D, %7BA: 2%7D%5D%0A        %7D, jQuery(document%5B%22binder-form%22%5D));%0A    %7D);%0A%0A    it('add item ax5binder', function (done) %7B%0A        myUI.add(%22list%22, %7BA: 3%7D);%0A        done(myUI.get(%22list%5B2%5D%5BA%5D%22) === 3 && myUI.get(%22list%5B2%5D%22 + %22__ADDED__%22) === true ? %22%22 : %22add item error%22);%0A    %7D);%0A%0A    it('remove item ax5binder', function (done) %7B%0A        myUI.remove(%22list%22, 1);%0A        done(myUI.get(%22list%5B1%5D%22 + %22__DELETED__%22) === true ? %22%22 : %22remove item error%22);%0A    %7D);%0A%0A    it('remove added item ax5binder', function (done) %7B%0A        myUI.add(%22list%22, %7BA: 3%7D);%0A        myUI.remove(%22list%22, 2);%0A        done(myUI.get(%22list%22).length === 2 && myUI.get(%22list%5B1%5D%5BA%5D%22) === 2 ? %22%22 : %22remove added item error%22);%0A    %7D);%0A%0A    it('update item ax5binder', function (done) %7B%0A        myUI.update(%22list%22, 1, %7BA: 3%7D);%0A        done(myUI.get(%22list%5B1%5D%5BA%5D%22) === 3 ? %22%22 : %22update item error%22);%0A    %7D);
 %0A%7D);

update test code