summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevlin Junker <devlin.junker@gmail.com>2023-08-09 07:59:03 -0700
committerBenjamin Brahmer <info@b-brahmer.de>2023-08-11 09:22:24 +0200
commite559cb35d4fed3c7c38c0dd3fd2d161b077f88af (patch)
tree02d617df61e678aba9bfd6ff62de2eb25236fb8c
parent790701a82a06c4046cc66134d5b4d4c1e62cda74 (diff)
fix linting errors
Signed-off-by: Devlin Junker <devlin.junker@gmail.com>
-rw-r--r--src/store/feed.ts22
-rw-r--r--src/types/ApiRoutes.ts6
-rw-r--r--src/types/MutationTypes.ts1
-rw-r--r--tests/javascript/unit/store/feed.spec.ts16
4 files changed, 21 insertions, 24 deletions
diff --git a/src/store/feed.ts b/src/store/feed.ts
index b103b7707..9a0da520b 100644
--- a/src/store/feed.ts
+++ b/src/store/feed.ts
@@ -28,25 +28,25 @@ export const actions = {
},
async [FEED_ACTION_TYPES.ADD_FEED](
{ commit }: ActionParams,
- { feedReq }: {
- feedReq: {
- url: string;
- folder?: { id: number; name?: string; },
- user?: string;
- password?: string;
- }
- }
+ { feedReq }: {
+ feedReq: {
+ url: string;
+ folder?: { id: number; name?: string; },
+ user?: string;
+ password?: string;
+ }
+ },
) {
let url = feedReq.url.trim()
if (!url.startsWith('http')) {
url = 'https://' + url
}
- let folderId;
+ let folderId
if (feedReq.folder?.id === undefined && feedReq.folder?.name && feedReq.folder?.name !== '') {
const response = await axios.post(API_ROUTES.FOLDER, { folderName: feedReq.folder?.name })
- folderId = response.data.folders[0].id;
- commit(FOLDER_MUTATION_TYPES.SET_FOLDERS, response.data.folders);
+ folderId = response.data.folders[0].id
+ commit(FOLDER_MUTATION_TYPES.SET_FOLDERS, response.data.folders)
} else {
folderId = feedReq.folder?.id || 0
}
diff --git a/src/types/ApiRoutes.ts b/src/types/ApiRoutes.ts
index a82c66dc1..c05a5f716 100644
--- a/src/types/ApiRoutes.ts
+++ b/src/types/ApiRoutes.ts
@@ -1,6 +1,6 @@
import { generateUrl } from '@nextcloud/router'
export const API_ROUTES = {
- FOLDER: generateUrl('/apps/news/folders'),
- FEED: generateUrl('/apps/news/feeds')
-} \ No newline at end of file
+ FOLDER: generateUrl('/apps/news/folders'),
+ FEED: generateUrl('/apps/news/feeds'),
+}
diff --git a/src/types/MutationTypes.ts b/src/types/MutationTypes.ts
index d561d1d77..294deaffd 100644
--- a/src/types/MutationTypes.ts
+++ b/src/types/MutationTypes.ts
@@ -1,4 +1,3 @@
-
export const FEED_MUTATION_TYPES = {
ADD_FEED: 'ADD_FEED',
SET_FEEDS: 'SET_FEEDS',
diff --git a/tests/javascript/unit/store/feed.spec.ts b/tests/javascript/unit/store/feed.spec.ts
index ba15c9410..922c79f3f 100644
--- a/tests/javascript/unit/store/feed.spec.ts
+++ b/tests/javascript/unit/store/feed.spec.ts
@@ -13,7 +13,7 @@ describe('feed.ts', () => {
describe('actions', () => {
describe('ADD_FEED', () => {
it('should call POST and commit feed to state', async () => {
- (axios as any).post.mockResolvedValue({ data: { feeds: [] }})
+ (axios as any).post.mockResolvedValue({ data: { feeds: [] } })
const commit = jest.fn()
await actions[FEED_ACTION_TYPES.ADD_FEED]({ commit }, { feedReq: { url: '' } })
expect(axios.post).toBeCalled()
@@ -30,8 +30,6 @@ describe('feed.ts', () => {
})
})
-
-
it('FETCH_FEEDS should call GET and commit returned feeds to state', async () => {
(axios as any).get.mockResolvedValue({ data: { feeds: [] } })
const commit = jest.fn()
@@ -46,23 +44,23 @@ describe('feed.ts', () => {
it('should add feeds to state', () => {
const state = { feeds: [] as Feed[], folders: [] as any[] } as AppState
let feeds = [] as any
-
+
mutations[FEED_MUTATION_TYPES.SET_FEEDS](state, feeds)
expect(state.feeds.length).toEqual(0)
-
+
feeds = [{ title: 'test' }] as Feed[]
-
+
mutations[FEED_MUTATION_TYPES.SET_FEEDS](state, feeds)
expect(state.feeds.length).toEqual(1)
expect(state.feeds[0]).toEqual(feeds[0])
})
})
-
+
describe('ADD_FEED', () => {
it('should add a single feed to state', () => {
const state = { feeds: [] as Feed[], folders: [] as any[] } as AppState
- let feed = { title: 'test' } as any;
-
+ const feed = { title: 'test' } as any
+
mutations[FEED_MUTATION_TYPES.ADD_FEED](state, feed)
expect(state.feeds.length).toEqual(1)
expect(state.feeds[0]).toEqual(feed)