-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(getIconUrl): Add appData to getIconUrl
CozyClient v27.19.1 is bound in order to get icon url mechanism working
- Loading branch information
1 parent
b14fb86
commit ffb568c
Showing
6 changed files
with
105 additions
and
13 deletions.
There are no files selected for viewing
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
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
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
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
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,50 @@ | ||
import React from 'react' | ||
import { fireEvent, render } from '@testing-library/react' | ||
import CipherIcon from './index' | ||
|
||
jest.mock('cozy-client', () => ({ | ||
withClient: Component => { | ||
const client = { | ||
stackClient: { | ||
getIconURL: ({ type, appData }) => { | ||
console.log('getIconUrl called with:') | ||
console.log(type) | ||
console.log(appData) | ||
} | ||
} | ||
} | ||
return konnector => ( | ||
<Component client={client} konnector={{ ...konnector }} /> | ||
) | ||
} | ||
})) | ||
|
||
jest.mock('../AppIcon', () => ({ fetchIcon }) => ( | ||
<button data-testid="app-icon" onClick={fetchIcon}></button> | ||
)) | ||
|
||
describe('CipherIcon', () => { | ||
it('should provide appData to getIconUrl in order to get icon simply, when oauth not needed', () => { | ||
// Given | ||
jest.spyOn(console, 'log').mockImplementation() | ||
const konnector = { | ||
name: 'PropTypes.string', | ||
slug: 'slug', | ||
links: { | ||
icon: 'icon url' | ||
}, | ||
latest_version: { | ||
version: 'version' | ||
} | ||
} | ||
const { getByTestId } = render(<CipherIcon konnector={konnector} />) | ||
|
||
// When | ||
fireEvent.click(getByTestId('app-icon')) | ||
|
||
// Then | ||
expect(console.log).toHaveBeenNthCalledWith(1, 'getIconUrl called with:') | ||
expect(console.log).toHaveBeenNthCalledWith(2, 'konnector') | ||
expect(console.log).toHaveBeenNthCalledWith(3, { konnector }) | ||
}) | ||
}) |
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