Skip to content

Commit

Permalink
fix(graphCard,helpers,types): issues/161 directory, file rename
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Dec 16, 2019
1 parent 25be1ef commit c02c2ea
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -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`] = `
<Card
className="curiosity-usage-graph fadein"
>
Expand Down Expand Up @@ -71,7 +71,7 @@ exports[`RhelGraphCard Component should render a non-connected component: non-co
</Card>
`;

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 {
Expand Down Expand Up @@ -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`] = `
<Redirect
to="/lorem-error-403-route"
/>
`;

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`] = `
<Redirect
to="/lorem-error-500-route"
/>
`;

exports[`RhelGraphCard Component should render multiple states: fulfilled 1`] = `
exports[`GraphCard Component should render multiple states: fulfilled 1`] = `
<Card
className="curiosity-usage-graph fadein"
>
Expand Down Expand Up @@ -222,7 +222,7 @@ exports[`RhelGraphCard Component should render multiple states: fulfilled 1`] =
</Card>
`;

exports[`RhelGraphCard Component should render multiple states: pending 1`] = `
exports[`GraphCard Component should render multiple states: pending 1`] = `
<Card
className="curiosity-usage-graph fadein"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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",
Expand All @@ -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
Expand All @@ -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)",
Expand All @@ -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],
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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(<RhelGraphCard {...props} />);
const component = shallow(<GraphCard {...props} />);

expect(component).toMatchSnapshot('non-connected');
});
Expand Down Expand Up @@ -36,7 +36,7 @@ describe('RhelGraphCard Component', () => {
}
};

const component = shallow(<RhelGraphCard {...props} />);
const component = shallow(<GraphCard {...props} />);

component.setProps({
error: true
Expand Down
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -55,25 +55,25 @@ 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,
granularity: graphGranularity
});

const tooltips = ({ itemsByKey }) =>
rhelGraphCardHelpers.getTooltips({
graphCardHelpers.getTooltips({
itemsByKey,
granularity: graphGranularity,
product: translateProduct
});

const chartAreaProps = {
xAxisFixLabelOverlap: true,
xAxisLabelIncrement: rhelGraphCardHelpers.getChartXAxisLabelIncrement(graphGranularity),
xAxisLabelIncrement: graphCardHelpers.getChartXAxisLabelIncrement(graphGranularity),
xAxisTickFormat,
yAxisTickFormat: rhelGraphCardHelpers.yAxisTickFormat,
yAxisTickFormat: graphCardHelpers.yAxisTickFormat,
tooltips
};

Expand Down Expand Up @@ -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 && <Redirect to={errorRoute.to} />) || null;
Expand Down Expand Up @@ -153,7 +153,7 @@ class RhelGraphCard extends React.Component {
}
}

RhelGraphCard.propTypes = {
GraphCard.propTypes = {
error: PropTypes.bool,
errorRoute: PropTypes.shape({
to: PropTypes.string
Expand Down Expand Up @@ -184,7 +184,7 @@ RhelGraphCard.propTypes = {
endDate: PropTypes.instanceOf(Date)
};

RhelGraphCard.defaultProps = {
GraphCard.defaultProps = {
error: false,
errorRoute: {},
errorStatus: null,
Expand Down Expand Up @@ -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 };
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -155,8 +155,8 @@ const rhelGraphCardHelpers = {
};

export {
rhelGraphCardHelpers as default,
rhelGraphCardHelpers,
graphCardHelpers as default,
graphCardHelpers,
getChartXAxisLabelIncrement,
getTooltipDate,
getTooltips,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
18 changes: 9 additions & 9 deletions src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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 \\"\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`RhelView Component should have a fallback title: title 1`] = `
/>
</PageHeader>
<PageSection>
<Connect(RhelGraphCard)
<Connect(GraphCard)
filterGraphData={
Array [
Object {
Expand Down Expand Up @@ -41,7 +41,7 @@ exports[`RhelView Component should render a non-connected component: non-connect
/>
</PageHeader>
<PageSection>
<Connect(RhelGraphCard)
<Connect(GraphCard)
filterGraphData={
Array [
Object {
Expand Down
4 changes: 2 additions & 2 deletions src/components/rhelView/rhelView.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@patternfly/react-tokens';
import { PageHeader, PageHeaderTitle } from '@redhat-cloud-services/frontend-components';
import { PageSection } from '@patternfly/react-core';
import RhelGraphCard from '../rhelGraphCard/rhelGraphCard';
import GraphCard from '../graphCard/graphCard';
import { helpers } from '../../common';

class RhelView extends React.Component {
Expand All @@ -25,7 +25,7 @@ class RhelView extends React.Component {
/>
</PageHeader>
<PageSection>
<RhelGraphCard
<GraphCard
key={routeDetail.pathParameter}
filterGraphData={[
{ id: 'physicalSockets', fill: chartColorBlueLight.value, stroke: chartColorBlueDark.value },
Expand Down

0 comments on commit c02c2ea

Please sign in to comment.