Skip to content

Commit

Permalink
Remove translation mocks from defaultComponentMocks
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Jan 18, 2023
1 parent 17550ac commit 656628e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ function getWrapper({ propsData = {} } = {}) {
},
mocks: {
...defaultComponentMocks({
gettext: false,
currentRoute: mock<RouteLocation>({ query: { app: 'admin-settings' } })
})
}
Expand Down
1 change: 0 additions & 1 deletion packages/web-app-external/tests/unit/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ function createShallowMountWrapper(makeRequest = jest.fn().mockResolvedValue({ s
stubs: componentStubs,
mocks: {
...defaultComponentMocks({
gettext: false,
currentRoute: mock<RouteLocation>({ query: { app: 'exampleApp' } })
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ function getShallowWrapper(
}
) {
const mocks = defaultComponentMocks({
gettext: false,
currentRoute: mock<RouteLocation>({ name: 'files-trash-generic' })
})
mocks.$route.meta.title = 'ExampleTitle'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports[`Collaborator ListItem component share inheritance indicators show when
<div class="oc-pl-s oc-text-truncate">
<div class="oc-text-truncate">
<span aria-hidden="true" class="files-collaborators-collaborator-name">Brian Murphy</span>
<span class="oc-invisible-sr">Share receiver name: %{ displayName } (%{ additionalInfo })</span>
<span class="oc-invisible-sr">Share receiver name: Brian Murphy ([email protected])</span>
</div>
<div>
<div class="oc-flex oc-flex-nowrap oc-flex-middle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,23 @@ describe('rename', () => {
{
currentName: 'currentName',
newName: 'file1',
message: 'The name "%{name}" is already taken'
message: 'The name "file1" is already taken'
},
{
currentName: 'currentName',
newName: 'newname',
parentResources: [{ name: 'newname', path: '/newname' }],
message: 'The name "%{name}" is already taken'
message: 'The name "newname" is already taken'
}
])('should detect name errors and display error messages accordingly', (inputData) => {
const { mocks, wrapper } = getWrapper()
const { wrapper } = getWrapper()
const errorModalSpy = jest.spyOn(wrapper.vm, 'setModalInputErrorMessage')
wrapper.vm.$_rename_checkNewName(
{ name: inputData.currentName, path: `/${inputData.currentName}` },
inputData.newName,
inputData.parentResources
)
expect(mocks.$gettext).toHaveBeenCalledWith(inputData.message)
expect(errorModalSpy).toHaveBeenCalledWith(inputData.message)
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ function getShallowWrapper({
inFinalization = false
} = {}) {
const mocks = {
...defaultComponentMocks({ gettext: false })
...defaultComponentMocks()
}
const storeOptions = {
...defaultStoreMockOptions
Expand Down
14 changes: 2 additions & 12 deletions packages/web-test-helpers/src/mocks/defaultComponentMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ import { OwnCloudSdk } from 'web-client/src/types'
import { ref } from 'vue'

export interface ComponentMocksOptions {
gettext?: boolean
currentRoute?: RouteLocation
}

export const defaultComponentMocks = ({
gettext = true,
currentRoute = undefined
}: ComponentMocksOptions = {}) => {
export const defaultComponentMocks = ({ currentRoute = undefined }: ComponentMocksOptions = {}) => {
const $router = mockDeep<Router>({ ...(currentRoute && { currentRoute: ref(currentRoute) }) })
$router.resolve.mockImplementation(
(to: RouteLocationRaw) => ({ href: (to as any).name, location: { path: '' } } as any)
Expand All @@ -26,12 +22,6 @@ export const defaultComponentMocks = ({
$route,
$clientService: mockDeep<ClientService>(),
$client: mockDeep<OwnCloudSdk>(),
$uppyService: mockDeep<UppyService>(),
...(gettext && {
$gettextInterpolate: jest.fn((text) => text),
$ngettext: jest.fn((text) => text),
$pgettext: jest.fn((text) => text),
$gettext: jest.fn((text) => text)
})
$uppyService: mockDeep<UppyService>()
}
}

0 comments on commit 656628e

Please sign in to comment.