Updating tests - state seems broken, needs attention
This commit is contained in:
@ -55,7 +55,8 @@ class GridItem extends React.Component {
|
||||
|
||||
renderSecondary = ({
|
||||
uri,
|
||||
tracks_total,
|
||||
tracks_total = 0,
|
||||
tracks,
|
||||
followers,
|
||||
albums_uris,
|
||||
artists,
|
||||
@ -64,7 +65,7 @@ class GridItem extends React.Component {
|
||||
case 'playlist':
|
||||
return (
|
||||
<span className="grid__item__secondary__content">
|
||||
<I18n path="specs.tracks" count={tracks_total || 0} />
|
||||
<I18n path="specs.tracks" count={tracks.length || tracks_total} />
|
||||
</span>
|
||||
);
|
||||
|
||||
@ -95,7 +96,9 @@ class GridItem extends React.Component {
|
||||
|
||||
render = () => {
|
||||
const {
|
||||
item: { album },
|
||||
item: {
|
||||
album,
|
||||
} = {},
|
||||
link: customLink,
|
||||
type,
|
||||
show_source_icon,
|
||||
@ -149,4 +152,8 @@ const mapStateToProps = (state) => {
|
||||
};
|
||||
};
|
||||
|
||||
export {
|
||||
GridItem,
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(GridItem);
|
||||
|
||||
@ -26,7 +26,13 @@ const indexToArray = (index, keys) => {
|
||||
* */
|
||||
const arrayOf = (property, items = []) => {
|
||||
const array = [];
|
||||
items.forEach((item) => (item[property] !== undefined ? array.push(item[property]) : null));
|
||||
items.forEach(
|
||||
(item) => {
|
||||
if (item[property] === undefined) return;
|
||||
if (item[property] === null) return;
|
||||
array.push(item[property]);
|
||||
},
|
||||
);
|
||||
return array;
|
||||
};
|
||||
|
||||
|
||||
@ -375,13 +375,14 @@ let isObject = function (value) {
|
||||
const isLoading = function (load_queue = {}, keys = []) {
|
||||
if (!load_queue || !keys) return false;
|
||||
|
||||
const queue_keys = indexToArray(load_queue);
|
||||
const queue_keys = Object.keys(load_queue);
|
||||
const matches = keys.reduce((acc, key) => {
|
||||
let regex = '';
|
||||
try {
|
||||
regex = new RegExp(key);
|
||||
} catch {
|
||||
console.error('Invalid regular expression', keys);
|
||||
// Fucks with unit tests, but helpful for debugging.
|
||||
// console.error('Invalid regular expression', keys);
|
||||
return acc;
|
||||
}
|
||||
|
||||
|
||||
@ -21,14 +21,12 @@ import * as spotifyActions from '../services/spotify/actions';
|
||||
import * as lastfmActions from '../services/lastfm/actions';
|
||||
import {
|
||||
uriSource,
|
||||
getFromUri,
|
||||
isLoading,
|
||||
sourceIcon,
|
||||
} from '../util/helpers';
|
||||
import Button from '../components/Button';
|
||||
import { makeLoadingSelector, makeItemSelector, makeLibrarySelector } from '../util/selectors';
|
||||
import { makeLoadingSelector, makeItemSelector } from '../util/selectors';
|
||||
|
||||
export class Album extends React.Component {
|
||||
class Album extends React.Component {
|
||||
componentDidMount = () => {
|
||||
const {
|
||||
uri,
|
||||
@ -305,6 +303,10 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
lastfmActions: bindActionCreators(lastfmActions, dispatch),
|
||||
});
|
||||
|
||||
export {
|
||||
Album,
|
||||
};
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps,
|
||||
|
||||
Reference in New Issue
Block a user