import { assert } from 'chai';
import sinon from 'sinon';
import Rectangle from '../../src/Rectangle';
import Cursor from 'kittik-cursor';

describe('Shape::Rectangle', () => {
  it('Should properly render with default options', () => {
    const cursor = Cursor.create();
    const rectangle = new Rectangle();
    const mock = sinon.mock(cursor);

    mock.expects('background').never();
    mock.expects('foreground').never();
    mock.expects('moveTo').exactly(8).returns(cursor);
    mock.expects('write').exactly(7).returns(cursor);

    rectangle.render(cursor);

    mock.verify();
  });

  it('Should properly render with custom options', () => {
    const cursor = Cursor.create();
    const mock = sinon.mock(cursor);
    const rectangle = new Rectangle({
      text: 'test',
      width: 11,
      height: 11,
      x: 1,
      y: 1,
      background: 'yellow',
      foreground: 'black'
    });

    mock.expects('background').once().withArgs('yellow');
    mock.expects('foreground').once().withArgs('black');
    mock.expects('moveTo').exactly(14).returns(cursor);
    mock.expects('write').exactly(13).returns(cursor);

    rectangle.render(cursor);

    mock.verify();
  });

  it('Should properly serialize shape to Object representation', () => {
    const rectangle = new Rectangle();
    const obj = rectangle.toObject();

    assert.deepEqual(obj, {
      type: 'Rectangle',
      options: {
        text: '',
        width: 15,
        height: 5,
        x: 10,
        y: 10,
        background: undefined,
        foreground: undefined
      }
    });
  });

  it('Should properly create rectangle from Object representation', () => {
    const obj = {
      type: 'Rectangle',
      options: {
        text: 'test',
        width: 30,
        height: 50,
        x: 1,
        y: 1,
        background: undefined,
        foreground: undefined
      }
    };

    const rectangle = Rectangle.fromObject(obj);
    assert.instanceOf(rectangle, Rectangle);
    assert.equal(rectangle.getText(), 'test');
    assert.equal(rectangle.getWidth(), 30);
    assert.equal(rectangle.getHeight(), 50);
    assert.equal(rectangle.getX(), 1);
    assert.equal(rectangle.getY(), 1);
    assert.isUndefined(rectangle.getBackground());
    assert.isUndefined(rectangle.getForeground());
  });
});

@@ -378,54 +378,126 @@
 d').
-never();%0A    mock.expects('foreground').never(
+once().withExactArgs(false).returns(cursor);%0A    mock.expects('foreground').once().withExactArgs(false).returns(cursor
 );%0A 
@@ -1030,16 +1030,32 @@
 yellow')
+.returns(cursor)
 ;%0A    mo
@@ -1103,16 +1103,32 @@
 'black')
+.returns(cursor)
 ;%0A    mo
@@ -1613,33 +1613,29 @@
 background: 
-undefined
+false
 ,%0A        fo
@@ -1640,33 +1640,29 @@
 foreground: 
-undefined
+false
 %0A      %7D%0A   
@@ -1900,70 +1900,8 @@
 y: 1
-,%0A        background: undefined,%0A        foreground: undefined
 %0A   
@@ -2228,35 +2228,29 @@
 %0A    assert.
-isUndefined
+notOk
 (rectangle.g
@@ -2281,19 +2281,13 @@
 ert.
-isUndefined
+notOk
 (rec

Fix tests