test(itemhelper): improve tests and use proper message format

This commit is contained in:
MrTimscampi 2021-02-14 23:35:17 +01:00
parent cbaee21708
commit 3ad5aa5421
2 changed files with 46 additions and 9 deletions

View File

@ -6,14 +6,44 @@ const TestComponent = new Vue({
});
describe('itemHelper', () => {
test('Correctly returns true if the item can be resumed', () => {
expect(TestComponent.canPlay({ Type: 'MusicGenre' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'Season' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'Series' })).toEqual(true);
test('returns true if the item can be played', () => {
// TODO: Replace with BaseItemKind enum
expect(TestComponent.canPlay({ Type: 'AggregateFolder' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'Audio' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'AudioBook' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'BasePluginFolder' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'Book' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'BoxSet' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'Channel' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'ChannelFolderItem' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'CollectionFolder' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'Episode' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'Folder' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'Genre' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'ManualPlaylistsFolder' })).toEqual(
false
);
expect(TestComponent.canPlay({ Type: 'Movie' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'MusicAlbum' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'MusicArtist' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'MusicGenre' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'MusicVideo' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'Person' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'Photo' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'PhotoAlbum' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'Playlist' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'Program' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'Recording' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'Season' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'Series' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'Studio' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'Trailer' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'TvChannel' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'TvProgram' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'UserRootFolder' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'UserView' })).toEqual(false);
expect(TestComponent.canPlay({ Type: 'Video' })).toEqual(true);
expect(TestComponent.canPlay({ Type: 'Year' })).toEqual(false);
expect(TestComponent.canPlay({ MediaType: 'Video' })).toEqual(true);
expect(TestComponent.canPlay({ MediaType: 'Audio' })).toEqual(true);
@ -21,7 +51,7 @@ describe('itemHelper', () => {
expect(TestComponent.canPlay({})).toEqual(false);
});
test('Correctly returns true if the item can be resumed', () => {
test('returns true if the item can be resumed', () => {
expect(
TestComponent.canResume({ UserData: { PlaybackPositionTicks: 1 } })
).toEqual(true);

View File

@ -46,13 +46,20 @@ const itemHelper = Vue.extend({
if (
[
'MusicGenre',
'Season',
'Series',
'Audio',
'AudioBook',
'BoxSet',
'Episode',
'Movie',
'MusicAlbum',
'MusicArtist',
'Playlist'
'MusicGenre',
'MusicVideo',
'Playlist',
'Season',
'Series',
'Trailer',
'Video'
].includes(itemType) ||
['Video', 'Audio'].includes(itemMediaType)
) {