Skip to content

Commit

Permalink
test(shape): Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaiklor committed Feb 26, 2016
1 parent 278ba56 commit 8fb59ac
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions test/unit/Shape.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Shape', () => {
assert.instanceOf(shape.setHeight(15), Shape);
assert.equal(shape.getHeight(), 15);
assert.instanceOf(shape.setHeight('50%'), Shape);
assert.equal(shape.getHeight(), Math.ceil(process.stdout.rows / 2));
assert.equal(shape.getHeight(), Math.floor(process.stdout.rows / 2));
});

it('Should properly get/set x coordinate', () => {
Expand All @@ -61,13 +61,13 @@ describe('Shape', () => {
assert.instanceOf(shape.setX(20), Shape);
assert.equal(shape.getX(), 20);
assert.instanceOf(shape.setX('left'), Shape);
assert.equal(shape.getX(), 1);
assert.equal(shape.getX(), 0);
assert.instanceOf(shape.setX('center'), Shape);
assert.equal(shape.getX(), Math.ceil(process.stdout.columns / 2 - shape.getWidth() / 2) + 1);
assert.equal(shape.getX(), Math.floor(process.stdout.columns / 2 - shape.getWidth() / 2));
assert.instanceOf(shape.setX('right'), Shape);
assert.equal(shape.getX(), Math.ceil(process.stdout.columns - shape.getWidth()) + 1);
assert.equal(shape.getX(), Math.floor(process.stdout.columns - shape.getWidth()));
assert.instanceOf(shape.setX('50%'), Shape);
assert.equal(shape.getX(), Math.ceil(process.stdout.columns / 2) + 1);
assert.equal(shape.getX(), Math.floor(process.stdout.columns / 2));
});

it('Should properly get/set y coordinate', () => {
Expand All @@ -77,13 +77,13 @@ describe('Shape', () => {
assert.instanceOf(shape.setY(20), Shape);
assert.equal(shape.getY(), 20);
assert.instanceOf(shape.setY('top'), Shape);
assert.equal(shape.getY(), 1);
assert.equal(shape.getY(), 0);
assert.instanceOf(shape.setY('middle'), Shape);
assert.equal(shape.getY(), Math.ceil(process.stdout.rows / 2 - shape.getHeight() / 2) + 1);
assert.equal(shape.getY(), Math.floor(process.stdout.rows / 2 - shape.getHeight() / 2));
assert.instanceOf(shape.setY('bottom'), Shape);
assert.equal(shape.getY(), Math.ceil(process.stdout.rows - shape.getHeight()) + 1);
assert.equal(shape.getY(), Math.floor(process.stdout.rows - shape.getHeight()));
assert.instanceOf(shape.setY('50%'), Shape);
assert.equal(shape.getY(), Math.ceil(process.stdout.rows / 2) + 1);
assert.equal(shape.getY(), Math.floor(process.stdout.rows / 2));
});

it('Should properly get/set background', () => {
Expand Down Expand Up @@ -120,8 +120,8 @@ describe('Shape', () => {
height: 5,
x: 10,
y: 10,
background: undefined,
foreground: undefined
background: false,
foreground: false
}
});
});
Expand All @@ -148,14 +148,14 @@ describe('Shape', () => {
const shape = new Shape();
const json = shape.toJSON();

assert.equal(json, '{"type":"Shape","options":{"text":"","width":15,"height":5,"x":10,"y":10}}');
assert.equal(json, '{"type":"Shape","options":{"text":"","width":15,"height":5,"x":10,"y":10,"background":false,"foreground":false}}');
});

it('Should properly serialize shape to JSON with custom options', () => {
const shape = new Shape({text: 'test', x: 0, y: 0, width: 30, height: 50});
const json = shape.toJSON();

assert.equal(json, '{"type":"Shape","options":{"text":"test","width":30,"height":50,"x":0,"y":0}}');
assert.equal(json, '{"type":"Shape","options":{"text":"test","width":30,"height":50,"x":0,"y":0,"background":false,"foreground":false}}');
});

it('Should properly create Shape instance from static create()', () => {
Expand Down Expand Up @@ -213,7 +213,7 @@ describe('Shape', () => {
assert.equal(shape.getHeight(), 50);
assert.equal(shape.getX(), 1);
assert.equal(shape.getY(), 1);
assert.isUndefined(shape.getBackground());
assert.isUndefined(shape.getForeground());
assert.notOk(shape.getBackground());
assert.notOk(shape.getForeground());
});
});

0 comments on commit 8fb59ac

Please sign in to comment.