mirror of
https://github.com/jellyfin/jellyfin-vue.git
synced 2024-12-03 11:41:09 +00:00
test(tvshows): use proper message format
This commit is contained in:
parent
f439309790
commit
5d7a81782c
@ -46,76 +46,78 @@ beforeEach(() => {
|
||||
store = new Vuex.Store(cloneDeep({ state, mutations, getters, actions }));
|
||||
});
|
||||
|
||||
test('When "ADD_TVSHOW_SEASONS" is committed, the seasons are added is set.', () => {
|
||||
store.replaceState({ ...defaultState() });
|
||||
describe('vuex: tvShows', () => {
|
||||
it('adds the seasons when "ADD_TVSHOW_SEASONS" is committed', () => {
|
||||
store.replaceState({ ...defaultState() });
|
||||
|
||||
store.commit('ADD_TVSHOW_SEASONS', {
|
||||
seasons: [TEST_TV_SEASON_1, TEST_TV_SEASON_2],
|
||||
itemId: TEST_TV_SERIES.Id
|
||||
});
|
||||
|
||||
expect(store.state[TEST_TV_SERIES.Id || ''].seasons).toMatchObject([
|
||||
TEST_TV_SEASON_1,
|
||||
TEST_TV_SEASON_2
|
||||
]);
|
||||
});
|
||||
|
||||
test('When "ADD_TVSHOW_SEASON_EPISODES" is committed, the episodes are added.', () => {
|
||||
store.replaceState({ ...defaultState() });
|
||||
|
||||
store.commit('ADD_TVSHOW_SEASON_EPISODES', {
|
||||
seasonEpisodes: [TEST_TV_EPISODE_1, TEST_TV_EPISODE_2],
|
||||
itemId: [TEST_TV_SERIES.Id],
|
||||
seasonItemId: TEST_TV_SEASON_1.Id
|
||||
});
|
||||
|
||||
expect(store.state[TEST_TV_SERIES.Id || ''].seasonEpisodes).toMatchObject({
|
||||
[TEST_TV_SEASON_1.Id || '']: [TEST_TV_EPISODE_1, TEST_TV_EPISODE_2]
|
||||
});
|
||||
});
|
||||
|
||||
test('When "CLEAR_TVSHOWS" is committed, the store is cleared.', () => {
|
||||
store.replaceState({
|
||||
[TEST_TV_SERIES.Id || '']: {
|
||||
store.commit('ADD_TVSHOW_SEASONS', {
|
||||
seasons: [TEST_TV_SEASON_1, TEST_TV_SEASON_2],
|
||||
seasonEpisodes: {
|
||||
[TEST_TV_SEASON_1.Id || '']: [TEST_TV_EPISODE_1, TEST_TV_EPISODE_2]
|
||||
itemId: TEST_TV_SERIES.Id
|
||||
});
|
||||
|
||||
expect(store.state[TEST_TV_SERIES.Id || ''].seasons).toMatchObject([
|
||||
TEST_TV_SEASON_1,
|
||||
TEST_TV_SEASON_2
|
||||
]);
|
||||
});
|
||||
|
||||
it('adds episodes to a season when "ADD_TVSHOW_SEASON_EPISODES" is committed', () => {
|
||||
store.replaceState({ ...defaultState() });
|
||||
|
||||
store.commit('ADD_TVSHOW_SEASON_EPISODES', {
|
||||
seasonEpisodes: [TEST_TV_EPISODE_1, TEST_TV_EPISODE_2],
|
||||
itemId: [TEST_TV_SERIES.Id],
|
||||
seasonItemId: TEST_TV_SEASON_1.Id
|
||||
});
|
||||
|
||||
expect(store.state[TEST_TV_SERIES.Id || ''].seasonEpisodes).toMatchObject({
|
||||
[TEST_TV_SEASON_1.Id || '']: [TEST_TV_EPISODE_1, TEST_TV_EPISODE_2]
|
||||
});
|
||||
});
|
||||
|
||||
it('clears the store when "CLEAR_TVSHOWS" is committed', () => {
|
||||
store.replaceState({
|
||||
[TEST_TV_SERIES.Id || '']: {
|
||||
seasons: [TEST_TV_SEASON_1, TEST_TV_SEASON_2],
|
||||
seasonEpisodes: {
|
||||
[TEST_TV_SEASON_1.Id || '']: [TEST_TV_EPISODE_1, TEST_TV_EPISODE_2]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
store.commit('CLEAR_TVSHOWS');
|
||||
|
||||
expect(store.state).toMatchObject(defaultState());
|
||||
});
|
||||
|
||||
store.commit('CLEAR_TVSHOWS');
|
||||
it('sets the show, seasons and episodes <hen getTvShowsSeasonEpisodesSuccess is dispatched', () => {
|
||||
store.replaceState({ ...defaultState() });
|
||||
|
||||
expect(store.state).toMatchObject(defaultState());
|
||||
});
|
||||
store.dispatch('getTvShowsSeasonEpisodesSuccess', {
|
||||
response: {
|
||||
Items: [TEST_TV_EPISODE_1, TEST_TV_EPISODE_2]
|
||||
} as BaseItemDtoQueryResult,
|
||||
itemId: TEST_TV_SERIES.Id,
|
||||
seasonItemId: TEST_TV_SEASON_1.Id
|
||||
});
|
||||
|
||||
test('When getTvShowsSeasonEpisodesSuccess is called, showNavDrawer is set.', () => {
|
||||
store.replaceState({ ...defaultState() });
|
||||
|
||||
store.dispatch('getTvShowsSeasonEpisodesSuccess', {
|
||||
response: {
|
||||
Items: [TEST_TV_EPISODE_1, TEST_TV_EPISODE_2]
|
||||
} as BaseItemDtoQueryResult,
|
||||
itemId: TEST_TV_SERIES.Id,
|
||||
seasonItemId: TEST_TV_SEASON_1.Id
|
||||
expect(store.state[TEST_TV_SERIES.Id || ''].seasonEpisodes).toMatchObject({
|
||||
[TEST_TV_SEASON_1.Id || '']: [TEST_TV_EPISODE_1, TEST_TV_EPISODE_2]
|
||||
});
|
||||
});
|
||||
|
||||
expect(store.state[TEST_TV_SERIES.Id || ''].seasonEpisodes).toMatchObject({
|
||||
[TEST_TV_SEASON_1.Id || '']: [TEST_TV_EPISODE_1, TEST_TV_EPISODE_2]
|
||||
});
|
||||
});
|
||||
|
||||
test('When clearTvShows is called, the store is cleared.', () => {
|
||||
store.replaceState({
|
||||
[TEST_TV_SERIES.Id || '']: {
|
||||
seasons: [TEST_TV_SEASON_1, TEST_TV_SEASON_2],
|
||||
seasonEpisodes: {
|
||||
[TEST_TV_SEASON_1.Id || '']: [TEST_TV_EPISODE_1, TEST_TV_EPISODE_2]
|
||||
it('clears the store when clearTvShows is dispatched', () => {
|
||||
store.replaceState({
|
||||
[TEST_TV_SERIES.Id || '']: {
|
||||
seasons: [TEST_TV_SEASON_1, TEST_TV_SEASON_2],
|
||||
seasonEpisodes: {
|
||||
[TEST_TV_SEASON_1.Id || '']: [TEST_TV_EPISODE_1, TEST_TV_EPISODE_2]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
store.dispatch('clearTvShows');
|
||||
|
||||
expect(store.state).toMatchObject(defaultState());
|
||||
});
|
||||
|
||||
store.dispatch('clearTvShows');
|
||||
|
||||
expect(store.state).toMatchObject(defaultState());
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user