Skip to content

Commit

Permalink
Fix #121 - React throwing a NaN warning (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
mderrick authored Nov 1, 2017
1 parent e9cb144 commit cfedd0a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/DefaultPlayer/Seek/Seek.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default ({ onChange, percentagePlayed, percentageBuffered, className, ari
onChange={onChange}
aria-label={ariaLabel}
className={styles.input}
value={percentagePlayed} />
value={percentagePlayed || 0} />
</div>
</div>
);
Expand Down
9 changes: 9 additions & 0 deletions src/DefaultPlayer/Seek/Seek.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ describe('Seek', () => {
.toEqual(10);
});

it('handles an undefined percentagePlayed value', () => {
component.setProps({
percentagePlayed: undefined
});
const rangeInput = component.find(`.${styles.input}`);
expect(rangeInput.prop('value'))
.toEqual(0);
});

it('triggers \'onChange\' prop when the input is changed', () => {
const spy = jest.fn();
component.setProps({
Expand Down
2 changes: 1 addition & 1 deletion src/DefaultPlayer/Volume/Volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import VolumeOff from './../Icon/volume_off.svg';
import VolumeUp from './../Icon/volume_up.svg';

export default ({ onChange, onClick, volume, muted, className, ariaLabelMute, ariaLabelUnmute, ariaLabelVolume }) => {
const volumeValue = muted
const volumeValue = muted || !volume
? 0
: +volume;
const isSilent = muted || volume <= 0;
Expand Down
9 changes: 9 additions & 0 deletions src/DefaultPlayer/Volume/Volume.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ describe('Volume', () => {
.toEqual('Change volume');
});

it('handles an undefined volume value', () => {
component.setProps({
volume: undefined
});
const rangeInput = component.find(`.${styles.input}`);
expect(rangeInput.prop('value'))
.toEqual(0);
});

it('triggers \'onClick\' prop when the button is clicked', () => {
const spy = jest.fn();
component.setProps({
Expand Down

0 comments on commit cfedd0a

Please sign in to comment.