koel/resources/assets/js/tests/stores/artistTest.js

80 lines
2.7 KiB
JavaScript
Raw Normal View History

2015-12-13 04:42:28 +00:00
require('chai').should();
2016-03-05 09:01:12 +00:00
import _ 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-05 09:01:12 +00:00
beforeEach(() => artistStore.init(_.cloneDeep(artists)));
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;
});
});
describe('#getSongsByArtist', () => {
it('correctly gathers all songs by artist', () => {
artistStore.getSongsByArtist(artistStore.state.artists[0]).length.should.equal(3);
});
});
2015-12-22 09:53:03 +00:00
describe('#getImage', () => {
it('correctly gets an artists 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
describe('#append', () => {
beforeEach(() => artistStore.append(_.cloneDeep(singleArtist)));
it('correctly appends an artist', () => {
_.last(artistStore.state.artists).name.should.equal('John Cena');
});
});
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(() => {
artistStore.addAlbumsIntoArtist(artistStore.state.artists[0], _.cloneDeep(singleAlbum));
});
it('correctly adds albums into an artist', () => {
artistStore.state.artists[0].albums.length.should.equal(4);
});
it('correctly sets the album artist', () => {
2016-03-16 03:51:07 +00:00
let 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
});