Socket
Socket
Sign inDemoInstall

react-jplayer

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-jplayer - npm Package Compare versions

Comparing version 4.0.2 to 4.0.3

2

lib/components/poster/poster.js

@@ -21,3 +21,3 @@ 'use strict';

attributes = _ref.attributes;
return _react2.default.createElement('img', _extends({ className: _constants.classes.POSTER, alt: alt, src: src }, attributes));
return src !== '' ? _react2.default.createElement('img', _extends({ className: _constants.classes.POSTER, alt: alt, src: src }, attributes)) : null;
};

@@ -24,0 +24,0 @@

@@ -18,24 +18,16 @@ 'use strict';

var Title = function Title(_ref) {
var artist = _ref.artist,
title = _ref.title,
children = _ref.children,
var children = _ref.children,
attributes = _ref.attributes;
return _react2.default.createElement(
return children !== '' ? _react2.default.createElement(
'div',
_extends({ className: _constants.classes.TITLE }, attributes),
children === null ? artist + ' - ' + title : children
);
children
) : null;
};
Title.defaultProps = {
children: null
};
Title.propTypes = {
attributes: _react2.default.PropTypes.object.isRequired,
children: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.number]),
artist: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.number]).isRequired,
title: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.number]).isRequired
children: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.number]).isRequired
};
exports.default = Title;

@@ -17,2 +17,19 @@ 'use strict';

var formatArtistAndTitle = function formatArtistAndTitle(artist, title) {
var titleText = '';
if (artist !== '') {
titleText += '' + artist;
}
if (title !== '') {
if (artist !== '') {
titleText += ' - ';
}
titleText += '' + title;
}
return titleText;
};
var mapStateToProps = function mapStateToProps(_ref2, _ref) {

@@ -26,5 +43,3 @@ var jPlayers = _ref2.jPlayers;

return {
title: jPlayers[id].media.title,
artist: jPlayers[id].media.artist,
children: children,
children: children || formatArtistAndTitle(jPlayers[id].media.artist, jPlayers[id].media.title),
attributes: attributes

@@ -31,0 +46,0 @@ };

{
"name": "react-jplayer",
"version": "4.0.2",
"version": "4.0.3",
"description": "Html5 audio and video player library for React",

@@ -5,0 +5,0 @@ "author": "Martin Dawson <u1356770@gmail.com>",

@@ -334,3 +334,3 @@ [![Build Status](https://travis-ci.org/MartinDawson/react-jPlayer.svg?branch=master)](https://travis-ci.org/MartinDawson/react-jPlayer)

##### `setOption(id, key, value)`
Sets any jPlayer option. For some properties such as `muted` you can either use this method or `setMute()`. They both do the same thing.
Sets any jPlayer option. Some of the options can be set using the below actions as well as this method, it doesn't matter which one you use as they both do the same thing internally.

@@ -337,0 +337,0 @@ **Arguments**

@@ -5,4 +5,7 @@ import React from 'react';

const Poster = ({ src, alt, attributes }) =>
<img className={classes.POSTER} alt={alt} src={src} {...attributes} />;
const Poster = ({ src, alt, attributes }) => (
src !== '' ?
<img className={classes.POSTER} alt={alt} src={src} {...attributes} />
: null
);

@@ -9,0 +12,0 @@ Poster.defaultProps = {

@@ -5,6 +5,6 @@ import React from 'react';

import { classes } from '../../util/constants';
import { classes, defaultStatus } from '../../util/constants';
import Poster from './poster';
const setup = () => {
const setup = (newProps) => {
const props = {

@@ -16,2 +16,3 @@ src: 'http://www.test.jpg',

},
...newProps,
};

@@ -31,7 +32,5 @@

beforeEach(() => {
it('renders self and subcomponents', () => {
({ wrapper, props } = setup());
});
it('renders self and subcomponents', () => {
expect(wrapper.hasClass(classes.POSTER)).toBeTruthy();

@@ -42,2 +41,8 @@ expect(wrapper.prop('alt')).toBe(props.alt);

});
it('renders null if src is not set', () => {
({ wrapper, props } = setup({ src: defaultStatus.src }));
expect(wrapper.type()).toBe(null);
});
});

@@ -5,12 +5,10 @@ import React from 'react';

const Title = ({ artist, title, children, attributes }) => (
<div className={classes.TITLE} {...attributes}>
{children === null ? `${artist} - ${title}` : children}
</div>
const Title = ({ children, attributes }) => (
children !== '' ?
<div className={classes.TITLE} {...attributes}>
{children}
</div>
: null
);
Title.defaultProps = {
children: null,
};
Title.propTypes = {

@@ -21,13 +19,5 @@ attributes: React.PropTypes.object.isRequired,

React.PropTypes.number,
]),
artist: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number,
]).isRequired,
title: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number,
]).isRequired,
};
export default Title;

@@ -13,4 +13,3 @@ import React from 'react';

},
artist: 'Alan Walker',
title: 'Fade',
children: 'Fade - Alan Walker',
...newProps,

