|
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'; |
@@ -626,3 +627,47 @@ describe('Pond', () => { |
626 | 627 | }); |
627 | 628 | }); |
628 | 629 | }); |
| 630 | + |
| 631 | +describe('Guide', () => { |
| 632 | + let clock, currentGuideStub, playSoundStub; |
| 633 | + |
| 634 | + beforeEach(() => { |
| 635 | + clock = sinon.useFakeTimers(); |
| 636 | + currentGuideStub = sinon.stub(guide, 'getCurrentGuide'); |
| 637 | + currentGuideStub.returns({ |
| 638 | + id: 'guide-id', |
| 639 | + style: '', |
| 640 | + heading: 'hey, listen!', |
| 641 | + text: 'this is an important message' |
| 642 | + }); |
| 643 | + playSoundStub = sinon.stub(soundLibrary, 'playSound'); |
| 644 | + }); |
| 645 | + |
| 646 | + afterEach(() => { |
| 647 | + clock.restore(); |
| 648 | + guide.getCurrentGuide.restore(); |
| 649 | + soundLibrary.playSound.restore(); |
| 650 | + }); |
| 651 | + |
| 652 | + it('sets guideTypingTimer if not already started', () => { |
| 653 | + setState({guideShowing: false, guideTypingTimer: null}); |
| 654 | + const wrapper = shallow(<Guide {...DEFAULT_PROPS} />); |
| 655 | + |
| 656 | + expect(getState().guideTypingTimer).not.toBeNull(); |
| 657 | + }); |
| 658 | + |
| 659 | + it('is dismissable', () => { |
| 660 | + const dismissCurrentGuideStub = sinon |
| 661 | + .stub(guide, 'dismissCurrentGuide') |
| 662 | + .returns(true); |
| 663 | + const wrapper = shallow(<Guide {...DEFAULT_PROPS} />); |
| 664 | + const dismissHandler = wrapper.find('#uitest-dismiss-guide'); |
| 665 | + |
| 666 | + dismissHandler.simulate('click'); |
| 667 | + |
| 668 | + expect(dismissCurrentGuideStub.callCount).toEqual(1); |
| 669 | + expect(playSoundStub.withArgs('other').callCount).toEqual(1); |
| 670 | + |
| 671 | + guide.dismissCurrentGuide.restore(); |
| 672 | + }); |
| 673 | +}); |
0 commit comments