|
9 | 9 | wordSet, |
10 | 10 | Train, |
11 | 11 | Predict, |
12 | | - Pond |
| 12 | + Pond, |
| 13 | + Guide |
13 | 14 | } from '@ml/oceans/ui'; |
14 | 15 | import guide from '@ml/oceans/models/guide'; |
15 | 16 | import soundLibrary from '@ml/oceans/models/soundLibrary'; |
@@ -605,3 +606,47 @@ describe('Pond', () => { |
605 | 606 | }); |
606 | 607 | }); |
607 | 608 | }); |
| 609 | + |
| 610 | +describe('Guide', () => { |
| 611 | + let clock, currentGuideStub, playSoundStub; |
| 612 | + |
| 613 | + beforeEach(() => { |
| 614 | + clock = sinon.useFakeTimers(); |
| 615 | + currentGuideStub = sinon.stub(guide, 'getCurrentGuide'); |
| 616 | + currentGuideStub.returns({ |
| 617 | + id: 'guide-id', |
| 618 | + style: '', |
| 619 | + heading: 'hey, listen!', |
| 620 | + text: 'this is an important message' |
| 621 | + }); |
| 622 | + playSoundStub = sinon.stub(soundLibrary, 'playSound'); |
| 623 | + }); |
| 624 | + |
| 625 | + afterEach(() => { |
| 626 | + clock.restore(); |
| 627 | + guide.getCurrentGuide.restore(); |
| 628 | + soundLibrary.playSound.restore(); |
| 629 | + }); |
| 630 | + |
| 631 | + it('sets guideTypingTimer if not already started', () => { |
| 632 | + setState({guideShowing: false, guideTypingTimer: null}); |
| 633 | + const wrapper = shallow(<Guide {...DEFAULT_PROPS} />); |
| 634 | + |
| 635 | + expect(getState().guideTypingTimer).not.toBeNull(); |
| 636 | + }); |
| 637 | + |
| 638 | + it('is dismissable', () => { |
| 639 | + const dismissCurrentGuideStub = sinon |
| 640 | + .stub(guide, 'dismissCurrentGuide') |
| 641 | + .returns(true); |
| 642 | + const wrapper = shallow(<Guide {...DEFAULT_PROPS} />); |
| 643 | + const dismissHandler = wrapper.find('#uitest-dismiss-guide'); |
| 644 | + |
| 645 | + dismissHandler.simulate('click'); |
| 646 | + |
| 647 | + expect(dismissCurrentGuideStub.callCount).toEqual(1); |
| 648 | + expect(playSoundStub.withArgs('other').callCount).toEqual(1); |
| 649 | + |
| 650 | + guide.dismissCurrentGuide.restore(); |
| 651 | + }); |
| 652 | +}); |
0 commit comments