From c02c2eaf5812e94f5caf4bced5fd3e2e83df974d Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Sun, 15 Dec 2019 17:51:03 -0500 Subject: [PATCH] fix(graphCard,helpers,types): issues/161 directory, file rename --- .../__snapshots__/graphCard.test.js.snap} | 12 +++++----- .../graphCardHelpers.test.js.snap} | 16 ++++++------- .../graphCardTypes.test.js.snap} | 0 .../__tests__/graphCard.test.js} | 8 +++---- .../__tests__/graphCardHelpers.test.js} | 8 +++---- .../__tests__/graphCardTypes.test.js} | 4 ++-- .../graphCard.js} | 24 +++++++++---------- .../graphCardHelpers.js} | 6 ++--- .../graphCardTypes.js} | 4 ++-- .../__tests__/__snapshots__/i18n.test.js.snap | 18 +++++++------- .../__snapshots__/rhelView.test.js.snap | 4 ++-- src/components/rhelView/rhelView.js | 4 ++-- 12 files changed, 54 insertions(+), 54 deletions(-) rename src/components/{rhelGraphCard/__tests__/__snapshots__/rhelGraphCard.test.js.snap => graphCard/__tests__/__snapshots__/graphCard.test.js.snap} (92%) rename src/components/{rhelGraphCard/__tests__/__snapshots__/rhelGraphCardHelpers.test.js.snap => graphCard/__tests__/__snapshots__/graphCardHelpers.test.js.snap} (76%) rename src/components/{rhelGraphCard/__tests__/__snapshots__/rhelGraphCardTypes.test.js.snap => graphCard/__tests__/__snapshots__/graphCardTypes.test.js.snap} (100%) rename src/components/{rhelGraphCard/__tests__/rhelGraphCard.test.js => graphCard/__tests__/graphCard.test.js} (88%) rename src/components/{rhelGraphCard/__tests__/rhelGraphCardHelpers.test.js => graphCard/__tests__/graphCardHelpers.test.js} (96%) rename src/components/{rhelGraphCard/__tests__/rhelGraphCardTypes.test.js => graphCard/__tests__/graphCardTypes.test.js} (69%) rename src/components/{rhelGraphCard/rhelGraphCard.js => graphCard/graphCard.js} (89%) rename src/components/{rhelGraphCard/rhelGraphCardHelpers.js => graphCard/graphCardHelpers.js} (98%) rename src/components/{rhelGraphCard/rhelGraphCardTypes.js => graphCard/graphCardTypes.js} (85%) diff --git a/src/components/rhelGraphCard/__tests__/__snapshots__/rhelGraphCard.test.js.snap b/src/components/graphCard/__tests__/__snapshots__/graphCard.test.js.snap similarity index 92% rename from src/components/rhelGraphCard/__tests__/__snapshots__/rhelGraphCard.test.js.snap rename to src/components/graphCard/__tests__/__snapshots__/graphCard.test.js.snap index 8834d32b3..8c4428891 100644 --- a/src/components/rhelGraphCard/__tests__/__snapshots__/rhelGraphCard.test.js.snap +++ b/src/components/graphCard/__tests__/__snapshots__/graphCard.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`RhelGraphCard Component should render a non-connected component: non-connected 1`] = ` +exports[`GraphCard Component should render a non-connected component: non-connected 1`] = ` @@ -71,7 +71,7 @@ exports[`RhelGraphCard Component should render a non-connected component: non-co `; -exports[`RhelGraphCard Component should render multiple states: error passes values 1`] = ` +exports[`GraphCard Component should render multiple states: error passes values 1`] = ` Object { "chartBarData": Array [ Object { @@ -107,19 +107,19 @@ Object { } `; -exports[`RhelGraphCard Component should render multiple states: error with 403 status redirects 1`] = ` +exports[`GraphCard Component should render multiple states: error with 403 status redirects 1`] = ` `; -exports[`RhelGraphCard Component should render multiple states: error with 500 status redirects 1`] = ` +exports[`GraphCard Component should render multiple states: error with 500 status redirects 1`] = ` `; -exports[`RhelGraphCard Component should render multiple states: fulfilled 1`] = ` +exports[`GraphCard Component should render multiple states: fulfilled 1`] = ` @@ -222,7 +222,7 @@ exports[`RhelGraphCard Component should render multiple states: fulfilled 1`] = `; -exports[`RhelGraphCard Component should render multiple states: pending 1`] = ` +exports[`GraphCard Component should render multiple states: pending 1`] = ` diff --git a/src/components/rhelGraphCard/__tests__/__snapshots__/rhelGraphCardHelpers.test.js.snap b/src/components/graphCard/__tests__/__snapshots__/graphCardHelpers.test.js.snap similarity index 76% rename from src/components/rhelGraphCard/__tests__/__snapshots__/rhelGraphCardHelpers.test.js.snap rename to src/components/graphCard/__tests__/__snapshots__/graphCardHelpers.test.js.snap index f123e21ca..25f11452e 100644 --- a/src/components/rhelGraphCard/__tests__/__snapshots__/rhelGraphCardHelpers.test.js.snap +++ b/src/components/graphCard/__tests__/__snapshots__/graphCardHelpers.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`RhelGraphCardHelpers getChartXAxisLabelIncrement should return a x axis tick increment based on granularity: x axis tick increment 1`] = ` +exports[`GraphCardHelpers getChartXAxisLabelIncrement should return a x axis tick increment based on granularity: x axis tick increment 1`] = ` Object { "daily": 5, "monthly": 2, @@ -9,7 +9,7 @@ Object { } `; -exports[`RhelGraphCardHelpers getTooltipDate should return a formatted date based on granularity: granularity based date 1`] = ` +exports[`GraphCardHelpers getTooltipDate should return a formatted date based on granularity: granularity based date 1`] = ` Object { "daily": "June 1", "monthly": "June 2019", @@ -18,7 +18,7 @@ Object { } `; -exports[`RhelGraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: granularity data display 1`] = ` +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: granularity data display 1`] = ` Object { "daily": "t(curiosity-graph.thresholdLabel, [object Object]): 100 t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 50 @@ -39,7 +39,7 @@ t(curiosity-graph.dateLabel): June 1", } `; -exports[`RhelGraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: no data granularity data display 1`] = ` +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: no data granularity data display 1`] = ` Object { "daily": "t(curiosity-graph.noDataLabel)", "monthly": "t(curiosity-graph.noDataLabel)", @@ -48,7 +48,7 @@ Object { } `; -exports[`RhelGraphCardHelpers should have specific functions: rhelGraphCardHelpers 1`] = ` +exports[`GraphCardHelpers should have specific functions: graphCardHelpers 1`] = ` Object { "getChartXAxisLabelIncrement": [Function], "getTooltipDate": [Function], @@ -58,14 +58,14 @@ Object { } `; -exports[`RhelGraphCardHelpers xAxisTickFormat should produce consistent x axis tick values: x axis should be undefined if date or granularity are missing 1`] = ` +exports[`GraphCardHelpers xAxisTickFormat should produce consistent x axis tick values: x axis should be undefined if date or granularity are missing 1`] = ` Object { "missingDate": undefined, "missingGranularity": undefined, } `; -exports[`RhelGraphCardHelpers xAxisTickFormat should produce consistent x axis tick values: x axis tick values 1`] = ` +exports[`GraphCardHelpers xAxisTickFormat should produce consistent x axis tick values: x axis tick values 1`] = ` Object { "daily": Array [ "Jun 20", @@ -152,7 +152,7 @@ Object { } `; -exports[`RhelGraphCardHelpers yAxisTickFormat should produce consistent y axis tick values: y axis tick values 1`] = ` +exports[`GraphCardHelpers yAxisTickFormat should produce consistent y axis tick values: y axis tick values 1`] = ` Object { "1": "1", "10": "10", diff --git a/src/components/rhelGraphCard/__tests__/__snapshots__/rhelGraphCardTypes.test.js.snap b/src/components/graphCard/__tests__/__snapshots__/graphCardTypes.test.js.snap similarity index 100% rename from src/components/rhelGraphCard/__tests__/__snapshots__/rhelGraphCardTypes.test.js.snap rename to src/components/graphCard/__tests__/__snapshots__/graphCardTypes.test.js.snap diff --git a/src/components/rhelGraphCard/__tests__/rhelGraphCard.test.js b/src/components/graphCard/__tests__/graphCard.test.js similarity index 88% rename from src/components/rhelGraphCard/__tests__/rhelGraphCard.test.js rename to src/components/graphCard/__tests__/graphCard.test.js index 63361250f..d963b8749 100644 --- a/src/components/rhelGraphCard/__tests__/rhelGraphCard.test.js +++ b/src/components/graphCard/__tests__/graphCard.test.js @@ -1,12 +1,12 @@ import React from 'react'; import { shallow } from 'enzyme'; import { ChartArea } from '../../chartArea/chartArea'; -import { RhelGraphCard } from '../rhelGraphCard'; +import { GraphCard } from '../graphCard'; -describe('RhelGraphCard Component', () => { +describe('GraphCard Component', () => { it('should render a non-connected component', () => { const props = {}; - const component = shallow(); + const component = shallow(); expect(component).toMatchSnapshot('non-connected'); }); @@ -36,7 +36,7 @@ describe('RhelGraphCard Component', () => { } }; - const component = shallow(); + const component = shallow(); component.setProps({ error: true diff --git a/src/components/rhelGraphCard/__tests__/rhelGraphCardHelpers.test.js b/src/components/graphCard/__tests__/graphCardHelpers.test.js similarity index 96% rename from src/components/rhelGraphCard/__tests__/rhelGraphCardHelpers.test.js rename to src/components/graphCard/__tests__/graphCardHelpers.test.js index 6e1449c73..a6097a75b 100644 --- a/src/components/rhelGraphCard/__tests__/rhelGraphCardHelpers.test.js +++ b/src/components/graphCard/__tests__/graphCardHelpers.test.js @@ -1,18 +1,18 @@ import moment from 'moment'; import { - rhelGraphCardHelpers, + graphCardHelpers, getChartXAxisLabelIncrement, getTooltipDate, getTooltips, xAxisTickFormat, yAxisTickFormat -} from '../rhelGraphCardHelpers'; +} from '../graphCardHelpers'; import { dateHelpers } from '../../../common'; import { RHSM_API_QUERY_GRANULARITY_TYPES as GRANULARITY_TYPES } from '../../../types/rhsmApiTypes'; -describe('RhelGraphCardHelpers', () => { +describe('GraphCardHelpers', () => { it('should have specific functions', () => { - expect(rhelGraphCardHelpers).toMatchSnapshot('rhelGraphCardHelpers'); + expect(graphCardHelpers).toMatchSnapshot('graphCardHelpers'); }); it('getChartXAxisLabelIncrement should return a x axis tick increment based on granularity', () => { diff --git a/src/components/rhelGraphCard/__tests__/rhelGraphCardTypes.test.js b/src/components/graphCard/__tests__/graphCardTypes.test.js similarity index 69% rename from src/components/rhelGraphCard/__tests__/rhelGraphCardTypes.test.js rename to src/components/graphCard/__tests__/graphCardTypes.test.js index 7f4eddfcd..d10fb9ea1 100644 --- a/src/components/rhelGraphCard/__tests__/rhelGraphCardTypes.test.js +++ b/src/components/graphCard/__tests__/graphCardTypes.test.js @@ -1,8 +1,8 @@ -import { rhelGraphCardTypes, getGranularityOptionsType } from '../rhelGraphCardTypes'; +import { graphCardTypes, getGranularityOptionsType } from '../graphCardTypes'; describe('RhelGraphCardTypes', () => { it('should have specific types', () => { - expect(rhelGraphCardTypes).toMatchSnapshot('rhelGraphCardTypes'); + expect(graphCardTypes).toMatchSnapshot('rhelGraphCardTypes'); }); it('should return an output for granularity selection', () => { diff --git a/src/components/rhelGraphCard/rhelGraphCard.js b/src/components/graphCard/graphCard.js similarity index 89% rename from src/components/rhelGraphCard/rhelGraphCard.js rename to src/components/graphCard/graphCard.js index a9a0fe13b..d3d685010 100644 --- a/src/components/rhelGraphCard/rhelGraphCard.js +++ b/src/components/graphCard/graphCard.js @@ -8,11 +8,11 @@ import { Select } from '../select/select'; import { connectTranslate, reduxActions, reduxSelectors, reduxTypes, store } from '../../redux'; import { helpers, dateHelpers } from '../../common'; import { rhsmApiTypes, RHSM_API_QUERY_GRANULARITY_TYPES as GRANULARITY_TYPES } from '../../types/rhsmApiTypes'; -import { rhelGraphCardHelpers } from './rhelGraphCardHelpers'; -import { rhelGraphCardTypes } from './rhelGraphCardTypes'; +import { graphCardHelpers } from './graphCardHelpers'; +import { graphCardTypes } from './graphCardTypes'; import ChartArea from '../chartArea/chartArea'; -class RhelGraphCard extends React.Component { +class GraphCard extends React.Component { componentDidMount() { this.onUpdateGraphData(); } @@ -55,7 +55,7 @@ class RhelGraphCard extends React.Component { const { filterGraphData, graphData, graphGranularity, t, translateProduct } = this.props; const xAxisTickFormat = ({ item, previousItem, tick }) => - rhelGraphCardHelpers.xAxisTickFormat({ + graphCardHelpers.xAxisTickFormat({ tick, date: item.date, previousDate: previousItem.date, @@ -63,7 +63,7 @@ class RhelGraphCard extends React.Component { }); const tooltips = ({ itemsByKey }) => - rhelGraphCardHelpers.getTooltips({ + graphCardHelpers.getTooltips({ itemsByKey, granularity: graphGranularity, product: translateProduct @@ -71,9 +71,9 @@ class RhelGraphCard extends React.Component { const chartAreaProps = { xAxisFixLabelOverlap: true, - xAxisLabelIncrement: rhelGraphCardHelpers.getChartXAxisLabelIncrement(graphGranularity), + xAxisLabelIncrement: graphCardHelpers.getChartXAxisLabelIncrement(graphGranularity), xAxisTickFormat, - yAxisTickFormat: rhelGraphCardHelpers.yAxisTickFormat, + yAxisTickFormat: graphCardHelpers.yAxisTickFormat, tooltips }; @@ -115,7 +115,7 @@ class RhelGraphCard extends React.Component { // ToDo: combine "curiosity-skeleton-container" into a single class w/ --loading and BEM style render() { const { error, errorRoute, errorStatus, graphGranularity, selectOptionsType, pending, t } = this.props; - const getGranularityOptions = rhelGraphCardTypes.getGranularityOptions(selectOptionsType); + const getGranularityOptions = graphCardTypes.getGranularityOptions(selectOptionsType); if (error && (errorStatus === 403 || errorStatus >= 500)) { return (errorRoute && errorRoute.to && ) || null; @@ -153,7 +153,7 @@ class RhelGraphCard extends React.Component { } } -RhelGraphCard.propTypes = { +GraphCard.propTypes = { error: PropTypes.bool, errorRoute: PropTypes.shape({ to: PropTypes.string @@ -184,7 +184,7 @@ RhelGraphCard.propTypes = { endDate: PropTypes.instanceOf(Date) }; -RhelGraphCard.defaultProps = { +GraphCard.defaultProps = { error: false, errorRoute: {}, errorStatus: null, @@ -215,6 +215,6 @@ const mapDispatchToProps = dispatch => ({ getGraphReports: (id, query) => dispatch(reduxActions.rhsm.getGraphReports(id, query)) }); -const ConnectedRhelGraphCard = connectTranslate(makeMapStateToProps, mapDispatchToProps)(RhelGraphCard); +const ConnectedGraphCard = connectTranslate(makeMapStateToProps, mapDispatchToProps)(GraphCard); -export { ConnectedRhelGraphCard as default, ConnectedRhelGraphCard, RhelGraphCard }; +export { ConnectedGraphCard as default, ConnectedGraphCard, GraphCard }; diff --git a/src/components/rhelGraphCard/rhelGraphCardHelpers.js b/src/components/graphCard/graphCardHelpers.js similarity index 98% rename from src/components/rhelGraphCard/rhelGraphCardHelpers.js rename to src/components/graphCard/graphCardHelpers.js index 745a0f482..1e4d1b5a8 100644 --- a/src/components/rhelGraphCard/rhelGraphCardHelpers.js +++ b/src/components/graphCard/graphCardHelpers.js @@ -146,7 +146,7 @@ const xAxisTickFormat = ({ date, granularity, tick, previousDate }) => { */ const yAxisTickFormat = ({ tick }) => numbro(tick).format({ average: true, mantissa: 1, optionalMantissa: true }); -const rhelGraphCardHelpers = { +const graphCardHelpers = { getChartXAxisLabelIncrement, getTooltipDate, getTooltips, @@ -155,8 +155,8 @@ const rhelGraphCardHelpers = { }; export { - rhelGraphCardHelpers as default, - rhelGraphCardHelpers, + graphCardHelpers as default, + graphCardHelpers, getChartXAxisLabelIncrement, getTooltipDate, getTooltips, diff --git a/src/components/rhelGraphCard/rhelGraphCardTypes.js b/src/components/graphCard/graphCardTypes.js similarity index 85% rename from src/components/rhelGraphCard/rhelGraphCardTypes.js rename to src/components/graphCard/graphCardTypes.js index 423609307..8c18a0135 100644 --- a/src/components/rhelGraphCard/rhelGraphCardTypes.js +++ b/src/components/graphCard/graphCardTypes.js @@ -14,8 +14,8 @@ const getGranularityOptionsType = optionsType => { return []; }; -const rhelGraphCardTypes = { +const graphCardTypes = { getGranularityOptions: getGranularityOptionsType }; -export { rhelGraphCardTypes as default, rhelGraphCardTypes, getGranularityOptionsType }; +export { graphCardTypes as default, graphCardTypes, getGranularityOptionsType }; diff --git a/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap b/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap index e0f06fa45..17629e524 100644 --- a/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap +++ b/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap @@ -14,36 +14,36 @@ exports[`I18n Component should generate a predictable pot output snapshot: pot o msgstr \\"\\" \\"Content-Type: text/plain; charset=UTF-8\\\\n\\" -#: src/components/rhelGraphCard/rhelGraphCardHelpers.js:73 +#: src/components/graphCard/graphCardHelpers.js:73 msgid \\"curiosity-graph.dateLabel\\" msgstr \\"\\" -#: src/components/rhelGraphCard/rhelGraphCardTypes.js:7 +#: src/components/graphCard/graphCardTypes.js:7 msgid \\"curiosity-graph.dropdownDaily\\" msgstr \\"\\" -#: src/components/rhelGraphCard/rhelGraphCardTypes.js:9 +#: src/components/graphCard/graphCardTypes.js:9 msgid \\"curiosity-graph.dropdownMonthly\\" msgstr \\"\\" -#: src/components/rhelGraphCard/rhelGraphCard.js:130 -#: src/components/rhelGraphCard/rhelGraphCard.js:134 +#: src/components/graphCard/graphCard.js:130 +#: src/components/graphCard/graphCard.js:134 msgid \\"curiosity-graph.dropdownPlaceholder\\" msgstr \\"\\" -#: src/components/rhelGraphCard/rhelGraphCardTypes.js:10 +#: src/components/graphCard/graphCardTypes.js:10 msgid \\"curiosity-graph.dropdownQuarterly\\" msgstr \\"\\" -#: src/components/rhelGraphCard/rhelGraphCardTypes.js:8 +#: src/components/graphCard/graphCardTypes.js:8 msgid \\"curiosity-graph.dropdownWeekly\\" msgstr \\"\\" -#: src/components/rhelGraphCard/rhelGraphCard.js:127 +#: src/components/graphCard/graphCard.js:127 msgid \\"curiosity-graph.heading\\" msgstr \\"\\" -#: src/components/rhelGraphCard/rhelGraphCardHelpers.js:90 +#: src/components/graphCard/graphCardHelpers.js:90 msgid \\"curiosity-graph.noDataLabel\\" msgstr \\"\\" diff --git a/src/components/rhelView/__tests__/__snapshots__/rhelView.test.js.snap b/src/components/rhelView/__tests__/__snapshots__/rhelView.test.js.snap index a53aef39c..e73d4a6e9 100644 --- a/src/components/rhelView/__tests__/__snapshots__/rhelView.test.js.snap +++ b/src/components/rhelView/__tests__/__snapshots__/rhelView.test.js.snap @@ -8,7 +8,7 @@ exports[`RhelView Component should have a fallback title: title 1`] = ` /> - - -