-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
847 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { fireEvent, render, screen } from '@testing-library/react'; | ||
import { BackdropDialog, Button } from '@monkvision/common-ui-web'; | ||
import { PhotoCaptureHUDTutorial, PhotoCaptureHUDTutorialProps } from '../../../src'; | ||
import { expectPropsOnChildMock } from '@monkvision/test-utils'; | ||
import { TutorialViews } from '../../../src/PhotoCapture/hooks'; | ||
|
||
const BACKDROP_TEST_ID = 'backdrop'; | ||
const translationPrefix = 'photo.hud.tutorial'; | ||
|
||
function createProps(): PhotoCaptureHUDTutorialProps { | ||
return { | ||
tutorialView: TutorialViews.WELCOME, | ||
onTutorialNext: jest.fn(), | ||
allowSkipTutorial: false, | ||
enableSightGuidelines: true, | ||
enableSightTutorial: true, | ||
sightGuidelines: [], | ||
sightId: 'test-sight-id', | ||
}; | ||
} | ||
|
||
describe('PhotoCaptureHUDTutorial component', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should not be shown if tutorialView is null', () => { | ||
const props = createProps(); | ||
render(<PhotoCaptureHUDTutorial {...props} tutorialView={null} />); | ||
|
||
expect(screen.queryByTestId(BACKDROP_TEST_ID)).toBeNull(); | ||
}); | ||
|
||
it('should be shown if tutorialView is set', () => { | ||
const props = createProps(); | ||
render(<PhotoCaptureHUDTutorial {...props} />); | ||
|
||
expect(screen.queryByTestId(BACKDROP_TEST_ID)).toBeNull(); | ||
}); | ||
|
||
it('handles the next button click correctly', () => { | ||
const props = createProps(); | ||
render(<PhotoCaptureHUDTutorial {...props} />); | ||
|
||
const buttonProps = (Button as unknown as jest.Mock).mock.calls[1][0]; | ||
buttonProps.onClick(); | ||
expect(props.onTutorialNext).toHaveBeenCalledWith(TutorialViews.GUIDELINE); | ||
}); | ||
|
||
it('should render with the correct props when tutorialView is null', () => { | ||
const props = createProps(); | ||
const { unmount } = render(<PhotoCaptureHUDTutorial {...props} />); | ||
|
||
expect(Button).toBeCalled(); | ||
|
||
unmount(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.