-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02cc117
commit 1654a0a
Showing
19 changed files
with
70 additions
and
73 deletions.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
35 changes: 17 additions & 18 deletions
35
frontend/src/scenes/insights/aggregationAxisFormats.test.ts
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 |
---|---|---|
@@ -1,34 +1,33 @@ | ||
import { formatAggregationAxisValue } from 'scenes/insights/aggregationAxisFormat' | ||
import { FilterType } from '~/types' | ||
import { TrendsFilter } from '~/queries/schema' | ||
|
||
describe('formatAggregationAxisValue', () => { | ||
const formatTestcases = [ | ||
{ candidate: 34, filters: { aggregation_axis_format: 'duration' }, expected: '34s' }, | ||
{ candidate: 340, filters: { aggregation_axis_format: 'duration' }, expected: '5m 40s' }, | ||
{ candidate: 3940, filters: { aggregation_axis_format: 'duration' }, expected: '1h 5m 40s' }, | ||
{ candidate: 3.944, filters: { aggregation_axis_format: 'percentage' }, expected: '3.94%' }, | ||
{ candidate: 3.956, filters: { aggregation_axis_format: 'percentage' }, expected: '3.96%' }, | ||
{ candidate: 3940, filters: { aggregation_axis_format: 'percentage' }, expected: '3,940%' }, | ||
{ candidate: 34, filters: { aggregation_axis_format: 'numeric' }, expected: '34' }, | ||
{ candidate: 394, filters: { aggregation_axis_format: 'numeric' }, expected: '394' }, | ||
{ candidate: 3940, filters: { aggregation_axis_format: 'numeric' }, expected: '3,940' }, | ||
const formatTestcases: { candidate: number; filters: TrendsFilter; expected: string }[] = [ | ||
{ candidate: 34, filters: { aggregationAxisFormat: 'duration' }, expected: '34s' }, | ||
{ candidate: 340, filters: { aggregationAxisFormat: 'duration' }, expected: '5m 40s' }, | ||
{ candidate: 3940, filters: { aggregationAxisFormat: 'duration' }, expected: '1h 5m 40s' }, | ||
{ candidate: 3.944, filters: { aggregationAxisFormat: 'percentage' }, expected: '3.94%' }, | ||
{ candidate: 3.956, filters: { aggregationAxisFormat: 'percentage' }, expected: '3.96%' }, | ||
{ candidate: 3940, filters: { aggregationAxisFormat: 'percentage' }, expected: '3,940%' }, | ||
{ candidate: 34, filters: { aggregationAxisFormat: 'numeric' }, expected: '34' }, | ||
{ candidate: 394, filters: { aggregationAxisFormat: 'numeric' }, expected: '394' }, | ||
{ candidate: 3940, filters: { aggregationAxisFormat: 'numeric' }, expected: '3,940' }, | ||
{ candidate: 3940, filters: {}, expected: '3,940' }, | ||
{ candidate: 3940, filters: { aggregation_axis_format: 'unexpected' }, expected: '3,940' }, | ||
// @ts-expect-error | ||
{ candidate: 3940, filters: { aggregationAxisFormat: 'unexpected' }, expected: '3,940' }, | ||
{ | ||
candidate: 3940, | ||
filters: { | ||
aggregation_axis_format: 'numeric', | ||
aggregation_axis_prefix: '£', | ||
aggregation_axis_postfix: '💖', | ||
aggregationAxisFormat: 'numeric', | ||
aggregationAxisPrefix: '£', | ||
aggregationAxisPostfix: '💖', | ||
}, | ||
expected: '£3,940💖', | ||
}, | ||
] | ||
formatTestcases.forEach((testcase) => { | ||
it(`correctly formats "${testcase.candidate}" as ${testcase.expected} when filters are ${testcase.filters}`, () => { | ||
expect(formatAggregationAxisValue(testcase.filters as Partial<FilterType>, testcase.candidate)).toEqual( | ||
testcase.expected | ||
) | ||
expect(formatAggregationAxisValue(testcase.filters, testcase.candidate)).toEqual(testcase.expected) | ||
}) | ||
}) | ||
}) |
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
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
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.