@@ -23,8 +23,8 @@ import arrowDownImage from '@public/images/arrow-down.png';
2323import snail from '@public/images/snail-large.png' ;
2424import loadingGif from '@public/images/loading.gif' ;
2525import Typist from 'react-typist' ;
26- import { getCurrentGuide , dismissCurrentGuide } from './models/guide' ;
27- import { playSound } from './models/soundLibrary' ;
26+ import * as guide from './models/guide' ;
27+ import * as soundLibrary from './models/soundLibrary' ;
2828import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
2929import {
3030 faPlay ,
@@ -662,7 +662,7 @@ class Content extends React.Component {
662662 }
663663}
664664
665- let Button = class Button extends React . Component {
665+ let UnwrappedButton = class Button extends React . Component {
666666 static propTypes = {
667667 className : PropTypes . string ,
668668 style : PropTypes . object ,
@@ -671,33 +671,30 @@ let Button = class Button extends React.Component {
671671 sound : PropTypes . string
672672 } ;
673673
674- onClick ( event ) {
675- dismissCurrentGuide ( ) ;
674+ onClick = event => {
675+ guide . dismissCurrentGuide ( ) ;
676676 const clickReturnValue = this . props . onClick ( event ) ;
677677
678678 if ( clickReturnValue !== false ) {
679- if ( this . props . sound && clickReturnValue !== false ) {
680- playSound ( this . props . sound ) ;
681- } else {
682- playSound ( 'other' ) ;
683- }
679+ const sound = this . props . sound || 'other' ;
680+ soundLibrary . playSound ( sound ) ;
684681 }
685- }
682+ } ;
686683
687684 render ( ) {
688685 return (
689686 < button
690687 type = "button"
691688 className = { this . props . className }
692689 style = { [ styles . button , this . props . style ] }
693- onClick = { event => this . onClick ( event ) }
690+ onClick = { this . onClick }
694691 >
695692 { this . props . children }
696693 </ button >
697694 ) ;
698695 }
699696} ;
700- Button = Radium ( Button ) ;
697+ export const Button = Radium ( UnwrappedButton ) ; // Exported for unit tests.
701698
702699let ConfirmationDialog = class ConfirmationDialog extends React . Component {
703700 static propTypes = {
@@ -1251,11 +1248,11 @@ let Pond = class Pond extends React.Component {
12511248 if ( state . showRecallFish ) {
12521249 currentFishSet = state . recallFish ;
12531250 nextFishSet = state . pondFish ;
1254- playSound ( 'yes' ) ;
1251+ soundLibrary . playSound ( 'yes' ) ;
12551252 } else {
12561253 currentFishSet = state . pondFish ;
12571254 nextFishSet = state . recallFish ;
1258- playSound ( 'no' ) ;
1255+ soundLibrary . playSound ( 'no' ) ;
12591256 }
12601257
12611258 // Don't call arrangeFish if fish have already been arranged.
@@ -1275,7 +1272,7 @@ let Pond = class Pond extends React.Component {
12751272
12761273 onPondClick = e => {
12771274 // Don't allow pond clicks if a Guide is currently showing.
1278- if ( getCurrentGuide ( ) ) {
1275+ if ( guide . getCurrentGuide ( ) ) {
12791276 return ;
12801277 }
12811278
@@ -1328,7 +1325,7 @@ let Pond = class Pond extends React.Component {
13281325 }
13291326 } ) ;
13301327 fishClicked = true ;
1331- playSound ( 'yes' ) ;
1328+ soundLibrary . playSound ( 'yes' ) ;
13321329
13331330 if (
13341331 state . appMode === AppMode . FishShort ||
@@ -1351,7 +1348,7 @@ let Pond = class Pond extends React.Component {
13511348
13521349 if ( ! fishClicked ) {
13531350 setState ( { pondClickedFish : null } ) ;
1354- playSound ( 'no' ) ;
1351+ soundLibrary . playSound ( 'no' ) ;
13551352 }
13561353 }
13571354 } ;
@@ -1368,9 +1365,9 @@ let Pond = class Pond extends React.Component {
13681365 } ) ;
13691366
13701367 if ( state . pondPanelShowing ) {
1371- playSound ( 'sortno' ) ;
1368+ soundLibrary . playSound ( 'sortno' ) ;
13721369 } else {
1373- playSound ( 'sortyes' ) ;
1370+ soundLibrary . playSound ( 'sortyes' ) ;
13741371 }
13751372 }
13761373
@@ -1480,15 +1477,15 @@ let Guide = class Guide extends React.Component {
14801477 }
14811478
14821479 dismissGuideClick ( ) {
1483- const dismissed = dismissCurrentGuide ( ) ;
1480+ const dismissed = guide . dismissCurrentGuide ( ) ;
14841481 if ( dismissed ) {
1485- playSound ( 'other' ) ;
1482+ soundLibrary . playSound ( 'other' ) ;
14861483 }
14871484 }
14881485
14891486 render ( ) {
14901487 const state = getState ( ) ;
1491- const currentGuide = getCurrentGuide ( ) ;
1488+ const currentGuide = guide . getCurrentGuide ( ) ;
14921489
14931490 let guideBgStyle = [ styles . guideBackground ] ;
14941491 if ( currentGuide ) {
@@ -1505,7 +1502,7 @@ let Guide = class Guide extends React.Component {
15051502 // Start playing the typing sounds.
15061503 if ( ! state . guideShowing && ! state . guideTypingTimer && currentGuide ) {
15071504 const guideTypingTimer = setInterval ( ( ) => {
1508- playSound ( 'no' , 0.5 ) ;
1505+ soundLibrary . playSound ( 'no' , 0.5 ) ;
15091506 } , 1000 / 10 ) ;
15101507 setState ( { guideTypingTimer} ) ;
15111508 }
0 commit comments