-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Metric] convert mocha tests to jest #54054
Merged
nickofthyme
merged 15 commits into
elastic:master
from
nickofthyme:kpm/metric-mocha-to-jest
Jan 17, 2020
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ecefd44
Add fixtures/* alias to tsconfig and jest config
nickofthyme da50977
Convert metric tests to jest
nickofthyme 8c265b6
Convert remaining js files to ts
nickofthyme 0fd87ba
Address PR comments
nickofthyme 773d9c7
Merge branch 'master' into kpm/metric-mocha-to-jest
nickofthyme deecb22
Fix ci test failures
nickofthyme 5cf78d0
Merge branch 'master' into kpm/metric-mocha-to-jest
elasticmachine 6da5585
Fix type errors
nickofthyme b0ae467
Merge branch 'master' into kpm/metric-mocha-to-jest
nickofthyme 9e8f1e6
Merge remote-tracking branch 'origin/kpm/metric-mocha-to-jest' into k…
nickofthyme a80f077
Merge branch 'master' into kpm/metric-mocha-to-jest
elasticmachine 1c53734
Merge branch 'master' into kpm/metric-mocha-to-jest
nickofthyme 79d9ff0
Merge branch 'master' into kpm/metric-mocha-to-jest
nickofthyme 3e8d869
Fix type error
nickofthyme cef03ae
Fix jest test error
nickofthyme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
95 changes: 0 additions & 95 deletions
95
src/legacy/core_plugins/vis_type_metric/public/__tests__/metric_vis.js
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -17,11 +17,14 @@ | |
* under the License. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { MetricVisComponent } from '../components/metric_vis_controller'; | ||
// @ts-ignore | ||
import { MetricVisComponent } from './metric_vis_component'; | ||
import { Vis } from '../legacy_imports'; | ||
|
||
jest.mock('ui/new_platform'); | ||
|
||
describe('metric_vis - controller', function() { | ||
const vis = { | ||
const vis: Vis = { | ||
params: { | ||
metric: { | ||
colorSchema: 'Green to Red', | ||
|
@@ -33,39 +36,46 @@ describe('metric_vis - controller', function() { | |
bucket: null, | ||
}, | ||
}, | ||
}; | ||
} as any; | ||
|
||
let metricController; | ||
let metricVis: MetricVisComponent; | ||
|
||
beforeEach(() => { | ||
metricController = new MetricVisComponent({ vis: vis, visParams: vis.params }); | ||
metricVis = new MetricVisComponent({ | ||
vis, | ||
visParams: vis.params, | ||
visData: {} as any, | ||
renderComplete: jest.fn(), | ||
}); | ||
}); | ||
|
||
it('should set the metric label and value', function() { | ||
const metrics = metricController._processTableGroups({ | ||
// @ts-ignore | ||
const metrics = metricVis.processTableGroups({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit weird to test react components like this - could we change this to simple enzyme tests with a snapshot assertion instead? Then we don't have to call into the internal method. |
||
columns: [{ id: 'col-0', name: 'Count' }], | ||
rows: [{ 'col-0': 4301021 }], | ||
}); | ||
|
||
expect(metrics.length).to.be(1); | ||
expect(metrics[0].label).to.be('Count'); | ||
expect(metrics[0].value).to.be('<span ng-non-bindable>4301021</span>'); | ||
expect(metrics.length).toBe(1); | ||
expect(metrics[0].label).toBe('Count'); | ||
expect(metrics[0].value).toBe('<span ng-non-bindable>4301021</span>'); | ||
}); | ||
|
||
it('should support multi-value metrics', function() { | ||
vis.params.dimensions.metrics.push({ accessor: 1 }); | ||
const metrics = metricController._processTableGroups({ | ||
// @ts-ignore | ||
const metrics = metricVis.processTableGroups({ | ||
columns: [ | ||
{ id: 'col-0', name: '1st percentile of bytes' }, | ||
{ id: 'col-1', name: '99th percentile of bytes' }, | ||
], | ||
rows: [{ 'col-0': 182, 'col-1': 445842.4634666484 }], | ||
}); | ||
|
||
expect(metrics.length).to.be(2); | ||
expect(metrics[0].label).to.be('1st percentile of bytes'); | ||
expect(metrics[0].value).to.be('<span ng-non-bindable>182</span>'); | ||
expect(metrics[1].label).to.be('99th percentile of bytes'); | ||
expect(metrics[1].value).to.be('<span ng-non-bindable>445842.4634666484</span>'); | ||
expect(metrics.length).toBe(2); | ||
expect(metrics[0].label).toBe('1st percentile of bytes'); | ||
expect(metrics[0].value).toBe('<span ng-non-bindable>182</span>'); | ||
expect(metrics[1].label).toBe('99th percentile of bytes'); | ||
expect(metrics[1].value).toBe('<span ng-non-bindable>445842.4634666484</span>'); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover from the conversion?