forked from opensearch-project/observability
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jest test cases (opensearch-project#985)
* gauge chart test case added, event-anlytics utils test case added Signed-off-by: Ramneet Chopra <ramneet_chopra@persistent.com> * build error resolve: updated snapshots Signed-off-by: Ramneet Chopra <ramneet_chopra@persistent.com> Signed-off-by: Ramneet Chopra <ramneet_chopra@persistent.com>
- Loading branch information
1 parent
a37542d
commit a1490cc
Showing
13 changed files
with
1,376 additions
and
203 deletions.
There are no files selected for viewing
283 changes: 273 additions & 10 deletions
283
...s/explorer/visualizations/config_panel/__tests__/__snapshots__/config_panel.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
83 changes: 83 additions & 0 deletions
83
dashboards-observability/public/components/event_analytics/utils/__tests__/utils.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
import { | ||
hexToRgb, | ||
lightenColor, | ||
formatError, | ||
isValidTraceId, | ||
rangeNumDocs, | ||
getHeaders, | ||
} from '../utils'; | ||
|
||
describe('Utils event analytics helper functions', () => { | ||
configure({ adapter: new Adapter() }); | ||
|
||
it('validates hexToRgb function', () => { | ||
expect(hexToRgb()).toBe('rgba(60,161,199,1)'); | ||
expect(hexToRgb('test', 1, true)).toBe('rgba(96,353,409,1)'); | ||
expect(hexToRgb('#000000', 1, true)).toBe('rgba(0,0,0,1)'); | ||
}); | ||
|
||
it('validates lightenColor function', () => { | ||
expect(lightenColor('#00000', 10)).toBe('#1a1a1a'); | ||
}); | ||
|
||
it('validates formatError function', () => { | ||
expect(formatError('Warning', 'This is a warning', 'Test warning description')).toStrictEqual({ | ||
body: { | ||
attributes: { error: { caused_by: { reason: 'Test warning description', type: '' } } }, | ||
}, | ||
message: 'This is a warning', | ||
name: 'Warning', | ||
}); | ||
}); | ||
|
||
it('validates isValidTraceId function', () => { | ||
expect(isValidTraceId('#00000')).toBe(false); | ||
expect(isValidTraceId('abcdefghijklmnopqrstuvwxyzabcdef')).toBe(true); | ||
}); | ||
|
||
it('validates rangeNumDocs function', () => { | ||
expect(rangeNumDocs(11000)).toBe(10000); | ||
expect(rangeNumDocs(-200)).toBe(0); | ||
expect(rangeNumDocs(2000)).toBe(2000); | ||
}); | ||
|
||
it('validates getHeaders function', () => { | ||
expect( | ||
getHeaders( | ||
[ | ||
{ | ||
name: 'host', | ||
type: 'text', | ||
}, | ||
{ | ||
name: 'ip_count', | ||
type: 'integer', | ||
}, | ||
{ | ||
name: 'per_ip_bytes', | ||
type: 'long', | ||
}, | ||
{ | ||
name: 'resp_code', | ||
type: 'text', | ||
}, | ||
{ | ||
name: 'sum_bytes', | ||
type: 'long', | ||
}, | ||
], | ||
['', 'Time', '_source'], | ||
undefined | ||
) | ||
).toBeTruthy(); | ||
expect(getHeaders([], ['', 'Time', '_source'], undefined)).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.