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

49 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-11-26 03:25:35 +00:00
require('chai').should()
import { cloneDeep, last } from 'lodash'
2015-12-13 04:42:28 +00:00
2016-11-26 03:25:35 +00:00
import { albumStore, artistStore } from '../../stores'
2017-04-25 14:09:32 +00:00
import data from '../blobs/data'
const { artists, albums } = data
2015-12-13 04:42:28 +00:00
describe('stores/album', () => {
2017-04-25 14:09:32 +00:00
beforeEach(() => {
artistStore.init(cloneDeep(artists))
albumStore.init(cloneDeep(albums))
})
2016-03-05 09:01:12 +00:00
2017-04-25 14:09:32 +00:00
afterEach(() => {
artistStore.state.artists = []
albumStore.state.albums = []
})
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +00:00
describe('#init', () => {
it('correctly gathers albums', () => {
2016-11-26 03:25:35 +00:00
albumStore.state.albums.length.should.equal(7)
})
2015-12-13 04:42:28 +00:00
2016-06-25 16:05:24 +00:00
it('correctly sets album artists', () => {
2017-04-25 14:09:32 +00:00
albumStore.state.albums[0].artist.id.should.equal(3)
2016-11-26 03:25:35 +00:00
})
})
2015-12-13 04:42:28 +00:00
2017-04-25 14:09:32 +00:00
describe('#byId', () => {
it('correctly gets an album by ID', () => {
albumStore.byId(1193).name.should.equal('All-4-One')
2016-11-26 03:25:35 +00:00
})
})
2016-03-05 09:01:12 +00:00
2017-04-25 14:09:32 +00:00
describe('#compact', () => {
it('correctly compacts albums', () => {
albumStore.compact()
albumStore.state.albums.length.should.equal(0)
2016-11-26 03:25:35 +00:00
})
})
2016-03-05 09:01:12 +00:00
2017-04-25 14:09:32 +00:00
describe('#all', () => {
it('correctly returns all albums', () => {
albumStore.all.length.should.equal(7)
2016-11-26 03:25:35 +00:00
})
})
})