[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:
parent
c6f86bdce1
commit
e02a03290d
2 changed files with 74 additions and 0 deletions
|
@ -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>
|
||||
`;
|
52
webapp/src/components/content/contentElement.test.tsx
Normal file
52
webapp/src/components/content/contentElement.test.tsx
Normal 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()
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue