-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* graphCard, lifecycle to context * graphCardChartLegend, use parsed context * graphCardContext, useParseFiltersSettings hook * graphCardContext, rhsmActions, align promise all
- Loading branch information
Showing
9 changed files
with
257 additions
and
109 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,90 @@ | ||
import React from 'react'; | ||
import { GraphCard } from '../graphCard'; | ||
import { rhsmConstants } from '../../../services/rhsm/rhsmConstants'; | ||
|
||
describe('GraphCard Component', () => { | ||
it('should render a basic component', async () => { | ||
const props = { | ||
useProductGraphConfig: () => ({ | ||
filters: [ | ||
{ | ||
metric: rhsmConstants.RHSM_API_PATH_METRIC_TYPES.CORE_SECONDS | ||
} | ||
] | ||
}) | ||
}; | ||
const component = await shallowHookComponent(<GraphCard {...props} />); | ||
|
||
expect(component).toMatchSnapshot('basic'); | ||
it('should render a default component', async () => { | ||
const component = await shallowHookComponent(<GraphCard />); | ||
expect(component).toMatchSnapshot('default'); | ||
}); | ||
|
||
it('should setup basic settings', async () => { | ||
const props = { | ||
useProductGraphConfig: () => ({ | ||
filters: [ | ||
{ | ||
metric: rhsmConstants.RHSM_API_PATH_METRIC_TYPES.CORE_SECONDS | ||
}, | ||
useParseFiltersSettings: () => ({ | ||
groupedFiltersSettings: {}, | ||
standaloneFiltersSettings: [ | ||
{ | ||
metric: rhsmConstants.RHSM_API_PATH_METRIC_TYPES.SOCKETS, | ||
isStandalone: true | ||
settings: { | ||
isStandalone: true, | ||
metric: { | ||
chartType: 'area', | ||
id: 'Sockets', | ||
isCapacity: false, | ||
isStacked: true, | ||
isStandalone: true, | ||
isThreshold: false, | ||
isToolbarFilter: false, | ||
metric: 'Sockets', | ||
strokeWidth: 2 | ||
}, | ||
metrics: [ | ||
{ | ||
chartType: 'area', | ||
id: 'Sockets', | ||
isCapacity: false, | ||
isStacked: true, | ||
isStandalone: true, | ||
isThreshold: false, | ||
isToolbarFilter: false, | ||
metric: 'Sockets', | ||
strokeWidth: 2 | ||
} | ||
], | ||
padding: { | ||
bottom: 75, | ||
left: 75, | ||
right: 45, | ||
top: 45 | ||
} | ||
} | ||
} | ||
] | ||
}) | ||
}; | ||
const component = await shallowHookComponent(<GraphCard {...props} />); | ||
const componentStandalone = await shallowHookComponent(<GraphCard {...props} />); | ||
expect(componentStandalone).toMatchSnapshot('settings, standalone'); | ||
|
||
props.useParseFiltersSettings = () => ({ | ||
groupedFiltersSettings: { | ||
settings: { | ||
isStandalone: false, | ||
metric: undefined, | ||
metrics: [ | ||
{ | ||
chartType: 'area', | ||
id: 'Core-seconds', | ||
isCapacity: false, | ||
isStacked: true, | ||
isStandalone: false, | ||
isThreshold: false, | ||
isToolbarFilter: false, | ||
metric: 'Core-seconds', | ||
strokeWidth: 2 | ||
} | ||
] | ||
} | ||
}, | ||
standaloneFiltersSettings: [] | ||
}); | ||
|
||
expect(component).toMatchSnapshot('settings'); | ||
const componentGrouped = await shallowHookComponent(<GraphCard {...props} />); | ||
expect(componentGrouped).toMatchSnapshot('settings, grouped'); | ||
}); | ||
|
||
it('should allow being disabled', async () => { | ||
const props = { | ||
isDisabled: true | ||
}; | ||
const component = await shallowHookComponent(<GraphCard {...props} />); | ||
|
||
expect(component).toMatchSnapshot('disabled'); | ||
}); | ||
}); |
41 changes: 40 additions & 1 deletion
41
src/components/graphCard/__tests__/graphCardContext.test.js
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.