Skip to content

Commit

Permalink
play ballon sound when popping
Browse files Browse the repository at this point in the history
  • Loading branch information
kriswep committed Apr 23, 2017
1 parent 706528f commit 8266166
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/wtballoon.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

import sound from './sound';

export default function wtBalloon(balloonNumber, x, y, speed, WTGM) {
this.balloonNumber = balloonNumber;
this.verticalOffset = 0;
Expand Down Expand Up @@ -99,6 +102,7 @@ export default function wtBalloon(balloonNumber, x, y, speed, WTGM) {
return false;
}
if (xP > this.x && xP < this.x + this.width && yP > this.y && yP < this.y + this.height) {
sound.playPlop();
return true;
}
return false;
Expand Down
8 changes: 8 additions & 0 deletions src/wtballoon.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/* globals test jest expect */
import WtBalloon from './wtballoon';
import sound from './sound';

jest.mock('./sound', () =>
({
playPlop: jest.fn(),
}),
);

const getUpdatedProps = (obj, prop) => {
obj.update();
Expand Down Expand Up @@ -191,6 +198,7 @@ test('WtBalloon isInside should check if point is inside balloon', () => {
const balloon = new WtBalloon(0, 700, 500, 5, WTGM);
expect(balloon.isInside(0, 0)).toBeFalsy();
expect(balloon.isInside(701, 501)).toBeTruthy();
expect(sound.playPlop).toHaveBeenCalled();
balloon.remove = 1;
expect(balloon.isInside(701, 501)).toBeFalsy();
});

0 comments on commit 8266166

Please sign in to comment.