Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only] remove language related log outputs in unit-tests #6404

Merged
merged 6 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ describe('LocationPicker', () => {
mountOptions(store, $route, loading, setup, {
'oc-button': false,
'list-info': true,
translate: true,
pagination: true,
RouterLink: RouterLinkStub
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`SharedViaLink view when the view is not loading anymore when there are
<div class="oc-icon oc-icon-xxl oc-icon-passive">
<!---->
</div>
<div class="oc-text-muted oc-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 oc-text-large"><span>There are no resources with a public link at the moment</span></div>
<div class="oc-text-muted"></div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import GetTextPlugin from 'vue-gettext'
import { mount, RouterLinkStub } from '@vue/test-utils'
import { RouterLinkStub, shallowMount } from '@vue/test-utils'
import { localVue } from '../views.setup'
import { createStore } from 'vuex-extensions'
import Files from '@/__fixtures__/files'
Expand Down Expand Up @@ -199,7 +199,7 @@ function getMountedWrapper(spaceResources = [], spaceItem = null) {
}
}

return mount(SpaceProject, {
return shallowMount(SpaceProject, {
localVue,
stubs: {
RouterLink: RouterLinkStub
Expand All @@ -212,8 +212,7 @@ function getMountedWrapper(spaceResources = [], spaceItem = null) {
getFileContents: jest.fn(() => 'fileContent'),
list: jest.fn(() => spaceResources)
}
},
$ngettext: () => 'text'
}
},

store: createStore(Vuex.Store, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ function getMountedWrapper() {
}
}
}
})
}),
stubs: {
translate: true
}
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ exports[`Spaces project view space image should show if given 1`] = `
</div>
</div>
</div>
<div class="oc-height-1-1 oc-flex oc-flex-column oc-flex-center oc-flex-middle oc-text-center files-empty" id="files-space-empty">
<div class="oc-icon oc-icon-xxl oc-icon-passive">
<!---->
</div>
<div class="oc-text-muted oc-text-large">
<p class="oc-text-muted" data-msgid="No resources found" data-current-language="en_US">No resources found</p>
</div>
<div class="oc-text-muted"></div>
</div>
<no-content-message-stub icon="folder" id="files-space-empty" class="files-empty"></no-content-message-stub>
</div>
`;

Expand All @@ -42,14 +34,6 @@ exports[`Spaces project view space readme should show if given 1`] = `
</div>
</div>
</div>
<div class="oc-height-1-1 oc-flex oc-flex-column oc-flex-center oc-flex-middle oc-text-center files-empty" id="files-space-empty">
<div class="oc-icon oc-icon-xxl oc-icon-passive">
<!---->
</div>
<div class="oc-text-muted oc-text-large">
<p class="oc-text-muted" data-msgid="No resources found" data-current-language="en_US">No resources found</p>
</div>
<div class="oc-text-muted"></div>
</div>
<no-content-message-stub icon="folder" id="files-space-empty" class="files-empty"></no-content-message-stub>
</div>
`;
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Spaces component should only list drives of type "project" 1`] = `
<div class="oc-py-s oc-px-m"><button aria-label="Create a new space" class="oc-mb-l oc-button oc-button-m oc-button-justify-content-center oc-button-gap-m oc-button-primary" id="new-space-menu-btn" data-testid="spaces-list-create-space-btn"><span class="oc-icon oc-icon-m oc-icon-passive"><!----></span> <span>Create Space</span></button>
<div class="oc-py-s oc-px-m"><button aria-label="Create a new space" class="oc-mb-l oc-button oc-button-m oc-button-justify-content-center oc-button-gap-m oc-button-primary" id="new-space-menu-btn" data-testid="spaces-list-create-space-btn"><span class="oc-icon oc-icon-m oc-icon-passive"><!----></span>
<translate-stub tag="span">Create Space</translate-stub>
</button>
<div class="oc-pb-xl oc-border-b"><span>Store your project related files in Spaces for seamless collaboration.</span></div>
<div class="spaces-list oc-mt-l">
<ul class="
Expand Down
5 changes: 5 additions & 0 deletions packages/web-app-files/tests/unit/views/views.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ localVue.use(GetTextPlugin, {
silent: true
})

// mock `v-translate` directive
localVue.directive('translate', {
inserted: (el) => {}
})

export const getRouter = ({ query = {} }) => ({
afterEach: jest.fn(),
replace: jest.fn(),
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/config/jest.init.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ try {

config.mocks = {
$gettext: (str) => str,
$pgettext: (context, msgid) => msgid,
$ngettext: (msgid, plural, n) => {
if (n > 1 || n === 0 || n < 0 || !Number.isInteger(n)) {
return plural
} else {
return msgid
}
},
isIE11: () => false,
$language: {
current: 'en'
Expand Down