Skip to content
Snippets Groups Projects
Commit a9c747d4 authored by Jack Reed's avatar Jack Reed
Browse files

Fixup A/V tests and actually add captions to audio

parent 59b4e3ea
Branches
Tags
No related merge requests found
...@@ -23,8 +23,8 @@ describe('AudioViewer', () => { ...@@ -23,8 +23,8 @@ describe('AudioViewer', () => {
{ getFormat: () => 'video/mp4', id: 2 }, { getFormat: () => 'video/mp4', id: 2 },
], ],
}, true); }, true);
expect(wrapper.contains(<source src="1" type="video/mp4" />)); expect(wrapper.contains(<source src={1} type="video/mp4" />)).toBe(true);
expect(wrapper.contains(<source src="2" type="video/mp4" />)); expect(wrapper.contains(<source src={2} type="video/mp4" />)).toBe(true);
}); });
it('passes through configurable options', () => { it('passes through configurable options', () => {
wrapper = createWrapper({ wrapper = createWrapper({
...@@ -44,8 +44,8 @@ describe('AudioViewer', () => { ...@@ -44,8 +44,8 @@ describe('AudioViewer', () => {
{ getLabel: () => 'French', getProperty: () => 'fr', id: 2 }, { getLabel: () => 'French', getProperty: () => 'fr', id: 2 },
], ],
}, true); }, true);
expect(wrapper.contains(<track src="1" label="English" srcLang="en" />)); expect(wrapper.contains(<track src={1} label="English" srcLang="en" />)).toBe(true);
expect(wrapper.contains(<track src="2" label="French" srcLang="fr" />)); expect(wrapper.contains(<track src={2} label="French" srcLang="fr" />)).toBe(true);
}); });
}); });
}); });
...@@ -23,8 +23,8 @@ describe('VideoViewer', () => { ...@@ -23,8 +23,8 @@ describe('VideoViewer', () => {
{ getFormat: () => 'video/mp4', id: 2 }, { getFormat: () => 'video/mp4', id: 2 },
], ],
}, true); }, true);
expect(wrapper.contains(<source src="1" type="video/mp4" />)); expect(wrapper.contains(<source src={1} type="video/mp4" />)).toBe(true);
expect(wrapper.contains(<source src="2" type="video/mp4" />)); expect(wrapper.contains(<source src={2} type="video/mp4" />)).toBe(true);
}); });
it('passes through configurable options', () => { it('passes through configurable options', () => {
wrapper = createWrapper({ wrapper = createWrapper({
...@@ -44,8 +44,8 @@ describe('VideoViewer', () => { ...@@ -44,8 +44,8 @@ describe('VideoViewer', () => {
{ getFormat: () => 'video/mp4', id: 1 }, { getFormat: () => 'video/mp4', id: 1 },
], ],
}, true); }, true);
expect(wrapper.contains(<track src="1" label="English" srcLang="en" />)); expect(wrapper.contains(<track src={1} label="English" srcLang="en" />)).toBe(true);
expect(wrapper.contains(<track src="2" label="French" srcLang="fr" />)); expect(wrapper.contains(<track src={2} label="French" srcLang="fr" />)).toBe(true);
}); });
}); });
}); });
...@@ -6,7 +6,9 @@ export class AudioViewer extends Component { ...@@ -6,7 +6,9 @@ export class AudioViewer extends Component {
/* eslint-disable jsx-a11y/media-has-caption */ /* eslint-disable jsx-a11y/media-has-caption */
/** */ /** */
render() { render() {
const { classes, audioOptions, audioResources } = this.props; const {
captions, classes, audioOptions, audioResources,
} = this.props;
return ( return (
<div className={classes.container}> <div className={classes.container}>
...@@ -16,6 +18,11 @@ export class AudioViewer extends Component { ...@@ -16,6 +18,11 @@ export class AudioViewer extends Component {
<source src={audio.id} type={audio.getFormat()} /> <source src={audio.id} type={audio.getFormat()} />
</Fragment> </Fragment>
))} ))}
{captions.map(caption => (
<Fragment key={caption.id}>
<track src={caption.id} label={caption.getLabel()} srcLang={caption.getProperty('language')} />
</Fragment>
))}
</audio> </audio>
</div> </div>
); );
...@@ -26,10 +33,12 @@ export class AudioViewer extends Component { ...@@ -26,10 +33,12 @@ export class AudioViewer extends Component {
AudioViewer.propTypes = { AudioViewer.propTypes = {
audioOptions: PropTypes.object, // eslint-disable-line react/forbid-prop-types audioOptions: PropTypes.object, // eslint-disable-line react/forbid-prop-types
audioResources: PropTypes.arrayOf(PropTypes.object), audioResources: PropTypes.arrayOf(PropTypes.object),
captions: PropTypes.arrayOf(PropTypes.object),
classes: PropTypes.objectOf(PropTypes.string).isRequired, classes: PropTypes.objectOf(PropTypes.string).isRequired,
}; };
AudioViewer.defaultProps = { AudioViewer.defaultProps = {
audioOptions: {}, audioOptions: {},
audioResources: [], audioResources: [],
captions: [],
}; };
...@@ -4,13 +4,14 @@ import { withTranslation } from 'react-i18next'; ...@@ -4,13 +4,14 @@ import { withTranslation } from 'react-i18next';
import { withStyles } from '@material-ui/core'; import { withStyles } from '@material-ui/core';
import { withPlugins } from '../extend/withPlugins'; import { withPlugins } from '../extend/withPlugins';
import { AudioViewer } from '../components/AudioViewer'; import { AudioViewer } from '../components/AudioViewer';
import { getConfig, getVisibleCanvasAudioResources } from '../state/selectors'; import { getConfig, getVisibleCanvasAudioResources, getVisibleCanvasCaptions } from '../state/selectors';
/** */ /** */
const mapStateToProps = (state, { windowId }) => ( const mapStateToProps = (state, { windowId }) => (
{ {
audioOptions: getConfig(state).audioOptions, audioOptions: getConfig(state).audioOptions,
audioResources: getVisibleCanvasAudioResources(state, { windowId }) || [], audioResources: getVisibleCanvasAudioResources(state, { windowId }) || [],
captions: getVisibleCanvasCaptions(state, { windowId }) || [],
} }
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment