Skip to content

Commit e3191f6

Browse files
committed
#RI-781 - add Unit tests
1 parent 5c070b1 commit e3191f6

36 files changed

+744
-1257
lines changed

babel.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ module.exports = (api) => {
4848
require('@babel/plugin-syntax-import-meta'),
4949
[require('@babel/plugin-proposal-class-properties'), { loose: true }],
5050
require('@babel/plugin-proposal-json-strings'),
51+
[require('@babel/plugin-proposal-private-property-in-object'), { loose: true }],
52+
[require('@babel/plugin-proposal-private-methods'), { loose: true }],
5153

5254
...(development ? developmentPlugins : productionPlugins),
5355
],

configs/webpack.config.renderer.dev.babel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ export default merge(baseConfig, {
209209
BASE_API_URL: 'http://localhost',
210210
RESOURCES_BASE_URL: 'http://localhost',
211211
SCAN_COUNT_DEFAULT: '500',
212+
SCAN_TREE_COUNT_DEFAULT: '10000',
212213
BUILD_TYPE: 'ELECTRON',
213214
APP_VERSION: version,
214215
SEGMENT_WRITE_KEY:

configs/webpack.config.renderer.dev.dll.babel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export default merge(baseConfig, {
5151
BASE_API_URL: 'http://localhost',
5252
RESOURCES_BASE_URL: 'http://localhost',
5353
SCAN_COUNT_DEFAULT: '500',
54+
SCAN_TREE_COUNT_DEFAULT: '10000',
5455
SEGMENT_WRITE_KEY:
5556
'SEGMENT_WRITE_KEY' in process.env ? process.env.SEGMENT_WRITE_KEY : 'SOURCE_WRITE_KEY',
5657
}),

configs/webpack.config.renderer.prod.babel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ export default merge(baseConfig, {
197197
RESOURCES_BASE_URL: process.env.SERVER_TLS_CERT && process.env.SERVER_TLS_KEY ? 'https://localhost' : 'http://localhost',
198198
APP_ENV: 'electron',
199199
SCAN_COUNT_DEFAULT: '500',
200+
SCAN_TREE_COUNT_DEFAULT: '10000',
200201
SEGMENT_WRITE_KEY:
201202
'SEGMENT_WRITE_KEY' in process.env ? process.env.SEGMENT_WRITE_KEY : 'SOURCE_WRITE_KEY',
202203
}),

configs/webpack.config.renderer.stage.babel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default merge(baseConfig, {
2020
RESOURCES_BASE_URL: process.env.SERVER_TLS_CERT && process.env.SERVER_TLS_KEY ? 'https://localhost' : 'http://localhost',
2121
APP_ENV: 'electron',
2222
SCAN_COUNT_DEFAULT: '500',
23+
SCAN_COUNT_MEMORY_ANALYSES: '10000',
2324
SEGMENT_WRITE_KEY:
2425
'SEGMENT_WRITE_KEY' in process.env ? process.env.SEGMENT_WRITE_KEY : 'SOURCE_WRITE_KEY',
2526
}),

configs/webpack.config.web.dev.babel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,11 @@ export default merge(commonConfig, {
183183
NODE_ENV: 'development',
184184
APP_ENV: 'web',
185185
API_PREFIX: 'api',
186-
API_PORT: '5000',
186+
API_PORT: '5001',
187187
BASE_API_URL: `http://${require('os').hostname()}`,
188188
RESOURCES_BASE_URL: `http://${require('os').hostname()}`,
189189
SCAN_COUNT_DEFAULT: '500',
190+
SCAN_TREE_COUNT_DEFAULT: '10000',
190191
SEGMENT_WRITE_KEY:
191192
'SEGMENT_WRITE_KEY' in process.env ? process.env.SEGMENT_WRITE_KEY : 'SOURCE_WRITE_KEY',
192193
}),

configs/webpack.config.web.prod.babel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ export default merge(commonConfig, {
4646
new webpack.EnvironmentPlugin({
4747
NODE_ENV: 'production',
4848
APP_ENV: 'web',
49-
API_PORT: '5000',
49+
API_PORT: '5001',
5050
API_PREFIX: '',
5151
BASE_API_URL: 'api/',
5252
RESOURCES_BASE_URL:
5353
process.env.SERVER_TLS_CERT && process.env.SERVER_TLS_KEY ? 'https://localhost' : 'http://localhost',
5454
SCAN_COUNT_DEFAULT: '500',
55+
SCAN_TREE_COUNT_DEFAULT: '10000',
5556
SEGMENT_WRITE_KEY:
5657
'SEGMENT_WRITE_KEY' in process.env ? process.env.SEGMENT_WRITE_KEY : 'SOURCE_WRITE_KEY',
5758
}),

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@
134134
"@teamsupercell/typings-for-css-modules-loader": "^2.4.0",
135135
"@testing-library/jest-dom": "^5.11.6",
136136
"@testing-library/react": "^11.2.2",
137-
"@testing-library/react-hooks": "^5.0.3",
138137
"@types/axios": "^0.14.0",
139138
"@types/classnames": "^2.2.11",
140139
"@types/date-fns": "^2.6.0",
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
import React from 'react'
22
import { instance, mock } from 'ts-mockito'
3-
import { fireEvent, screen, render } from 'uiSrc/utils/test-utils'
4-
import ScanMore, { Props } from './KeysSummary'
3+
import { render } from 'uiSrc/utils/test-utils'
4+
import KeysSummary, { Props } from './KeysSummary'
55

66
const mockedProps = mock<Props>()
77

8-
describe('ActionBar', () => {
8+
describe('KeysSummary', () => {
99
it('should render', () => {
10-
expect(render(<ScanMore {...instance(mockedProps)} />)).toBeTruthy()
10+
expect(render(<KeysSummary {...instance(mockedProps)} />)).toBeTruthy()
1111
})
1212

13-
it('should call "onCloseActionBar"', () => {
14-
const handleClick = jest.fn()
15-
16-
const renderer = render(
17-
<ScanMore {...instance(mockedProps)} onCloseActionBar={handleClick} />
13+
it('should "Scanning..." be in the document until loading and totalItemsCount == 0 ', () => {
14+
const { queryByTestId } = render(
15+
<KeysSummary {...instance(mockedProps)} loading totalItemsCount={0} />
1816
)
17+
expect(queryByTestId('scanning-text')).toBeInTheDocument()
18+
})
1919

20-
expect(renderer).toBeTruthy()
21-
22-
fireEvent.click(screen.getByTestId('cancel-selecting'))
23-
expect(handleClick).toHaveBeenCalledTimes(1)
20+
it('should Keys summary be in the document meanwhile totalItemsCount != 0 ', () => {
21+
const { queryByTestId } = render(
22+
<KeysSummary {...instance(mockedProps)} totalItemsCount={2} />
23+
)
24+
expect(queryByTestId('keys-summary')).toBeInTheDocument()
2425
})
2526
})

redisinsight/ui/src/components/keys-summary/KeysSummary.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const KeysSummary = ({
2828
}: Props) => (
2929
<>
3030
{!!totalItemsCount && (
31-
<div className={styles.content}>
31+
<div className={styles.content} data-testid="keys-summary">
3232
{!!totalItemsCount && (
3333
<EuiText size="xs">
3434
{!!scanned && (
@@ -83,7 +83,7 @@ const KeysSummary = ({
8383
</div>
8484
)}
8585
{loading && !totalItemsCount && (
86-
<EuiText size="xs">
86+
<EuiText size="xs" data-testid="scanning-text">
8787
Scanning...
8888
</EuiText>
8989
)}

0 commit comments

Comments
 (0)