-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0fc3d7
commit 2543c5f
Showing
13 changed files
with
695 additions
and
9 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
packages/web-app-files/tests/unit/components/SideBar/Details/SpaceDetails.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { createLocalVue, shallowMount } from '@vue/test-utils' | ||
import Vuex from 'vuex' | ||
import SpaceDetails from '../../../../../src/components/SideBar/Details/SpaceDetails.vue' | ||
import stubs from '../../../../../../../tests/unit/stubs' | ||
import GetTextPlugin from 'vue-gettext' | ||
import AsyncComputed from 'vue-async-computed' | ||
import VueCompositionAPI from '@vue/composition-api/dist/vue-composition-api' | ||
|
||
const localVue = createLocalVue() | ||
localVue.use(Vuex) | ||
localVue.use(AsyncComputed) | ||
localVue.use(VueCompositionAPI) | ||
localVue.use(GetTextPlugin, { | ||
translations: 'does-not-matter.json', | ||
silent: true | ||
}) | ||
const OcTooltip = jest.fn() | ||
|
||
const spaceMock = { | ||
type: 'space', | ||
name: ' space', | ||
id: '1', | ||
mdate: 'Wed, 21 Oct 2015 07:28:00 GMT', | ||
spaceQuota: { | ||
used: 100, | ||
total: 1000 | ||
} | ||
} | ||
|
||
const formDateFromJSDate = jest.fn().mockImplementation(() => 'ABSOLUTE_TIME') | ||
const formDateFromHTTP = jest.fn().mockImplementation(() => 'ABSOLUTE_TIME') | ||
const refreshShareDetailsTree = jest.fn() | ||
beforeEach(() => { | ||
formDateFromJSDate.mockClear() | ||
formDateFromHTTP.mockClear() | ||
refreshShareDetailsTree.mockReset() | ||
}) | ||
|
||
describe('Details SideBar Panel', () => { | ||
it('displayes the details side panel', () => { | ||
const wrapper = createWrapper(spaceMock) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
function createWrapper(spaceResource) { | ||
const component = { | ||
...SpaceDetails, | ||
setup: () => ({ | ||
spaceImage: '', | ||
owners: [], | ||
loadImageTask: { | ||
isRunning: false, | ||
perform: jest.fn() | ||
}, | ||
loadOwnersTask: { | ||
isRunning: false, | ||
perform: jest.fn() | ||
} | ||
}) | ||
} | ||
return shallowMount(component, { | ||
store: new Vuex.Store({ | ||
getters: { | ||
user: function () { | ||
return { id: 'marie' } | ||
} | ||
}, | ||
modules: { | ||
Files: { | ||
namespaced: true, | ||
state: { | ||
sharesTree: {} | ||
}, | ||
getters: { | ||
highlightedFile: function () { | ||
return spaceResource | ||
} | ||
} | ||
} | ||
} | ||
}), | ||
localVue, | ||
stubs: stubs, | ||
directives: { | ||
OcTooltip | ||
}, | ||
mixins: [ | ||
{ | ||
methods: { | ||
formDateFromJSDate, | ||
formDateFromHTTP | ||
} | ||
} | ||
], | ||
provide: { | ||
displayedItem: { | ||
value: spaceResource | ||
} | ||
} | ||
}) | ||
} |
30 changes: 30 additions & 0 deletions
30
...b-app-files/tests/unit/components/SideBar/Details/__snapshots__/SpaceDetails.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Details SideBar Panel displayes the details side panel 1`] = ` | ||
<div id="oc-space-details-sidebar"> | ||
<div class="oc-space-details-sidebar-image oc-text-center"> | ||
<oc-icon-stub name="layout-grid" size="xxlarge" class="space-default-image oc-px-m oc-py-m"></oc-icon-stub> | ||
</div> | ||
<!----> | ||
<div> | ||
<table aria-label="Overview of the information about the selected space" class="details-table"> | ||
<tr> | ||
<th scope="col" class="oc-pr-s">Last activity</th> | ||
<td>Invalid DateTime</td> | ||
</tr> | ||
<!----> | ||
<tr> | ||
<th scope="col" class="oc-pr-s">Manager</th> | ||
<td><span></span></td> | ||
</tr> | ||
<tr> | ||
<th scope="col" class="oc-pr-s">Quota</th> | ||
<td> | ||
<p class="oc-mb-s oc-mt-rm">10.00 % full (100 B of 1 kB used)</p> | ||
<oc-progress-stub value="10" max="100" size="small" variation="primary"></oc-progress-stub> | ||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</div> | ||
`; |
106 changes: 106 additions & 0 deletions
106
packages/web-app-files/tests/unit/components/SideBar/SpaceInfo.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { shallowMount, createLocalVue } from '@vue/test-utils' | ||
import Vuex from 'vuex' | ||
import GetTextPlugin from 'vue-gettext' | ||
import AsyncComputed from 'vue-async-computed' | ||
|
||
import stubs from '@/tests/unit/stubs' | ||
|
||
import SpaceInfo from '@files/src/components/SideBar/SpaceInfo.vue' | ||
|
||
const spaceMock = { | ||
type: 'space', | ||
name: ' space', | ||
id: '1', | ||
mdate: 'Wed, 21 Oct 2015 07:28:00 GMT', | ||
spaceQuota: { | ||
used: 100 | ||
} | ||
} | ||
|
||
const localVue = createLocalVue() | ||
localVue.use(Vuex) | ||
localVue.use(AsyncComputed) | ||
localVue.use(GetTextPlugin, { | ||
translations: 'does-not-matter.json', | ||
silent: true | ||
}) | ||
|
||
const selectors = { | ||
name: '[data-testid="space-info-name"]', | ||
subtitle: '[data-testid="space-info-subtitle"]' | ||
} | ||
|
||
const formDateFromRFC = jest.fn() | ||
const formRelativeDateFromRFC = jest.fn() | ||
const resetDateMocks = () => { | ||
formDateFromRFC.mockReset() | ||
formRelativeDateFromRFC.mockReset() | ||
formDateFromRFC.mockImplementation(() => 'ABSOLUTE_TIME') | ||
formRelativeDateFromRFC.mockImplementation(() => 'RELATIVE_TIME') | ||
} | ||
|
||
describe('SpaceInfo', () => { | ||
it('shows space info', () => { | ||
resetDateMocks() | ||
|
||
const wrapper = createWrapper(spaceMock) | ||
expect(wrapper.find(selectors.name).exists()).toBeTruthy() | ||
expect(wrapper.find(selectors.subtitle).exists()).toBeTruthy() | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
function createWrapper(spaceResource) { | ||
return shallowMount(SpaceInfo, { | ||
store: new Vuex.Store({ | ||
getters: { | ||
user: function () { | ||
return { id: 'marie' } | ||
}, | ||
capabilities: jest.fn(() => ({})) | ||
}, | ||
modules: { | ||
Files: { | ||
namespaced: true, | ||
getters: { | ||
highlightedFile: function () { | ||
return spaceResource | ||
} | ||
} | ||
} | ||
} | ||
}), | ||
localVue, | ||
stubs: { | ||
...stubs, | ||
'oc-resource-icon': true, | ||
'oc-resource-name': true | ||
}, | ||
directives: { | ||
OcTooltip: null | ||
}, | ||
mixins: [ | ||
{ | ||
methods: { | ||
formDateFromRFC, | ||
formRelativeDateFromRFC | ||
} | ||
} | ||
], | ||
mocks: { | ||
$router: { | ||
currentRoute: { | ||
name: 'some-route', | ||
query: { page: 1 } | ||
}, | ||
resolve: (r) => ({ href: r.name }) | ||
}, | ||
publicPage: () => false | ||
}, | ||
provide: { | ||
displayedItem: { | ||
value: spaceResource | ||
} | ||
} | ||
}) | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/web-app-files/tests/unit/components/SideBar/__snapshots__/SpaceInfo.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`SpaceInfo shows space info 1`] = ` | ||
<div class="space_info"> | ||
<div class="space_info__body oc-text-overflow oc-flex oc-flex-middle"> | ||
<div class="oc-mr-s"> | ||
<oc-icon-stub name="layout-grid" size="large" class="oc-display-block"></oc-icon-stub> | ||
</div> | ||
<div> | ||
<h3 data-testid="space-info-name"> space</h3> <span data-testid="space-info-subtitle"></span> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.