Skip to content

Commit

Permalink
fix(helpers): noopTranslate display locale keys in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Dec 13, 2019
1 parent 6ee8b89 commit 26110ca
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 79 deletions.
2 changes: 1 addition & 1 deletion src/common/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const noop = Function.prototype;

const noopPromise = Promise.resolve({});

const noopTranslate = (key, value) => (value && `${value}`) || `t('${key}')`;
const noopTranslate = (key, value) => `t(${key}${(value && `, ${value}`) || ''})`;

const DEV_MODE = process.env.REACT_APP_ENV === 'development';

Expand Down
6 changes: 3 additions & 3 deletions src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`I18n Component should attempt to perform a component translate: translated component 1`] = `"<div>hello world</div>"`;
exports[`I18n Component should attempt to perform a component translate: translated component 1`] = `"<div>t(lorem.ipsum, hello world)</div>"`;

exports[`I18n Component should attempt to perform a string replace: translate 1`] = `
Object {
"localeKey": "t('lorem.ipsum')",
"placeholder": "hello world",
"localeKey": "t(lorem.ipsum)",
"placeholder": "t(lorem.ipsum, hello world)",
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ exports[`RhelGraphCard Component should render a non-connected component: non-co
>
<CardHead>
<h2>
t('curiosity-graph.heading')
t(curiosity-graph.heading)
</h2>
<CardActions>
<Select
aria-label="t('curiosity-graph.dropdownPlaceholder')"
aria-label="t(curiosity-graph.dropdownPlaceholder)"
ariaLabel="Select option"
className=""
id="generatedid-"
Expand All @@ -20,24 +20,24 @@ exports[`RhelGraphCard Component should render a non-connected component: non-co
options={
Array [
Object {
"title": "t('curiosity-graph.dropdownDaily')",
"title": "t(curiosity-graph.dropdownDaily)",
"value": "daily",
},
Object {
"title": "t('curiosity-graph.dropdownWeekly')",
"title": "t(curiosity-graph.dropdownWeekly)",
"value": "weekly",
},
Object {
"title": "t('curiosity-graph.dropdownMonthly')",
"title": "t(curiosity-graph.dropdownMonthly)",
"value": "monthly",
},
Object {
"title": "t('curiosity-graph.dropdownQuarterly')",
"title": "t(curiosity-graph.dropdownQuarterly)",
"value": "quarterly",
},
]
}
placeholder="t('curiosity-graph.dropdownPlaceholder')"
placeholder="t(curiosity-graph.dropdownPlaceholder)"
selectedOptions="daily"
variant="single"
/>
Expand All @@ -61,7 +61,7 @@ exports[`RhelGraphCard Component should render a non-connected component: non-co
"fill": "#8bc1f7",
"id": "sockets",
"isStacked": true,
"legendLabel": "[object Object]",
"legendLabel": "t(curiosity-graph.productSocketsLabel, [object Object])",
"stroke": "#06c",
},
Object {
Expand All @@ -75,7 +75,7 @@ exports[`RhelGraphCard Component should render a non-connected component: non-co
"fill": "#a2d9d9",
"id": "hypervisor",
"isStacked": true,
"legendLabel": "[object Object]",
"legendLabel": "t(curiosity-graph.productHypervisorLabel, [object Object])",
"stroke": "#009596",
},
Object {
Expand All @@ -88,7 +88,7 @@ exports[`RhelGraphCard Component should render a non-connected component: non-co
"data": Array [],
"id": "threshold",
"isThreshold": true,
"legendLabel": "t('curiosity-graph.thresholdLabel')",
"legendLabel": "t(curiosity-graph.thresholdLabel)",
"stroke": "#4cb140",
},
]
Expand Down Expand Up @@ -145,7 +145,7 @@ Object {
"fill": "#8bc1f7",
"id": "sockets",
"isStacked": true,
"legendLabel": "[object Object]",
"legendLabel": "t(curiosity-graph.productSocketsLabel, [object Object])",
"stroke": "#06c",
},
Object {
Expand All @@ -159,7 +159,7 @@ Object {
"fill": "#a2d9d9",
"id": "hypervisor",
"isStacked": true,
"legendLabel": "[object Object]",
"legendLabel": "t(curiosity-graph.productHypervisorLabel, [object Object])",
"stroke": "#009596",
},
Object {
Expand All @@ -172,7 +172,7 @@ Object {
"data": undefined,
"id": "threshold",
"isThreshold": true,
"legendLabel": "t('curiosity-graph.thresholdLabel')",
"legendLabel": "t(curiosity-graph.thresholdLabel)",
"stroke": "#4cb140",
},
],
Expand All @@ -197,11 +197,11 @@ exports[`RhelGraphCard Component should render multiple states: fulfilled 1`] =
>
<CardHead>
<h2>
t('curiosity-graph.heading')
t(curiosity-graph.heading)
</h2>
<CardActions>
<Select
aria-label="t('curiosity-graph.dropdownPlaceholder')"
aria-label="t(curiosity-graph.dropdownPlaceholder)"
ariaLabel="Select option"
className=""
id="generatedid-"
Expand All @@ -211,24 +211,24 @@ exports[`RhelGraphCard Component should render multiple states: fulfilled 1`] =
options={
Array [
Object {
"title": "t('curiosity-graph.dropdownDaily')",
"title": "t(curiosity-graph.dropdownDaily)",
"value": "daily",
},
Object {
"title": "t('curiosity-graph.dropdownWeekly')",
"title": "t(curiosity-graph.dropdownWeekly)",
"value": "weekly",
},
Object {
"title": "t('curiosity-graph.dropdownMonthly')",
"title": "t(curiosity-graph.dropdownMonthly)",
"value": "monthly",
},
Object {
"title": "t('curiosity-graph.dropdownQuarterly')",
"title": "t(curiosity-graph.dropdownQuarterly)",
"value": "quarterly",
},
]
}
placeholder="t('curiosity-graph.dropdownPlaceholder')"
placeholder="t(curiosity-graph.dropdownPlaceholder)"
selectedOptions="daily"
variant="single"
/>
Expand Down Expand Up @@ -268,7 +268,7 @@ exports[`RhelGraphCard Component should render multiple states: fulfilled 1`] =
"fill": "#8bc1f7",
"id": "sockets",
"isStacked": true,
"legendLabel": "[object Object]",
"legendLabel": "t(curiosity-graph.productSocketsLabel, [object Object])",
"stroke": "#06c",
},
Object {
Expand All @@ -282,7 +282,7 @@ exports[`RhelGraphCard Component should render multiple states: fulfilled 1`] =
"fill": "#a2d9d9",
"id": "hypervisor",
"isStacked": true,
"legendLabel": "[object Object]",
"legendLabel": "t(curiosity-graph.productHypervisorLabel, [object Object])",
"stroke": "#009596",
},
Object {
Expand All @@ -295,7 +295,7 @@ exports[`RhelGraphCard Component should render multiple states: fulfilled 1`] =
"data": undefined,
"id": "threshold",
"isThreshold": true,
"legendLabel": "t('curiosity-graph.thresholdLabel')",
"legendLabel": "t(curiosity-graph.thresholdLabel)",
"stroke": "#4cb140",
},
]
Expand Down Expand Up @@ -328,11 +328,11 @@ exports[`RhelGraphCard Component should render multiple states: pending 1`] = `
>
<CardHead>
<h2>
t('curiosity-graph.heading')
t(curiosity-graph.heading)
</h2>
<CardActions>
<Select
aria-label="t('curiosity-graph.dropdownPlaceholder')"
aria-label="t(curiosity-graph.dropdownPlaceholder)"
ariaLabel="Select option"
className=""
id="generatedid-"
Expand All @@ -342,24 +342,24 @@ exports[`RhelGraphCard Component should render multiple states: pending 1`] = `
options={
Array [
Object {
"title": "t('curiosity-graph.dropdownDaily')",
"title": "t(curiosity-graph.dropdownDaily)",
"value": "daily",
},
Object {
"title": "t('curiosity-graph.dropdownWeekly')",
"title": "t(curiosity-graph.dropdownWeekly)",
"value": "weekly",
},
Object {
"title": "t('curiosity-graph.dropdownMonthly')",
"title": "t(curiosity-graph.dropdownMonthly)",
"value": "monthly",
},
Object {
"title": "t('curiosity-graph.dropdownQuarterly')",
"title": "t(curiosity-graph.dropdownQuarterly)",
"value": "quarterly",
},
]
}
placeholder="t('curiosity-graph.dropdownPlaceholder')"
placeholder="t(curiosity-graph.dropdownPlaceholder)"
selectedOptions="daily"
variant="single"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ Object {

exports[`RhelGraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: granularity data display 1`] = `
Object {
"daily": "t('curiosity-graph.thresholdLabel'): 100
[object Object]: 50
[object Object]: 50
t('curiosity-graph.dateLabel'): June 1",
"monthly": "t('curiosity-graph.thresholdLabel'): 100
[object Object]: 50
[object Object]: 50
t('curiosity-graph.dateLabel'): June 2019",
"quarterly": "t('curiosity-graph.thresholdLabel'): 100
[object Object]: 50
[object Object]: 50
t('curiosity-graph.dateLabel'): June 2019",
"weekly": "t('curiosity-graph.thresholdLabel'): 100
[object Object]: 50
[object Object]: 50
t('curiosity-graph.dateLabel'): June 1",
"daily": "t(curiosity-graph.thresholdLabel): 100
t(curiosity-graph.productSocketsLabel, [object Object]): 50
t(curiosity-graph.productHypervisorLabel, [object Object]): 50
t(curiosity-graph.dateLabel): June 1",
"monthly": "t(curiosity-graph.thresholdLabel): 100
t(curiosity-graph.productSocketsLabel, [object Object]): 50
t(curiosity-graph.productHypervisorLabel, [object Object]): 50
t(curiosity-graph.dateLabel): June 2019",
"quarterly": "t(curiosity-graph.thresholdLabel): 100
t(curiosity-graph.productSocketsLabel, [object Object]): 50
t(curiosity-graph.productHypervisorLabel, [object Object]): 50
t(curiosity-graph.dateLabel): June 2019",
"weekly": "t(curiosity-graph.thresholdLabel): 100
t(curiosity-graph.productSocketsLabel, [object Object]): 50
t(curiosity-graph.productHypervisorLabel, [object Object]): 50
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`] = `
Object {
"daily": "t('curiosity-graph.noDataLabel')",
"monthly": "t('curiosity-graph.noDataLabel')",
"quarterly": "t('curiosity-graph.noDataLabel')",
"weekly": "t('curiosity-graph.noDataLabel')",
"daily": "t(curiosity-graph.noDataLabel)",
"monthly": "t(curiosity-graph.noDataLabel)",
"quarterly": "t(curiosity-graph.noDataLabel)",
"weekly": "t(curiosity-graph.noDataLabel)",
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ Object {
exports[`RhelGraphCardTypes should return a specific output for getDateMenuOptionsType: getDateMenuOptionsType 1`] = `
Array [
Object {
"title": "t('curiosity-graph.dropdownDaily')",
"title": "t(curiosity-graph.dropdownDaily)",
"value": "daily",
},
Object {
"title": "t('curiosity-graph.dropdownWeekly')",
"title": "t(curiosity-graph.dropdownWeekly)",
"value": "weekly",
},
Object {
"title": "t('curiosity-graph.dropdownMonthly')",
"title": "t(curiosity-graph.dropdownMonthly)",
"value": "monthly",
},
Object {
"title": "t('curiosity-graph.dropdownQuarterly')",
"title": "t(curiosity-graph.dropdownQuarterly)",
"value": "quarterly",
},
]
Expand Down
Loading

0 comments on commit 26110ca

Please sign in to comment.