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

[GH-847] Add unit tests for contentElement (#1501)

* chore[GH-#847]: add unit tests for contentElement

* fix: checkbox not need...

* fix: checkbox not need...
This commit is contained in:
Julien Fabre 2021-10-13 12:56:38 +02:00 committed by GitHub
parent c6f86bdce1
commit e02a03290d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/content/contentElement return an element 1`] = `
<div>
<div
class="CheckboxElement"
>
<input
id="checkbox-test-id"
type="checkbox"
value="off"
/>
<input
class="Editable undefined"
placeholder="Edit text..."
spellcheck="true"
title="test-title"
value="test-title"
/>
</div>
</div>
`;

View File

@ -0,0 +1,52 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {render} from '@testing-library/react'
import {wrapIntl} from '../../testUtils'
import {ContentBlock} from '../../blocks/contentBlock'
import ContentElement from './contentElement'
describe('components/content/contentElement', () => {
test('return an element', () => {
const contentBlock: ContentBlock = {
id: 'test-id',
workspaceId: '',
parentId: '',
rootId: '',
modifiedBy: 'test-user-id',
schema: 0,
type: 'checkbox',
title: 'test-title',
fields: {},
createdBy: 'test-user-id',
createAt: 0,
updateAt: 0,
deleteAt: 0,
}
const checkBoxElement = ContentElement({block: contentBlock, readonly: false})
const {container} = render(wrapIntl(checkBoxElement))
expect(container).toMatchSnapshot()
})
test('return null', () => {
const contentBlock: ContentBlock = {
id: 'test-id',
workspaceId: '',
parentId: '',
rootId: '',
modifiedBy: 'test-user-id',
schema: 0,
type: 'unknown',
title: 'test-title',
fields: {},
createdBy: 'test-user-id',
createAt: 0,
updateAt: 0,
deleteAt: 0,
}
const contentElement = ContentElement({block: contentBlock, readonly: false})
expect(contentElement).toBeNull()
})
})