Skip to content

Commit 767b194

Browse files
author
Artyom Podymov
committed
fix unit tests
1 parent 6b7cd4f commit 767b194

File tree

13 files changed

+35
-23
lines changed

13 files changed

+35
-23
lines changed

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@
7575
"\\.(jpg|jpeg|png|ico|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/redisinsight/__mocks__/fileMock.js",
7676
"\\.(css|less|sass|scss)$": "identity-obj-proxy",
7777
"uiSrc/(.*)": "<rootDir>/redisinsight/ui/src/$1",
78-
"monaco-editor": "<rootDir>/redisinsight/__mocks__/monacoMock.js"
78+
"monaco-editor": "<rootDir>/redisinsight/__mocks__/monacoMock.js",
79+
"unified": "<rootDir>/redisinsight/__mocks__/unified.js",
80+
"remark-parse": "<rootDir>/redisinsight/__mocks__/remarkParse.js",
81+
"remark-rehype": "<rootDir>/redisinsight/__mocks__/remarkRehype.js",
82+
"rehype-external-links": "<rootDir>/redisinsight/__mocks__/rehypeExternalLinks.js",
83+
"rehype-stringify": "<rootDir>/redisinsight/__mocks__/rehypeStringify.js",
84+
"unist-util-visit": "<rootDir>/redisinsight/__mocks__/unistUtilsVisit.js"
7985
},
8086
"setupFilesAfterEnv": [
8187
"<rootDir>/redisinsight/ui/src/setup-tests.ts"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default jest.fn()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default jest.fn()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default jest.fn()

redisinsight/__mocks__/remarkRehype.js

Whitespace-only changes.

redisinsight/__mocks__/unified.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const unified = jest.fn()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const visit = jest.fn();

redisinsight/ui/src/pages/workbench/components/enablament-area/EnablementArea/EnablementArea.spec.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import { cloneDeep } from 'lodash'
33
import { instance, mock } from 'ts-mockito'
4-
import { cleanup, mockedEAFormatSelector, mockedStore, render } from 'uiSrc/utils/test-utils'
4+
import { cleanup, mockedStore, render } from 'uiSrc/utils/test-utils'
55
import { MOCK_ENABLEMENT_AREA_ITEMS } from 'uiSrc/constants'
66
import { EnablementAreaComponent } from 'uiSrc/slices/interfaces'
77

@@ -26,9 +26,6 @@ jest.mock('uiSrc/slices/workbench/wb-enablement-area', () => {
2626
}),
2727
}
2828
})
29-
jest.mock('./utils/formatter/FormatSelector', () => {
30-
return mockedEAFormatSelector
31-
})
3229

3330
describe('EnablementArea', () => {
3431
it('should render', () => {

redisinsight/ui/src/pages/workbench/components/enablament-area/EnablementArea/components/InternalPage/InternalPage.spec.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import React from 'react'
22
import { instance, mock } from 'ts-mockito'
3-
import { fireEvent, mockedEAFormatSelector, render } from 'uiSrc/utils/test-utils'
3+
import { fireEvent, render } from 'uiSrc/utils/test-utils'
44
import InternalPage, { Props } from './InternalPage'
55

66
const mockedProps = mock<Props>()
77

8-
jest.mock('../../utils/formatter/FormatSelector', () => {
9-
return mockedEAFormatSelector
10-
})
11-
128
describe('InternalPage', () => {
139
it('should render', () => {
1410
expect(render(<InternalPage {...instance(mockedProps)} />)).toBeTruthy()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import FormatSelector from './FormatSelector'
2+
import HtmlToJsxString from './HtmlToJsxString'
3+
import MarkdownToJsxString from './MarkdownToJsxString'
4+
5+
describe('FormatSelector', () => {
6+
it('should select correct formatter for html ', () => {
7+
expect(FormatSelector.selectFor('html')).toBeInstanceOf(HtmlToJsxString)
8+
})
9+
it('should select correct formatter for markdown ', () => {
10+
expect(FormatSelector.selectFor('md')).toBeInstanceOf(MarkdownToJsxString)
11+
})
12+
it('should throw unsupported format error', () => {
13+
try {
14+
FormatSelector.selectFor('mp4')
15+
} catch (e) {
16+
expect(e.message).toBe('Unsupported format')
17+
}
18+
})
19+
})

0 commit comments

Comments
 (0)