diff options
Diffstat (limited to 'tests/javascript/unit/store/feed.spec.ts')
-rw-r--r-- | tests/javascript/unit/store/feed.spec.ts | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/tests/javascript/unit/store/feed.spec.ts b/tests/javascript/unit/store/feed.spec.ts index 3a7521f89..451d04d7a 100644 --- a/tests/javascript/unit/store/feed.spec.ts +++ b/tests/javascript/unit/store/feed.spec.ts @@ -1,41 +1,42 @@ -import axios from '@nextcloud/axios' import { Feed } from '../../../../src/types/Feed' import { AppState } from '../../../../src/store' import { FEED_ACTION_TYPES, mutations, actions } from '../../../../src/store/feed' +import { FeedService } from '../../../../src/dataservices/feed.service' import { FEED_ITEM_MUTATION_TYPES, FEED_MUTATION_TYPES } from '../../../../src/types/MutationTypes' -jest.mock('@nextcloud/axios') - describe('feed.ts', () => { 'use strict' describe('actions', () => { describe('FETCH_FEEDS', () => { - it('should call GET and commit returned feeds to state', async () => { - (axios as any).get.mockResolvedValue({ data: { feeds: [] } }) + it('should call FeedService.fetchAllFeeds and commit returned feeds to state', async () => { + FeedService.fetchAllFeeds = jest.fn(); + (FeedService.fetchAllFeeds as any).mockResolvedValue({ data: { feeds: [] } }) const commit = jest.fn() await (actions[FEED_ACTION_TYPES.FETCH_FEEDS] as any)({ commit }) - expect(axios.get).toBeCalled() + expect(FeedService.fetchAllFeeds).toBeCalled() expect(commit).toBeCalledWith(FEED_MUTATION_TYPES.SET_FEEDS, []) expect(commit).toBeCalledWith(FEED_ITEM_MUTATION_TYPES.SET_UNREAD_COUNT, 0) }) }) describe('ADD_FEED', () => { - it('should call POST and commit feed to state', async () => { - (axios as any).post.mockResolvedValue({ data: { feeds: [] } }) + it('should call FeedService.addF and commit feed to state', async () => { + FeedService.addFeed = jest.fn(); + (FeedService.addFeed as any).mockResolvedValue({ data: { feeds: [] } }) const commit = jest.fn() await actions[FEED_ACTION_TYPES.ADD_FEED]({ commit }, { feedReq: { url: '' } }) - expect(axios.post).toBeCalled() + expect(FeedService.addFeed).toBeCalled() expect(commit).toBeCalled() }) - it('should call POST and not call commit if error', async () => { - (axios as any).post.mockRejectedValue() + it('should call FeedService.addF and not call commit if error', async () => { + FeedService.addFeed = jest.fn(); + (FeedService.addFeed as any).mockRejectedValue() const commit = jest.fn() await actions[FEED_ACTION_TYPES.ADD_FEED]({ commit }, { feedReq: { url: '' } }) - expect(axios.post).toBeCalled() + expect(FeedService.addFeed).toBeCalled() expect(commit).not.toBeCalled() }) |