@@ -32,6 +31,4 @@ };

it('renders self and subcomponents', () => {
const children = <div>Alan Walker - Fade</div>;
({ wrapper, props } = setup());
({ wrapper, props } = setup({ children }));
expect(wrapper.prop('children')).toBe(props.children);

@@ -42,8 +39,6 @@ expect(wrapper.hasClass(classes.TITLE)).toBeTruthy();

it('renders artist and title if children are not specified', () => {
({ wrapper, props } = setup());
expect(wrapper.prop('children')).toBe(`${props.artist} - ${props.title}`);
expect(wrapper.hasClass(classes.TITLE)).toBeTruthy();
it('renders null if children is empty string', () => {
({ wrapper, props } = setup({ children: '' }));
expect(wrapper.type()).toBe(null);
});
});
import { connectWithId } from '../../util/index';
import Title from './title';
const formatArtistAndTitle = (artist, title) => {
let titleText = '';
if (artist !== '') {
titleText += `${artist}`;
}
if (title !== '') {
if (artist !== '') {
titleText += ' - ';
}
titleText += `${title}`;
}
return titleText;
};
const mapStateToProps = ({ jPlayers }, { id, children, ...attributes }) => ({
title: jPlayers[id].media.title,
artist: jPlayers[id].media.artist,
children,
children: children || formatArtistAndTitle(jPlayers[id].media.artist, jPlayers[id].media.title),
attributes,

@@ -9,0 +24,0 @@ });

@@ -12,3 +12,2 @@ import React from 'react';

};
const children = <div />;

@@ -24,7 +23,23 @@ describe('TitleContainer', () => {

},
}), { id, ...attributes });
const children = `${artist} - ${title}`;
expect(expected).toEqual({
children,
attributes,
});
});
it('maps custom children if specified', () => {
const title = 'Test Title';
const artist = 'Test Artist';
const children = <div />;
const expected = mapStateToProps(getJPlayers({
media: {
title,
artist,
},
}), { children, id, ...attributes });
expect(expected).toEqual({
title,
artist,
children,

@@ -34,2 +49,50 @@ attributes,

});
it('formats title properly when artist is empty', () => {
const title = 'Test Title';
const artist = '';
const expected = mapStateToProps(getJPlayers({
media: {
title,
artist,
},
}), { id, ...attributes });
const children = `${title}`;
expect(expected).toEqual({
children,
attributes,
});
});
it('formats title properly when title is empty', () => {
const title = '';
const artist = 'Test Artist';
const expected = mapStateToProps(getJPlayers({
media: {
title,
artist,
},
}), { id, ...attributes });
const children = `${artist}`;
expect(expected).toEqual({
children,
attributes,
});
});
it('formats title properly when title and artist are empty', () => {
const title = '';
const artist = '';
const expected = mapStateToProps(getJPlayers({
media: {
title,
artist,
},
}), { id, ...attributes });
const children = '';
expect(expected).toEqual({
children,
attributes,
});
});
});

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc