2015-12-13 04:42:28 +00:00
|
|
|
|
require('chai').should();
|
2016-03-31 07:44:36 +00:00
|
|
|
|
import { cloneDeep, last } from 'lodash';
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
|
|
import artistStore from '../../stores/artist';
|
2016-03-05 09:01:12 +00:00
|
|
|
|
import { default as artists, singleAlbum, singleArtist } from '../blobs/media';
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
|
|
describe('stores/artist', () => {
|
2016-03-31 07:44:36 +00:00
|
|
|
|
beforeEach(() => artistStore.init(cloneDeep(artists)));
|
2016-03-05 09:01:12 +00:00
|
|
|
|
afterEach(() => artistStore.state.artists = []);
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
|
|
describe('#init', () => {
|
|
|
|
|
it('correctly gathers artists', () => {
|
|
|
|
|
artistStore.state.artists.length.should.equal(3);
|
|
|
|
|
});
|
|
|
|
|
|
2016-03-05 09:01:12 +00:00
|
|
|
|
it('correctly gets artist images', () => {
|
2015-12-22 09:53:03 +00:00
|
|
|
|
artistStore.state.artists[0].image.should.equal('/public/img/covers/565c0f7067425.jpeg');
|
2015-12-13 04:42:28 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('correctly counts songs by artists', () => {
|
|
|
|
|
artistStore.state.artists[0].songCount = 3;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2015-12-22 09:53:03 +00:00
|
|
|
|
describe('#getImage', () => {
|
|
|
|
|
it('correctly gets an artist’s image', () => {
|
|
|
|
|
artistStore.getImage(artistStore.state.artists[0]).should.equal('/public/img/covers/565c0f7067425.jpeg');
|
2015-12-13 04:42:28 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
2016-03-05 09:01:12 +00:00
|
|
|
|
|
2016-04-05 07:38:10 +00:00
|
|
|
|
describe('#add', () => {
|
|
|
|
|
beforeEach(() => artistStore.add(cloneDeep(singleArtist)));
|
2016-03-05 09:01:12 +00:00
|
|
|
|
|
2016-04-05 07:38:10 +00:00
|
|
|
|
it('correctly adds an artist', () => {
|
2016-03-31 07:44:36 +00:00
|
|
|
|
last(artistStore.state.artists).name.should.equal('John Cena');
|
2016-03-05 09:01:12 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('#remove', () => {
|
|
|
|
|
beforeEach(() => artistStore.remove(artistStore.state.artists[0]));
|
|
|
|
|
|
|
|
|
|
it('correctly removes an artist', () => {
|
|
|
|
|
artistStore.state.artists.length.should.equal(2);
|
|
|
|
|
artistStore.state.artists[0].name.should.equal('Bob Dylan');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('#addAlbumsIntoArtist', () => {
|
|
|
|
|
beforeEach(() => {
|
2016-03-31 07:44:36 +00:00
|
|
|
|
artistStore.addAlbumsIntoArtist(artistStore.state.artists[0], cloneDeep(singleAlbum));
|
2016-03-05 09:01:12 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('correctly adds albums into an artist', () => {
|
|
|
|
|
artistStore.state.artists[0].albums.length.should.equal(4);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('correctly sets the album artist', () => {
|
2016-03-31 07:44:36 +00:00
|
|
|
|
const addedAlbum = last(artistStore.state.artists[0].albums);
|
2016-03-05 09:01:12 +00:00
|
|
|
|
addedAlbum.artist.should.equal(artistStore.state.artists[0]);
|
|
|
|
|
addedAlbum.artist_id.should.equal(artistStore.state.artists[0].id);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('#removeAlbumsFromArtist', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
artistStore.removeAlbumsFromArtist(artistStore.state.artists[0], artistStore.state.artists[0].albums[0]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('correctly removes an album from an artist', () => {
|
|
|
|
|
artistStore.state.artists[0].albums.length.should.equal(2);
|
|
|
|
|
});
|
|
|
|
|
});
|
2015-12-13 04:42:28 +00:00
|
|
|
|
});
|