summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDevlin Junker <devlin.junker@gmail.com>2022-12-03 15:40:06 -0800
committerBenjamin Brahmer <info@b-brahmer.de>2022-12-06 14:57:20 +0100
commit2c32ea05f0a0f266e36075e702ee293d7834bf62 (patch)
tree8cf87a4a051af892f76213182471df09de7674e9 /tests
parent4899be32e3f6065297f95e0ccc42e97efbec545b (diff)
start on state/store tests
Signed-off-by: Devlin Junker <devlin.junker@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/javascript/unit/components/Explore.spec.ts1
-rw-r--r--tests/javascript/unit/components/Sidebar.spec.ts4
-rw-r--r--tests/javascript/unit/setup.spec.ts (renamed from tests/javascript/unit/setup.ts)4
-rw-r--r--tests/javascript/unit/store/feed.spec.ts28
-rw-r--r--tests/javascript/unit/store/folder.spec.ts44
5 files changed, 74 insertions, 7 deletions
diff --git a/tests/javascript/unit/components/Explore.spec.ts b/tests/javascript/unit/components/Explore.spec.ts
index f0a945821..1a952fac0 100644
--- a/tests/javascript/unit/components/Explore.spec.ts
+++ b/tests/javascript/unit/components/Explore.spec.ts
@@ -9,7 +9,6 @@ jest.mock('@nextcloud/axios');
describe('Explore.vue', () => {
'use strict'
-
const localVue = createLocalVue()
it('should initialize without showing AddFeed Component', () => {
diff --git a/tests/javascript/unit/components/Sidebar.spec.ts b/tests/javascript/unit/components/Sidebar.spec.ts
index 16affbb3d..e70db7197 100644
--- a/tests/javascript/unit/components/Sidebar.spec.ts
+++ b/tests/javascript/unit/components/Sidebar.spec.ts
@@ -134,8 +134,4 @@ describe('Sidebar.vue', () => {
afterEach(() => {
jest.clearAllMocks()
})
-
- afterEach(() => {
- jest.clearAllMocks()
- })
})
diff --git a/tests/javascript/unit/setup.ts b/tests/javascript/unit/setup.spec.ts
index 380436f8c..510e53baa 100644
--- a/tests/javascript/unit/setup.ts
+++ b/tests/javascript/unit/setup.spec.ts
@@ -10,11 +10,11 @@ config.mocks.$t = function(_app: any, string: any) {
}
config.mocks.t = config.mocks.$t
-config.mocks.$n = function(app: any, singular: any, plural: any, count: any) {
+config.mocks.$n = function(app: any, singular: any) {
return singular
}
config.mocks.n = config.mocks.$n
afterAll(() => {
- // TODO: ?
+ // TODO: afterAll tests?
})
diff --git a/tests/javascript/unit/store/feed.spec.ts b/tests/javascript/unit/store/feed.spec.ts
new file mode 100644
index 000000000..1a4fb0fee
--- /dev/null
+++ b/tests/javascript/unit/store/feed.spec.ts
@@ -0,0 +1,28 @@
+import axios from '@nextcloud/axios'
+import { Feed } from '../../../../src/types/Feed'
+import { AppState } from '../../../../src/store'
+import { FEED_ACTION_TYPES, FEED_MUTATION_TYPES, mutations, actions } from '../../../../src/store/feed'
+
+jest.mock('@nextcloud/axios')
+
+describe('feed.ts', () => {
+ 'use strict'
+
+ describe('actions', () => {
+ it('ADD_FEED', async () => {
+ (axios as any).post.mockResolvedValue()
+ const commit = jest.fn()
+ await actions[FEED_ACTION_TYPES.ADD_FEED]({ commit }, { feedReq: { url: '' } })
+ expect(axios.post).toBeCalled()
+ expect(commit).toBeCalled()
+ })
+ })
+
+ describe('mutations', () => {
+ it('', () => {
+ const state = { feeds: [] as Feed[] } as AppState
+ const feeds = [] as Feed[]
+ mutations[FEED_MUTATION_TYPES.SET_FEEDS](state, feeds)
+ })
+ })
+})
diff --git a/tests/javascript/unit/store/folder.spec.ts b/tests/javascript/unit/store/folder.spec.ts
new file mode 100644
index 000000000..1d7feafb0
--- /dev/null
+++ b/tests/javascript/unit/store/folder.spec.ts
@@ -0,0 +1,44 @@
+import axios from '@nextcloud/axios'
+import { Folder } from '../../../../src/types/Folder'
+import { AppState } from '../../../../src/store'
+import { FOLDER_ACTION_TYPES, FOLDER_MUTATION_TYPES, mutations, actions } from '../../../../src/store/folder'
+
+jest.mock('@nextcloud/axios')
+
+describe('folder.ts', () => {
+ 'use strict'
+
+ describe('actions', () => {
+ it('FETCH_FOLDERS', () => {
+ // TODO
+ })
+
+ it('ADD_FOLDERS should send POST and then commit the folders returned', async () => {
+ (axios.post as any).mockResolvedValue({ data: { folders: [] } })
+
+ const folder = {} as Folder
+ const commit = jest.fn()
+ await actions[FOLDER_ACTION_TYPES.ADD_FOLDERS]({ commit }, { folder })
+ expect(axios.post).toBeCalled()
+ expect(commit).toBeCalled()
+ })
+
+ it('DELETE_FOLDER', () => {
+ // TODO
+ })
+ })
+
+ describe('mutations', () => {
+ it('SET_FOLDERS', () => {
+ const state = { folders: [] as Folder[] } as AppState
+ const folders = [] as Folder[]
+ (mutations[FOLDER_MUTATION_TYPES.SET_FOLDERS] as any)(state, folders)
+
+ expect(state.folders.length).toEqual(0)
+ })
+
+ it('DELETE_FOLDER', () => {
+ // TODO
+ })
+ })
+})