-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add tests for @/modules/file * wrap tests with act() where required
- Loading branch information
1 parent
c9ea869
commit 7a48073
Showing
6 changed files
with
74 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import Attachment from '@/modules/file/components/Attachment'; | ||
|
||
const file = { name: 'file.png' }; | ||
const address = '0x0000000000000000000000000000000000000000'; | ||
|
||
const removeFile = jest.fn(); | ||
const setAttachments = jest.fn(() => Promise.resolve()); | ||
|
||
jest.mock('@/modules/file/utils/image', () => ({ | ||
__esModule: true, | ||
readImage: jest.fn(() => Promise.resolve(Buffer.from(''))), | ||
})); | ||
|
||
jest.mock('@/modules/file/utils/ceramic', () => ({ | ||
__esModule: true, | ||
encrypt: jest.fn(() => Promise.resolve(Buffer.from(''))), | ||
})); | ||
|
||
jest.mock('@/modules/file/utils/bucket', () => ({ | ||
__esModule: true, | ||
default: { | ||
getKey: jest.fn(() => Promise.resolve('key')), | ||
upload: jest.fn(() => Promise.resolve()), | ||
}, | ||
})); | ||
|
||
describe('Attachment', () => { | ||
it('Verify that error is thrown if required props are not passed', async () => { | ||
expect(() => render(<Attachment />)).toThrowError(); | ||
expect(() => render(<Attachment file={file} />)).toThrowError(); | ||
expect(() => render(<Attachment file={file} address={address} />)).toThrowError(); | ||
}); | ||
|
||
it('Verify that component is rendered if required props are passed', () => { | ||
render(<Attachment file={file} address={address} removeFile={removeFile} setAttachments={setAttachments} />); | ||
|
||
expect(screen.getByText(file.name)).toBeInTheDocument(); | ||
}); | ||
}); |
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
7a48073
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: