summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDevlin Junker <devlin.junker@gmail.com>2022-12-03 14:34:26 -0800
committerBenjamin Brahmer <info@b-brahmer.de>2022-12-06 14:57:20 +0100
commit4899be32e3f6065297f95e0ccc42e97efbec545b (patch)
tree4da83df9abc2e5539f9f941d83dc7e01c12b4056 /tests
parent8131604192d06ecbf8f19a039a3f497d5e12918e (diff)
add more tests
Signed-off-by: Devlin Junker <devlin.junker@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/javascript/unit/components/Sidebar.spec.ts117
-rw-r--r--tests/javascript/unit/setup.ts2
2 files changed, 91 insertions, 28 deletions
diff --git a/tests/javascript/unit/components/Sidebar.spec.ts b/tests/javascript/unit/components/Sidebar.spec.ts
index 42f826eb8..16affbb3d 100644
--- a/tests/javascript/unit/components/Sidebar.spec.ts
+++ b/tests/javascript/unit/components/Sidebar.spec.ts
@@ -29,41 +29,104 @@ describe('Sidebar.vue', () => {
expect((wrapper.vm as any).$data.showAddFeed).toBeFalsy()
})
- it('should dispatch message to store with folder name to create new folder', () => {
- (wrapper.vm as any).newFolder('abc')
+ describe('User Actions', () => {
+ it('should dispatch message to store with folder name to create new folder', () => {
+ (wrapper.vm as any).newFolder('abc')
- expect((wrapper.vm as any).$store.dispatch).toHaveBeenCalledWith(ACTIONS.ADD_FOLDERS, { folder: { name: 'abc' } })
- })
+ expect((wrapper.vm as any).$store.dispatch).toHaveBeenCalledWith(ACTIONS.ADD_FOLDERS, { 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', () => {
+ const folder = {};
+ (wrapper.vm as any).deleteFolder(folder)
- expect((wrapper.vm as any).$store.dispatch).toHaveBeenCalledWith(ACTIONS.DELETE_FOLDER, { folder })
- })
+ expect((wrapper.vm as any).$store.dispatch).toHaveBeenCalledWith(ACTIONS.DELETE_FOLDER, { folder })
+ })
- it('should set showAddFeed to true', () => {
- (wrapper.vm as any).showShowAddFeed()
- expect(wrapper.vm.$data.showAddFeed).toBeTruthy()
- })
+ it('should set showAddFeed to true', () => {
+ (wrapper.vm as any).showShowAddFeed()
+ expect(wrapper.vm.$data.showAddFeed).toBeTruthy()
+ })
- it('should set showAddFeed to false', () => {
- (wrapper.vm as any).closeShowAddFeed()
- expect(wrapper.vm.$data.showAddFeed).toBeFalsy()
+ it('should set showAddFeed to false', () => {
+ (wrapper.vm as any).closeShowAddFeed()
+ expect(wrapper.vm.$data.showAddFeed).toBeFalsy()
+ })
})
- // TODO: A couple more tests here
- it('should return top level nav (folders and feeds without folders)', () => {
- const topLevelNav = (wrapper.vm.$options.computed?.topLevelNav as any).call({
- $store: {
- getters: {
- feeds: [],
- folders: [],
+ describe('SideBarState', () => {
+ it('should return no top level nav when no folders or feeds', () => {
+ const topLevelNav = (wrapper.vm.$options.computed?.topLevelNav as any).call({
+ $store: {
+ getters: {
+ feeds: [],
+ folders: [],
+ },
},
- },
+ })
+
+ expect(topLevelNav).toEqual([])
+ })
+
+ it('should return top level nav with 1 feed', () => {
+ const feeds: any[] = [{ name: 'feed1', id: 1 }]
+ const folders: any[] = []
+ const topLevelNav = (wrapper.vm.$options.computed?.topLevelNav as any).call({
+ $store: {
+ getters: {
+ feeds,
+ folders,
+ },
+ },
+ })
+
+ expect(topLevelNav).toEqual([feeds[0]])
})
- expect(topLevelNav).toEqual([])
+ it('should return top level nav with 1 folder (with feeds)', () => {
+ const feeds: any[] = [{ name: 'feed2', id: 2, folderId: 123 }]
+ const folders: any[] = [{ name: 'abc', id: 123 }]
+ const topLevelNav = (wrapper.vm.$options.computed?.topLevelNav as any).call({
+ $store: {
+ getters: {
+ feeds,
+ folders,
+ },
+ },
+ })
+
+ expect(topLevelNav).toEqual(folders)
+ })
+
+ it('should return top level nav with 1 folder (without feed)', () => {
+ const feeds: any[] = [{ name: 'feed1', id: 1 }]
+ const folders: any[] = [{ name: 'abc', id: 123 }]
+ const topLevelNav = (wrapper.vm.$options.computed?.topLevelNav as any).call({
+ $store: {
+ getters: {
+ feeds,
+ folders,
+ },
+ },
+ })
+
+ expect(topLevelNav).toEqual([feeds[0], ...folders])
+ })
+
+ it('should return top level nav with feeds and folders', () => {
+ const feeds: any[] = [{ name: 'feed1', id: 1 }, { name: 'feed2', id: 2, folderId: 123 }]
+ const folders: any[] = [{ name: 'abc', id: 123 }, { name: 'xyz', id: 234 }]
+ const topLevelNav = (wrapper.vm.$options.computed?.topLevelNav as any).call({
+ $store: {
+ getters: {
+ feeds,
+ folders,
+ },
+ },
+ })
+
+ expect(topLevelNav).toEqual([feeds[0], ...folders])
+ })
})
// TODO: More Template Testing with https://test-utils.vuejs.org/guide/essentials/a-crash-course.html#adding-a-new-todo
@@ -72,7 +135,7 @@ describe('Sidebar.vue', () => {
jest.clearAllMocks()
})
- describe('SideBar State', () => {
- // TODO
+ afterEach(() => {
+ jest.clearAllMocks()
})
})
diff --git a/tests/javascript/unit/setup.ts b/tests/javascript/unit/setup.ts
index f3b734953..380436f8c 100644
--- a/tests/javascript/unit/setup.ts
+++ b/tests/javascript/unit/setup.ts
@@ -16,5 +16,5 @@ config.mocks.$n = function(app: any, singular: any, plural: any, count: any) {
config.mocks.n = config.mocks.$n
afterAll(() => {
-
+ // TODO: ?
})