Skip to content

Commit

Permalink
address reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
saw-jan committed Oct 28, 2021
1 parent 680d1f6 commit f54dea3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
27 changes: 10 additions & 17 deletions packages/web-app-files/tests/unit/views/SharedViaLink.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { shallowMount, mount } from '@vue/test-utils'
import flushPromises from 'flush-promises'
import { getStore, localVue, createFile } from './views.setup.js'
import MixinFilesListPagination from '@files/src/mixins/filesListPagination'
import FileActions from '@files/src/mixins/fileActions'
import MixinFilesListPositioning from '@files/src/mixins/filesListPositioning'
import SharedViaLink from '@files/src/views/SharedViaLink.vue'

const $route = {
Expand Down Expand Up @@ -48,17 +51,14 @@ const selectors = {

describe('SharedViaLink view', () => {
jest
.spyOn(SharedViaLink.mixins[3].methods, '$_filesListPagination_updateCurrentPage')
.spyOn(MixinFilesListPagination.methods, '$_filesListPagination_updateCurrentPage')
.mockImplementation()
const spyAdjustTableHeaderPosition = jest.spyOn(
SharedViaLink.mixins[1].methods,
MixinFilesListPositioning.methods,
'adjustTableHeaderPosition'
)
const spyShowDefaultPanel = jest
.spyOn(SharedViaLink.mixins[4].methods, '$_mountSideBar_showDefaultPanel')
.mockImplementation()
const spyTriggerDefaultAction = jest
.spyOn(SharedViaLink.mixins[0].methods, '$_fileActions_triggerDefaultAction')
.spyOn(FileActions.methods, '$_fileActions_triggerDefaultAction')
.mockImplementation()
const spyLoadResources = jest.spyOn(SharedViaLink.methods, 'loadResources')
const spyRowMounted = jest.spyOn(SharedViaLink.methods, 'rowMounted')
Expand All @@ -84,8 +84,10 @@ describe('SharedViaLink view', () => {
describe('when the view is still loading', () => {
it('should show list-loader component', () => {
const wrapper = getShallowWrapper()
const listLoader = wrapper.find(selectors.listLoader)

expect(wrapper.find(selectors.listLoader).exists()).toBeTruthy()
expect(listLoader.exists()).toBeTruthy()
expect(wrapper).toMatchSnapshot()
})
})

Expand All @@ -109,7 +111,7 @@ describe('SharedViaLink view', () => {
const noContentMessage = wrapper.find(selectors.noContentMessage)

expect(noContentMessage.exists()).toBeTruthy()
expect(noContentMessage).toMatchSnapshot()
expect(wrapper).toMatchSnapshot()
})
it('should not show oc-table-files component', () => {
expect(wrapper.find(selectors.ocTableFiles).exists()).toBeFalsy()
Expand Down Expand Up @@ -147,15 +149,6 @@ describe('SharedViaLink view', () => {
expect(listInfo.props().files).toEqual(activeFiles.length)
expect(listInfo.props().folders).toEqual(0)
})
it('should trigger showing the sidebar when a "showDetails" event gets emitted', () => {
const ocTableFiles = wrapper.find(selectors.ocTableFiles)

expect(spyShowDefaultPanel).toHaveBeenCalledTimes(0)

ocTableFiles.vm.$emit('showDetails')

expect(spyShowDefaultPanel).toHaveBeenCalledTimes(1)
})
it('should trigger the default action when a "fileClick" event gets emitted', () => {
const ocTableFiles = wrapper.find(selectors.ocTableFiles)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`SharedViaLink view when the view is not loading anymore when there are no files to be displayed should show no-content-message component 1`] = `
<div class="uk-height-1-1 uk-flex uk-flex-column uk-flex-center uk-flex-middle uk-text-center files-empty" id="files-shared-via-link-empty">
<div class="oc-icon oc-icon-xxl oc-icon-passive"><svg viewBox="0 0 24 24" height="24" width="24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
<path xmlns="http://www.w3.org/2000/svg" d="M0 0h24v24H0z" fill="none"></path>
<path xmlns="http://www.w3.org/2000/svg" d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"></path>
</svg></div>
<div class="oc-text-muted uk-text-large"><span data-msgid="There are no resources with a public link at the moment" data-current-language="en_US">There are no resources with a public link at the moment</span></div>
<div class="oc-text-muted"></div>
<div>
<div class="uk-height-1-1 uk-flex uk-flex-column uk-flex-center uk-flex-middle uk-text-center files-empty" id="files-shared-via-link-empty">
<div class="oc-icon oc-icon-xxl oc-icon-passive"><svg viewBox="0 0 24 24" height="24" width="24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
<path xmlns="http://www.w3.org/2000/svg" d="M0 0h24v24H0z" fill="none"></path>
<path xmlns="http://www.w3.org/2000/svg" d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"></path>
</svg></div>
<div class="oc-text-muted uk-text-large"><span data-msgid="There are no resources with a public link at the moment" data-current-language="en_US">There are no resources with a public link at the moment</span></div>
<div class="oc-text-muted"></div>
</div>
</div>
`;

exports[`SharedViaLink view when the view is still loading should show list-loader component 1`] = `
<div>
<list-loader-stub></list-loader-stub>
</div>
`;

0 comments on commit f54dea3

Please sign in to comment.