diff options
author | Devlin Junker <devlin.junker@gmail.com> | 2022-10-26 22:00:02 -0700 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2022-11-02 11:27:20 +0100 |
commit | 431236bbd84fbdcf130100c7d5f861e3d54c5542 (patch) | |
tree | 5d580331ddafb418f3c6811ad09eaa9b93fb902b /tests | |
parent | 182897b4a8ce0a27a5ccae29fb280950ca55c921 (diff) |
more package cleanup and some basic tests for Sidebar
Signed-off-by: Devlin Junker <devlin.junker@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/javascript/unit/components/AddFeed.spec.ts | 5 | ||||
-rw-r--r-- | tests/javascript/unit/components/Explore.spec.ts | 14 | ||||
-rw-r--r-- | tests/javascript/unit/components/Sidebar.spec.ts | 41 |
3 files changed, 41 insertions, 19 deletions
diff --git a/tests/javascript/unit/components/AddFeed.spec.ts b/tests/javascript/unit/components/AddFeed.spec.ts index 224a4287c..a549ffb30 100644 --- a/tests/javascript/unit/components/AddFeed.spec.ts +++ b/tests/javascript/unit/components/AddFeed.spec.ts @@ -1,8 +1,7 @@ -import AddFeed from 'Components/AddFeed.vue' - +import { shallowMount } from '@vue/test-utils' import { store, localVue } from '../setupStore' -import { shallowMount } from '@vue/test-utils' +import AddFeed from 'Components/AddFeed.vue' describe('AddFeed.vue', () => { 'use strict' diff --git a/tests/javascript/unit/components/Explore.spec.ts b/tests/javascript/unit/components/Explore.spec.ts index 0ac31835b..b0fe86a28 100644 --- a/tests/javascript/unit/components/Explore.spec.ts +++ b/tests/javascript/unit/components/Explore.spec.ts @@ -1,18 +1,18 @@ -import Explore from 'Components/Explore.vue' -import sinon from 'sinon'; -import axios from '@nextcloud/axios' -import * as router from '@nextcloud/router' +import { shallowMount } from '@vue/test-utils' import { store, localVue } from '../setupStore' +import axios from '@nextcloud/axios' -import { shallowMount } from '@vue/test-utils' +import * as router from '@nextcloud/router' + +import Explore from 'Components/Explore.vue' describe('Explore.vue', () => { 'use strict' it('should initialize without showing AddFeed Component', () => { - sinon.stub(axios, 'get').resolves({ data: { } }); - sinon.stub(router, 'generateUrl').returns(''); + axios.get = jest.fn().mockResolvedValue({ data: { } }) + (router as any).generateUrl = jest.fn().mockReturnedValue(''); const wrapper = shallowMount(Explore, { localVue, store }) diff --git a/tests/javascript/unit/components/Sidebar.spec.ts b/tests/javascript/unit/components/Sidebar.spec.ts index d71e8bcb2..63b490f0e 100644 --- a/tests/javascript/unit/components/Sidebar.spec.ts +++ b/tests/javascript/unit/components/Sidebar.spec.ts @@ -1,23 +1,46 @@ -import AppSidebar from 'Components/Sidebar.vue' - +import { Wrapper, shallowMount } from '@vue/test-utils' import { store, localVue } from '../setupStore' -import { shallowMount } from '@vue/test-utils' +import AppSidebar from 'Components/Sidebar.vue' describe('Sidebar.vue', () => { 'use strict' - it('should initialize without showing AddFeed Component', () => { - const wrapper = shallowMount(AppSidebar, { localVue, store }) + let wrapper: Wrapper<AppSidebar>; + + beforeAll(() => { + wrapper = shallowMount(AppSidebar, { localVue, store }) + wrapper.vm.$store.dispatch = jest.fn(); + }) + it('should initialize without showing AddFeed Component', () => { expect(wrapper.vm.$data.showAddFeed).toBeFalsy }); - it('should dispatch message to store with folder name to create new folder', () => {}); + it('should dispatch message to store with folder name to create new folder', () => { + (wrapper.vm as any).newFolder('abc') + + expect(wrapper.vm.$store.dispatch).toHaveBeenCalledWith('addFolder', { folder: { name: 'abc'} }) + }); + + it('should dispatch message to store with folder object on delete folder', () => { + const folder = {}; + (wrapper.vm as any).deleteFolder(folder) - it('should dispatch message to store with folder object on delete folder', () => {}) + expect(wrapper.vm.$store.dispatch).toHaveBeenCalledWith('deleteFolder', { folder }) + }) - it('should set showAddFeed to true', () => {}) + it('should set showAddFeed to true', () => { + (wrapper.vm as any).showShowAddFeed() + expect(wrapper.vm.$data.showAddFeed).toBeTruthy + }) - it('should set showAddFeed to false', () => {}) + it('should set showAddFeed to false', () => { + (wrapper.vm as any).closeShowAddFeed() + expect(wrapper.vm.$data.showAddFeed).toBeFalsy + }) + + afterEach(() => { + jest.clearAllMocks(); + }); }) |