Updating tests - state seems broken, needs attention
This commit is contained in:
@ -1,34 +1,43 @@
|
||||
import React from 'react';
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
|
||||
// Testing-specific
|
||||
import { shallow, mount, render } from 'enzyme';
|
||||
const state = require('../state');
|
||||
|
||||
// Test subjects
|
||||
import GridItem from '../../src/js/components/GridItem';
|
||||
import { shallow } from 'enzyme';
|
||||
import { GridItem } from '../../src/js/components/GridItem';
|
||||
|
||||
describe('<GridItem />', () => {
|
||||
|
||||
it('should handle album', () => {
|
||||
var album = state.core.albums['jest:album:one'];
|
||||
var dom = shallow(<GridItem item={album} />);
|
||||
expect(dom.find('.grid__item__name').text()).toEqual('One');
|
||||
expect(dom.find('.grid__item__secondary__content').length).toBe(1);
|
||||
});
|
||||
it('should handle album', () => {
|
||||
const item = {
|
||||
uri: 'spotify:album:alpha',
|
||||
name: 'One',
|
||||
};
|
||||
const dom = shallow(<GridItem item={item} />);
|
||||
expect(dom.find('.grid__item__name').text()).toEqual('One');
|
||||
expect(dom.find('.grid__item__secondary__content').length).toBe(1);
|
||||
});
|
||||
|
||||
it('should handle artist', () => {
|
||||
var artist = state.core.artists['jest:artist:alpha'];
|
||||
var dom = shallow(<GridItem item={artist} />);
|
||||
expect(dom.find('.grid__item__name').text()).toEqual('Alpha');
|
||||
expect(dom.find('.grid__item__secondary__content').childAt(0).render().text()).toEqual('123 followers');
|
||||
expect(dom.find('.grid__item__secondary__content').childAt(1).render().text()).toEqual('1 albums');
|
||||
});
|
||||
it('should handle artist', () => {
|
||||
const item = {
|
||||
uri: 'spotify:artist:alpha',
|
||||
name: 'Alpha',
|
||||
followers: 123,
|
||||
albums_uris: ['spotify:album:beta'],
|
||||
};
|
||||
const dom = shallow(<GridItem item={item} />);
|
||||
expect(dom.find('.grid__item__name').text()).toEqual('Alpha');
|
||||
expect(dom.find('.grid__item__secondary__content').childAt(0).render().text()).toEqual('123 followers');
|
||||
expect(dom.find('.grid__item__secondary__content').childAt(1).render().text()).toEqual('1 albums');
|
||||
});
|
||||
|
||||
it('should handle playlist', () => {
|
||||
var playlist = state.core.playlists['jest:playlist:one'];
|
||||
var dom = shallow(<GridItem item={playlist} />);
|
||||
expect(dom.find('.grid__item__name').text()).toEqual('One');
|
||||
expect(dom.find('.grid__item__secondary__content').render().text()).toEqual('2 tracks');
|
||||
});
|
||||
it('should handle playlist', () => {
|
||||
const item = {
|
||||
uri: 'spotify:playlist:alpha',
|
||||
name: 'One',
|
||||
tracks: [
|
||||
{ uri: 'spotify:track:123' },
|
||||
{ uri: 'spotify:track:456' },
|
||||
],
|
||||
};
|
||||
const dom = shallow(<GridItem item={item} />);
|
||||
expect(dom.find('.grid__item__name').text()).toEqual('One');
|
||||
expect(dom.find('.grid__item__secondary__content').render().text()).toEqual('2 tracks');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user