[GH-837]: Add unit tests for topBar (#1751)

* chore[GH-#837]: Add unit tests for topBar

* fix: eslint error for screen

* fix: none

* fix: none and snapshot...
This commit is contained in:
Julien Fabre 2021-11-04 14:35:05 +01:00 committed by GitHub
parent 69b8641534
commit 6741b0e07e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 91 additions and 0 deletions

View file

@ -0,0 +1,58 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`src/components/topBar should match snapshot for focalboardPlugin 1`] = `
<div>
<div
class="TopBar"
>
<a
class="link"
href="https://www.focalboard.com/fwlink/feedback-boards.html?v=1.0.0"
rel="noreferrer"
target="_blank"
>
Give Feedback
</a>
<div
class="versionFrame"
>
<div
class="version"
>
v1.0.0
</div>
<div
class="versionBadge"
>
BETA
</div>
</div>
</div>
</div>
`;
exports[`src/components/topBar should match snapshot for none focalboardPlugin 1`] = `
<div>
<div
class="TopBar"
>
<a
class="link"
href="https://www.focalboard.com/fwlink/feedback-focalboard.html?v=1.0.0"
rel="noreferrer"
target="_blank"
>
Give Feedback
</a>
<a
href="https://www.focalboard.com/guide/user?utm_source=webapp"
rel="noreferrer"
target="_blank"
>
<i
class="CompassIcon icon-help-circle-outline HelpIcon"
/>
</a>
</div>
</div>
`;

View file

@ -0,0 +1,33 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {render} from '@testing-library/react'
import React from 'react'
import {mocked} from 'ts-jest/utils'
import {wrapDNDIntl} from '../testUtils'
import {Constants} from '../constants'
import {Utils} from '../utils'
import TopBar from './topBar'
Object.defineProperty(Constants, 'versionString', {value: '1.0.0'})
jest.mock('../utils')
const mockedUtils = mocked(Utils, true)
describe('src/components/topBar', () => {
beforeEach(jest.resetAllMocks)
test('should match snapshot for focalboardPlugin', () => {
mockedUtils.isFocalboardPlugin.mockReturnValue(true)
const {container} = render(wrapDNDIntl(
<TopBar/>,
))
expect(container).toMatchSnapshot()
})
test('should match snapshot for none focalboardPlugin', () => {
mockedUtils.isFocalboardPlugin.mockReturnValue(false)
const {container} = render(wrapDNDIntl(
<TopBar/>,
))
expect(container).toMatchSnapshot()
})
})