From 991facf2ee638713d2f2ef8b5197f32742d01804 Mon Sep 17 00:00:00 2001 From: Devlin Junker Date: Thu, 5 Oct 2023 10:27:26 -0700 Subject: tests and some cleanup Signed-off-by: Devlin Junker --- tests/javascript/unit/components/App.spec.ts | 9 ++++++++ .../feed-display/FeedItemDisplay.spec.ts | 7 ------ tests/javascript/unit/store/app.spec.ts | 26 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 tests/javascript/unit/store/app.spec.ts (limited to 'tests') diff --git a/tests/javascript/unit/components/App.spec.ts b/tests/javascript/unit/components/App.spec.ts index 135b41d40..f1c4096b9 100644 --- a/tests/javascript/unit/components/App.spec.ts +++ b/tests/javascript/unit/components/App.spec.ts @@ -19,6 +19,9 @@ describe('FeedItemDisplay.vue', () => { items: { playingItem: undefined, }, + app: { + error: undefined, + }, }, dispatch: dispatchStub, commit: commitStub, @@ -46,4 +49,10 @@ describe('FeedItemDisplay.vue', () => { expect(pauseStub).toBeCalled() }) + + it('should remove app state error with commit and undefined', () => { + (wrapper.vm as any).removeError() + + expect(commitStub).toBeCalledWith(MUTATIONS.SET_ERROR, undefined) + }) }) diff --git a/tests/javascript/unit/components/feed-display/FeedItemDisplay.spec.ts b/tests/javascript/unit/components/feed-display/FeedItemDisplay.spec.ts index 7d60d4a01..81c171114 100644 --- a/tests/javascript/unit/components/feed-display/FeedItemDisplay.spec.ts +++ b/tests/javascript/unit/components/feed-display/FeedItemDisplay.spec.ts @@ -59,13 +59,6 @@ describe('FeedItemDisplay.vue', () => { expect(formattedDate).toEqual(new Date(epoch).toLocaleString()) }) - it('should format datetime to match international standard', () => { - const epoch = Date.now() // Provide an epoch timestamp - const formattedDate = (wrapper.vm as any).formatDatetime(epoch) - - expect(formattedDate).toEqual(new Date(epoch).toISOString()) - }) - it('should retrieve feed by ID', () => { const feed = (wrapper.vm as any).getFeed(mockFeed.id) diff --git a/tests/javascript/unit/store/app.spec.ts b/tests/javascript/unit/store/app.spec.ts new file mode 100644 index 000000000..a083db3f0 --- /dev/null +++ b/tests/javascript/unit/store/app.spec.ts @@ -0,0 +1,26 @@ +import { AppInfoState, mutations } from '../../../../src/store/app' +import { APPLICATION_MUTATION_TYPES } from '../../../../src/types/MutationTypes' + +jest.mock('@nextcloud/router') + +describe('app.ts', () => { + 'use strict' + + // describe('actions', () => { + + // }) + + describe('mutations', () => { + it('SET_ERROR should update the error in the state', () => { + const state = { error: undefined } as AppInfoState + + const error = { message: 'test err' }; + + (mutations[APPLICATION_MUTATION_TYPES.SET_ERROR] as any)(state, error) + expect(state.error).toEqual(error); + + (mutations[APPLICATION_MUTATION_TYPES.SET_ERROR] as any)(state, undefined) + expect(state.error).toEqual(undefined) + }) + }) +}) -- cgit v1.2.3