Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
straker committed Jun 29, 2020
1 parent 7623eef commit c56f34a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -16,4 +16,4 @@ deploy:
keep_history: true
local_dir: docs
# on:
# branch: master
# branch: main
30 changes: 29 additions & 1 deletion src/gameObject.js
Expand Up @@ -360,6 +360,34 @@ class GameObject {
set viewY(value) {
return;
}

// ifdef GAMEOBJECT_GROUP
get sx() {
return this._sx;
}

get sy() {
return this._sy;
}

set sx(value) {
let diff = value - this._sx;
this.children.map(child => {
child.sx += diff;
});

this._sx = value;
}

set sy(value) {
let diff = value - this._sy;
this.children.map(child => {
child.sy += diff;
});

this._sy = value;
}
// @endif
// @endif

// @ifdef GAMEOBJECT_TTL
Expand Down Expand Up @@ -401,7 +429,7 @@ class GameObject {
* @function addChild
*
* @param {GameObject} child - Object to add as a child.
* @param {Object} options - Options for adding the child.
* @param {Object} [options] - Options for adding the child.
* @param {Boolean} [options.absolute=false] - If set the true, the x/y position of the child is treated as an absolute position in the world rather than being relative to the x/y position of the parent.
*
* @example
Expand Down
25 changes: 15 additions & 10 deletions test/unit/button.spec.js
Expand Up @@ -16,7 +16,9 @@ describe('button', () => {
let button;
beforeEach(() => {
button = Button({
text: 'Hello'
text: {
text: 'Hello'
}
});
});

Expand All @@ -31,17 +33,20 @@ describe('button', () => {

it('should setup basic properties', () => {
button = Button({
text: 'Hello',
font: '32px Arial',
width: 100,
color: 'black'
text: {
text: 'Hello',
font: '32px Arial',
width: 100,
color: 'black'
}
});

expect(button.width).to.equal(100);
expect(button.height).to.equal(32);
expect(button.font).to.equal('32px Arial');
expect(button.text).to.equal('Hello');
expect(button.color).to.equal('black');
expect(button.textNode).to.exist;
expect(button.textNode.width).to.equal(100);
expect(button.textNode.height).to.equal(32);
expect(button.textNode.font).to.equal('32px Arial');
expect(button.textNode.text).to.equal('Hello');
expect(button.textNode.color).to.equal('black');
});

it('should create a DOM node and add it to the page', () => {
Expand Down

0 comments on commit c56f34a

Please sign in to comment.