summaryrefslogtreecommitdiffstats
path: root/tests/javascript/unit/components/App.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/javascript/unit/components/App.spec.ts')
-rw-r--r--tests/javascript/unit/components/App.spec.ts49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/javascript/unit/components/App.spec.ts b/tests/javascript/unit/components/App.spec.ts
new file mode 100644
index 000000000..135b41d40
--- /dev/null
+++ b/tests/javascript/unit/components/App.spec.ts
@@ -0,0 +1,49 @@
+import { shallowMount, createLocalVue, Wrapper } from '@vue/test-utils'
+
+import App from '../../../../src/App.vue'
+import { MUTATIONS } from '../../../../src/store'
+
+describe('FeedItemDisplay.vue', () => {
+ 'use strict'
+ const localVue = createLocalVue()
+ let wrapper: Wrapper<App>
+
+ const dispatchStub = jest.fn()
+ const commitStub = jest.fn()
+ beforeAll(() => {
+ wrapper = shallowMount(App, {
+ localVue,
+ mocks: {
+ $store: {
+ state: {
+ items: {
+ playingItem: undefined,
+ },
+ },
+ dispatch: dispatchStub,
+ commit: commitStub,
+ },
+ },
+ })
+ })
+
+ beforeEach(() => {
+ dispatchStub.mockReset()
+ commitStub.mockReset()
+ })
+
+ it('should send SET_PLAYING_ITEM with undefined to stop playback', () => {
+ (wrapper.vm as any).stopPlaying()
+
+ expect(commitStub).toBeCalledWith(MUTATIONS.SET_PLAYING_ITEM, undefined)
+ })
+
+ it('should stop all video elements in page when playing video', () => {
+ const pauseStub = jest.fn()
+ document.getElementsByTagName = jest.fn().mockReturnValue([{ pause: pauseStub }]);
+
+ (wrapper.vm as any).stopVideo()
+
+ expect(pauseStub).toBeCalled()
+ })
+})