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

74 lines
2.3 KiB
JavaScript
Raw Normal View History

2015-12-13 04:42:28 +00:00
require('chai').should();
import { cloneDeep, last } from 'lodash';
2015-12-13 04:42:28 +00:00
2016-06-25 10:15:57 +00:00
import { artistStore } from '../../stores';
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-06-25 16:05:24 +00:00
beforeEach(() => artistStore.init(cloneDeep(artists)));
afterEach(() => artistStore.state.artists = []);
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +00:00
describe('#init', () => {
it('correctly gathers artists', () => {
artistStore.state.artists.length.should.equal(3);
});
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +00:00
it('correctly gets artist images', () => {
artistStore.state.artists[0].image.should.equal('/public/img/covers/565c0f7067425.jpeg');
});
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +00:00
it('correctly counts songs by artists', () => {
artistStore.state.artists[0].songCount = 3;
2015-12-13 04:42:28 +00:00
});
2016-06-25 16:05:24 +00:00
});
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +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-06-25 16:05:24 +00:00
});
2016-03-05 09:01:12 +00:00
2016-06-25 16:05:24 +00:00
describe('#add', () => {
beforeEach(() => artistStore.add(cloneDeep(singleArtist)));
2016-03-05 09:01:12 +00:00
2016-06-25 16:05:24 +00:00
it('correctly adds an artist', () => {
last(artistStore.state.artists).name.should.equal('John Cena');
2016-03-05 09:01:12 +00:00
});
2016-06-25 16:05:24 +00:00
});
2016-03-05 09:01:12 +00:00
2016-06-25 16:05:24 +00:00
describe('#remove', () => {
beforeEach(() => artistStore.remove(artistStore.state.artists[0]));
2016-03-05 09:01:12 +00:00
2016-06-25 16:05:24 +00:00
it('correctly removes an artist', () => {
artistStore.state.artists.length.should.equal(2);
artistStore.state.artists[0].name.should.equal('Bob Dylan');
2016-03-05 09:01:12 +00:00
});
2016-06-25 16:05:24 +00:00
});
2016-03-05 09:01:12 +00:00
2016-06-25 16:05:24 +00:00
describe('#addAlbumsIntoArtist', () => {
beforeEach(() => {
artistStore.addAlbumsIntoArtist(artistStore.state.artists[0], cloneDeep(singleAlbum));
});
2016-03-05 09:01:12 +00:00
2016-06-25 16:05:24 +00:00
it('correctly adds albums into an artist', () => {
artistStore.state.artists[0].albums.length.should.equal(4);
});
2016-03-05 09:01:12 +00:00
2016-06-25 16:05:24 +00:00
it('correctly sets the album artist', () => {
const addedAlbum = last(artistStore.state.artists[0].albums);
addedAlbum.artist.should.equal(artistStore.state.artists[0]);
addedAlbum.artist_id.should.equal(artistStore.state.artists[0].id);
2016-03-05 09:01:12 +00:00
});
2016-06-25 16:05:24 +00:00
});
2016-03-05 09:01:12 +00:00
2016-06-25 16:05:24 +00:00
describe('#removeAlbumsFromArtist', () => {
beforeEach(() => {
artistStore.removeAlbumsFromArtist(artistStore.state.artists[0], artistStore.state.artists[0].albums[0]);
});
2016-03-05 09:01:12 +00:00
2016-06-25 16:05:24 +00:00
it('correctly removes an album from an artist', () => {
artistStore.state.artists[0].albums.length.should.equal(2);
2016-03-05 09:01:12 +00:00
});
2016-06-25 16:05:24 +00:00
});
2015-12-13 04:42:28 +00:00
});