summaryrefslogtreecommitdiffstats
path: root/tests/javascript/unit/services/feed.service.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/javascript/unit/services/feed.service.spec.ts')
-rw-r--r--tests/javascript/unit/services/feed.service.spec.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/javascript/unit/services/feed.service.spec.ts b/tests/javascript/unit/services/feed.service.spec.ts
new file mode 100644
index 000000000..5f0c058cd
--- /dev/null
+++ b/tests/javascript/unit/services/feed.service.spec.ts
@@ -0,0 +1,34 @@
+import { FeedService } from './../../../../src/dataservices/feed.service'
+import axios from '@nextcloud/axios'
+
+jest.mock('@nextcloud/axios')
+
+describe('feed.service.ts', () => {
+ 'use strict'
+
+ beforeEach(() => {
+ (axios.get as any).mockReset();
+ (axios.post as any).mockReset()
+ })
+
+ describe('fetchAllFeeds', () => {
+ it('should call GET to retrieve all feeds', async () => {
+ (axios as any).get.mockResolvedValue({ data: { feeds: [] } })
+
+ await FeedService.fetchAllFeeds()
+
+ expect(axios.get).toBeCalled()
+ })
+ })
+
+ describe('addFeed', () => {
+ it('should call POST with item id in URL and read param', async () => {
+ await FeedService.addFeed({ url: 'http://example.com', folderId: 0 })
+
+ expect(axios.post).toBeCalled()
+ const args = (axios.post as any).mock.calls[0]
+
+ expect(args[1].url).toEqual('http://example.com')
+ })
+ })
+})