'use strict';

import { expect } from 'chai';
import sinon from 'sinon';
import _ from 'lodash';
import bind from '../../src/bind/bind';
import { after } from '../../src';

// This is currently broken :(
describe.skip('bind', () => {
  let spy, spy2, person, actual, sandbox = sinon.sandbox.create();

  beforeEach(() => {
    spy = sandbox.spy();
    spy2 = sandbox.spy();

    class Person {
      constructor() {}

      @bind()
      @after(2)
      fn() {
        spy(this);
      }

      @after(2)
      @bind()
      fn2() {
        spy2(this);
      }
    }

    person = new Person();
  });

  afterEach(() => {
    sandbox.restore();
  });

  describe('when bind is first in the chain', () => {
    it('should call the function in the correct context', () => {
      person.fn.call(null);
      person.fn.call(null);
      person.fn.call(null);
      expect(spy).to.have.been.calledWith(person);
      expect(spy).to.have.been.calledOnce;
    });

    it('should not call the function', () => {
      person.fn.call(null);
      expect(spy).not.to.have.been.calledWith(person);
    });
  });

  describe('when bind is last in the chain', () => {
    it('should call the function in the correct context', () => {
      person.fn2.call(null);
      person.fn2.call(null);
      person.fn2.call(null);
      expect(spy2).to.have.been.calledWith(person);
      expect(spy2).to.have.been.calledOnce;
    });

    it('should not call the function', () => {
      person.fn2.call(null);
      expect(spy2).not.to.have.been.calledWith(person);
    });
  });
});

@@ -243,16 +243,22 @@
 y, spy2,
+ spy3,
  person,
@@ -300,16 +300,16 @@
 eate();%0A
-
 %0A  befor
@@ -372,16 +372,42 @@
 x.spy();
+%0A    spy3 = sandbox.spy();
 %0A%0A    cl
@@ -554,24 +554,24 @@
     fn2() %7B%0A
-
         spy2
@@ -585,16 +585,89 @@
 %0A      %7D
+%0A%0A      @bind('John')%0A      fn3(name) %7B%0A        spy3(this, name);%0A      %7D
 %0A    %7D%0A%0A
@@ -1658,13 +1658,242 @@
 );%0A  %7D);
+%0A%0A  describe('when bind is used with an argument', () =%3E %7B%0A    it('should call the function with the correct argument', () =%3E %7B%0A      person.fn3.call(null);%0A      expect(spy3).to.have.been.calledWith(person, 'John');%0A    %7D);%0A  %7D)
 %0A%7D);%0A

Add test (although skipped so far)