'use strict';

import mixin, { proceed } from '../src/mixin.js';

describe('Mixin Adapter', () => {

    it('basic adapter', () => {
        let obj = {
            value: 17,
            getValue: function() {
                return this.value;
            }
        };

        let dynamicMixin = mixin().refineObject(obj, {
            getValue: function() {
                return 42 + proceed();
            }
        });

        expect(obj.getValue()).to.equal(17);

        dynamicMixin.activate();

        expect(obj.getValue()).to.equal(42 + 17);

        dynamicMixin.deactivate();

        expect(obj.getValue()).to.equal(17);
    });

    it('overlapping mixins', () => {
        let obj1 = { getValue: () => 1 },
            obj2 = { getValue: () => 2 },
            obj3 = { getValue: () => 3 },
            mixin1 = mixin()
                .refineObject(obj1, { getValue: function() { return 10 + proceed(); }})
                .refineObject(obj2, { getValue: function() { return 10 + proceed(); }})
                .activate(),
            mixin2 = mixin()
                .refineObject(obj2, { getValue: function() { return 20 + proceed(); }})
                .refineObject(obj3, { getValue: function() { return 20 + proceed(); }})
                .activate();

        expect(obj1.getValue()).to.equal(1 + 10);
        expect(obj2.getValue()).to.equal(2 + 10 + 20);
        expect(obj3.getValue()).to.equal(3      + 20);

        mixin2.deactivate();

        expect(obj1.getValue()).to.equal(1 + 10);
        expect(obj2.getValue()).to.equal(2 + 10);
        expect(obj3.getValue()).to.equal(3);
    });

    xit('instance-specific layer activation', () => {});
});

@@ -1615,24 +1615,779 @@
 );%0A    %7D);%0A%0A
+    it('refining static methods', () =%3E %7B%0A        class ClassToRefine %7B%0A            static get value() %7B%0A                return 17;%0A            %7D%0A            static primitiveGetter() %7B%0A                return this.value;%0A            %7D%0A            static getValue() %7B%0A                return this.primitiveGetter();%0A            %7D%0A        %7D%0A%0A        let dynamicMixin = mixin().refineObject(ClassToRefine, %7B%0A            getValue: function() %7B%0A                return 42 + proceed();%0A            %7D%0A        %7D);%0A%0A        expect(ClassToRefine.getValue()).to.equal(17);%0A%0A        dynamicMixin.activate();%0A%0A        expect(ClassToRefine.getValue()).to.equal(42 + 17);%0A%0A        dynamicMixin.deactivate();%0A%0A        expect(ClassToRefine.getValue()).to.equal(17);%0A    %7D);%0A%0A
     xit('ins

test for static methods