-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Snapshot update
- Loading branch information
Showing
6 changed files
with
159 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, {useState} from "react"; | ||
import {Button, Modal} from "reactstrap"; | ||
import * as ReactDOM from "react-dom"; | ||
import {MODAL_ROOT_ELEMENT} from "../../../../utils/Constants"; | ||
import * as PropTypes from "prop-types"; | ||
import ErrorBoundary from "../../../../ErrorHandling/ErrorBoundary"; | ||
|
||
function AudioPlayer({playbackURL, MimeType}) { | ||
|
||
const [preview, setPreview] = useState(true); | ||
|
||
function hideFull(e) { | ||
e.stopPropagation(); | ||
setPreview(!preview); | ||
|
||
} | ||
|
||
let element; | ||
if (preview) { | ||
element = ( | ||
<div className="img-thumbnail w-100 text-center" data-test="audioPlayerWidget"> | ||
<Button color="link" onClick={hideFull}> | ||
{/*<i className="fa fa-play-circle fa-4x"/>*/} | ||
<audio controls> | ||
<source src={playbackURL} type={MimeType}/> | ||
Your browser does not support the audio tag. | ||
</audio> | ||
</Button> | ||
</div> | ||
) | ||
} else { | ||
|
||
// Load the video | ||
|
||
|
||
element = ReactDOM.createPortal(( | ||
<Modal className="task-modal d-none d-sm-block" data-test="videoPlayerWidget" isOpen={!preview} | ||
toggle={hideFull}> | ||
|
||
|
||
<audio controls> | ||
<source src={playbackURL} type={MimeType}/> | ||
Your browser does not support the audio tag. | ||
</audio> | ||
|
||
</Modal> | ||
), document.getElementById(MODAL_ROOT_ELEMENT)); | ||
} | ||
|
||
return ( | ||
<ErrorBoundary> | ||
{element} | ||
</ErrorBoundary> | ||
) | ||
|
||
|
||
} | ||
|
||
AudioPlayer.propTypes = { | ||
playbackURL: PropTypes.string.isRequired, | ||
MimeType: PropTypes.string.isRequired | ||
}; | ||
|
||
export default AudioPlayer; |
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,41 @@ | ||
import React from "react"; | ||
import {shallow} from "enzyme"; | ||
import {findByTestAttr, testStore} from "../../../../../Utils"; | ||
import toJson from "enzyme-to-json"; | ||
import AudioPlayer from "./AudioPlayer"; | ||
|
||
const setUp = (intialState = {}, props = {}) => { | ||
const store = testStore(intialState); | ||
const component = shallow(<AudioPlayer {...props} store={store}/>); | ||
return component; | ||
}; | ||
|
||
|
||
describe('Audio Player Widget', function () { | ||
|
||
|
||
describe('renders', function () { | ||
let wrapper; | ||
beforeEach(() => { | ||
const initialState = {}; | ||
|
||
|
||
const props = { | ||
playbackURL: '', | ||
MimeType: '' | ||
}; | ||
wrapper = setUp(initialState, props) | ||
}); | ||
|
||
it('should render without crashing', function () { | ||
const component = findByTestAttr(wrapper, "audioPlayerWidget"); | ||
expect(component).toHaveLength(1); | ||
}); | ||
|
||
it('should match snapshot', function () { | ||
expect(toJson(wrapper)).toMatchSnapshot() | ||
}); | ||
|
||
}); | ||
|
||
}); |
26 changes: 26 additions & 0 deletions
26
src/views/Base/Widgets/AudioPlayer/__snapshots__/AudioPlayer.test.js.snap
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,26 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Audio Player Widget renders should match snapshot 1`] = ` | ||
<ErrorBoundary> | ||
<div | ||
className="img-thumbnail w-100 text-center" | ||
data-test="audioPlayerWidget" | ||
> | ||
<Button | ||
color="link" | ||
onClick={[Function]} | ||
tag="button" | ||
> | ||
<audio | ||
controls={true} | ||
> | ||
<source | ||
src="" | ||
type="" | ||
/> | ||
Your browser does not support the audio tag. | ||
</audio> | ||
</Button> | ||
</div> | ||
</ErrorBoundary> | ||
`; |
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