From f65769868bb826d4525025e92ab329f03f1c4962 Mon Sep 17 00:00:00 2001 From: Devlin Junker Date: Tue, 29 Nov 2022 00:53:36 -1000 Subject: working unit test for local computed state Signed-off-by: Devlin Junker --- tests/javascript/unit/components/Sidebar.spec.ts | 27 +++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/javascript/unit/components/Sidebar.spec.ts b/tests/javascript/unit/components/Sidebar.spec.ts index 5690aac08..c85bcd960 100644 --- a/tests/javascript/unit/components/Sidebar.spec.ts +++ b/tests/javascript/unit/components/Sidebar.spec.ts @@ -17,11 +17,12 @@ describe('Sidebar.vue', () => { state: { feeds: [], folders: [] - } + }, + dispatch: jest.fn() } } }) - wrapper.vm.$store.dispatch = jest.fn(); + // wrapper.vm.$store. }) it('should initialize without showing AddFeed Component', () => { @@ -51,15 +52,25 @@ describe('Sidebar.vue', () => { expect(wrapper.vm.$data.showAddFeed).toBeFalsy }) + // TODO: A couple more tests here + it('should return top level nav (folders and feeds without folders)', () => { + let topLevelNav = (wrapper.vm.$options.computed?.topLevelNav as any).call({ $store: { + getters: { + feeds: [], + folders: [] + } + }}) + + expect(topLevelNav).toEqual([]) + }) + + // TODO: More Template Testing with https://test-utils.vuejs.org/guide/essentials/a-crash-course.html#adding-a-new-todo + afterEach(() => { - jest.clearAllMocks(); + jest.clearAllMocks() }); describe('SideBar State', () => { - // it('should return top level nav (folders and feeds without folders)', () => { - // const navItems = (wrapper.vm.$options?.computed?.topLevelNav as any)({ feeds: [], folders: [] }); - - // console.log(navItems) - // }) + }) }) -- cgit v1.2.3