var quiddity = require("../quiddity.js"),
    expect = require("expect.js");

describe("quiddity", function() {
    it("should decorate an object and return it", function() {
        var obj = {};
        expect(quiddity(obj)).to.be(obj);
        expect(obj.create).to.be.a("function");
        expect(obj.init).to.be.a("function");
    });

    it("should reject invalid arguments", function() {
        expect(quiddity).withArgs(21120).to.throwError(new Error());
        expect(quiddity).withArgs("foo").to.throwError(new Error());
        expect(quiddity).withArgs([2,3]).to.throwError(new Error());
    });

    describe("create", function() {
        it("should return a derivation of current prototype", function() {
            var obj = quiddity({}),
                derivation = obj.create();
            expect(obj.isPrototypeOf(derivation));
        });

        it("should call prototype init", function() {
            var init = function() {this.foo = 42;},
                obj = quiddity({}, init);

            expect(obj.foo).to.be(undefined);
            expect(obj.create().foo).to.be(42);
        });
    });
});

@@ -1114,16 +1114,387 @@
      %7D);
+%0A%0A        it(%22should be able to chain inits together%22, function() %7B%0A            var fnA = function() %7Bthis.value += %22A%22;%7D,%0A                fnB = function() %7Bthis.value += %22B%22;%7D,%0A                fnC = function() %7Bthis.value += %22C%22;%7D,%0A                obj = quiddity(%7Bvalue:%22%22%7D, fnA);%0A%0A            expect(obj.create(fnB).create(fnC).create().value).to.be(%22ABC%22);%0A        %7D);
 %0A    %7D);

test init chaining