1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-11-27 08:31:20 +02:00

chore[GH-#849]: Add unit test for imageElement (#1502)

This commit is contained in:
Julien Fabre 2021-10-09 01:38:14 +02:00 committed by GitHub
parent 3448551a0a
commit 9ca5cd6a87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/content/ImageElement should match snapshot 1`] = `
<div>
<img
alt="test-title"
class="ImageElement"
src="test.jpg"
/>
</div>
`;

View File

@ -0,0 +1,55 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react'
import {render} from '@testing-library/react'
import {act} from 'react-dom/test-utils'
import {mocked} from 'ts-jest/utils'
import {ImageBlock} from '../../blocks/imageBlock'
import {wrapIntl} from '../../testUtils'
import octoClient from '../../octoClient'
import ImageElement from './imageElement'
jest.mock('../../octoClient')
const mockedOcto = mocked(octoClient, true)
mockedOcto.getFileAsDataUrl.mockResolvedValue('test.jpg')
describe('components/content/ImageElement', () => {
const defaultBlock: ImageBlock = {
id: 'test-id',
workspaceId: '',
parentId: '',
rootId: '1',
modifiedBy: 'test-user-id',
schema: 0,
type: 'image',
title: 'test-title',
fields: {
fileId: 'test.jpg',
},
createdBy: 'test-user-id',
createAt: 0,
updateAt: 0,
deleteAt: 0,
}
test('should match snapshot', async () => {
const component = wrapIntl(
<ImageElement
block={defaultBlock}
/>,
)
let imageContainer: Element | undefined
await act(async () => {
const {container} = render(component)
imageContainer = container
})
expect(imageContainer).toMatchSnapshot()
})
})