Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAndBear committed Aug 7, 2024
1 parent 2c11012 commit b730849
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defaultComponentMocks, defaultPlugins, mount } from 'web-test-helpers'
import { defaultComponentMocks, defaultPlugins, mount, RouteLocation } from 'web-test-helpers'
import ResourceTiles from '../../../../src/components/FilesList/ResourceTiles.vue'
import { sortFields } from '../../../../src/helpers/ui/resourceTiles'
import { Resource, ResourceIndicator, SpaceResource } from '@ownclouders/web-client'
Expand All @@ -25,6 +25,13 @@ vi.mock('../../../../src/composables/resources', async (importOriginal) => ({
useCanBeOpenedWithSecureView: vi.fn()
}))

vi.mock('../../../../src/composables/actions/files', async (importOriginal) => ({
...(await importOriginal<any>()),
useFileActions: vi.fn().mockReturnValue({
getDefaultAction: vi.fn().mockReturnValue({ handler: vi.fn() })
})
}))

const spacesResources = [
{
id: '1',
Expand Down Expand Up @@ -68,7 +75,7 @@ const resources = [
}
]

describe.skip('ResourceTiles component', () => {
describe('ResourceTiles component', () => {
const originalGetElementById = document.getElementById
const originalGetComputedStyle = window.getComputedStyle
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,78 @@ exports[`ResourceTiles component > renders a footer slot 1`] = `
<div data-v-67d39700="" class="oc-tiles-footer">Hello, ResourceTiles footer!</div>
</div>"
`;

exports[`ResourceTiles component > renders an array of spaces correctly 1`] = `
"<div data-v-67d39700="" id="tiles-view" class="oc-px-m oc-pt-l">
<!--v-if-->
<ul data-v-67d39700="" class="oc-list oc-my-rm oc-mx-rm oc-tiles oc-flex">
<li data-v-67d39700="" class="oc-tiles-item has-item-context-menu">
<div data-v-67d39700="" class="oc-tile-card oc-card oc-card-default oc-rounded" data-item-id="1" draggable="false"><a target="_self" draggable="false" class="oc-card-media-top oc-flex oc-flex-center oc-flex-middle oc-m-rm" tabindex="-1" attrs="[object Object]"></a>
<div class="oc-card-body oc-p-s">
<div class="oc-flex oc-flex-between oc-flex-middle">
<div class="oc-flex oc-flex-middle oc-text-truncate resource-name-wrapper">
<div class="oc-resource oc-text-overflow">
<!--v-if-->
<div class="oc-resource-details oc-text-overflow"><a target="_self" draggable="false" class="oc-text-overflow" attrs="[object Object]"></a>
<div class="oc-resource-indicators">
<!--v-if-->
</div>
</div>
</div>
</div>
<div class="oc-flex oc-flex-middle">
<!-- Slot for indicators !-->
<!-- Slot for individual actions -->
<!-- Slot for contextmenu --> <button data-v-67d39700="" type="button" aria-label="Show context menu" class="oc-button oc-rounded oc-button-m oc-button-justify-content-center oc-button-gap-m oc-button-passive oc-button-passive-raw resource-tiles-btn-action-dropdown" id="context-menu-trigger-1">
<!--v-if-->
<!-- @slot Content of the button --> <span class="oc-icon oc-icon-m oc-icon-passive"><!----></span>
<div id="context-menu-drop-1" class="oc-drop oc-box-shadow-medium oc-rounded oc-overflow-hidden">
<div class="oc-card oc-card-body oc-background-secondary oc-p-s"></div>
</div>
</button>
</div>
</div>
<!--v-if-->
</div>
</div>
</li>
<li data-v-67d39700="" class="oc-tiles-item has-item-context-menu">
<div data-v-67d39700="" class="oc-tile-card oc-card oc-card-default oc-rounded" data-item-id="2" draggable="false"><a target="_self" draggable="false" class="oc-card-media-top oc-flex oc-flex-center oc-flex-middle oc-m-rm" tabindex="-1" attrs="[object Object]"></a>
<div class="oc-card-body oc-p-s">
<div class="oc-flex oc-flex-between oc-flex-middle">
<div class="oc-flex oc-flex-middle oc-text-truncate resource-name-wrapper">
<div class="oc-resource oc-text-overflow">
<!--v-if-->
<div class="oc-resource-details oc-text-overflow"><a target="_self" draggable="false" class="oc-text-overflow" attrs="[object Object]"></a>
<div class="oc-resource-indicators">
<!--v-if-->
</div>
</div>
</div>
</div>
<div class="oc-flex oc-flex-middle">
<!-- Slot for indicators !-->
<!-- Slot for individual actions -->
<!-- Slot for contextmenu --> <button data-v-67d39700="" type="button" aria-label="Show context menu" class="oc-button oc-rounded oc-button-m oc-button-justify-content-center oc-button-gap-m oc-button-passive oc-button-passive-raw resource-tiles-btn-action-dropdown" id="context-menu-trigger-2">
<!--v-if-->
<!-- @slot Content of the button --> <span class="oc-icon oc-icon-m oc-icon-passive"><!----></span>
<div id="context-menu-drop-2" class="oc-drop oc-box-shadow-medium oc-rounded oc-overflow-hidden">
<div class="oc-card oc-card-body oc-background-secondary oc-p-s"></div>
</div>
</button>
</div>
</div>
<!--v-if-->
</div>
</div>
</li>
<li data-v-67d39700="" class="ghost-tile" aria-hidden="true"></li>
<li data-v-67d39700="" class="ghost-tile" aria-hidden="true"></li>
<li data-v-67d39700="" class="ghost-tile" aria-hidden="true"></li>
<li data-v-67d39700="" class="ghost-tile" aria-hidden="true"></li>
<li data-v-67d39700="" class="ghost-tile" aria-hidden="true"></li>
</ul>
<!--v-if-->
<div data-v-67d39700="" class="oc-tiles-footer"></div>
</div>"
`;

0 comments on commit b730849

Please sign in to comment.