Skip to content

Commit

Permalink
fix(utils): Budgets - update labels
Browse files Browse the repository at this point in the history
  • Loading branch information
vio committed Apr 10, 2022
1 parent e968a99 commit 537262b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions packages/utils/src/transformers/__tests__/budgets-insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ describe('transformers/budgetsInsights', () => {
totalSizeByTypeALL: {
type: 'ERROR',
message: {
text: 'Bundle Size value (11.5KB) is over 10KB budget',
md: '**Bundle Size** value (**11.5KB**) is over **10KB** budget',
text: 'Bundle Size is above budget (11.5KB / 10KB)',
md: '**Bundle Size** is above budget (**11.5KB** / **10KB**)',
},
data: {
currentValue: 11776,
Expand Down Expand Up @@ -93,8 +93,8 @@ describe('transformers/budgetsInsights', () => {
'sizes.totalSizeByTypeJS': {
type: 'ERROR',
message: {
text: 'JS value (11.5KB) is over 10KB budget',
md: '**JS** value (**11.5KB**) is over **10KB** budget',
text: 'JS is above budget (11.5KB / 10KB)',
md: '**JS** is above budget (**11.5KB** / **10KB**)',
},
data: {
currentValue: 11776,
Expand Down
6 changes: 3 additions & 3 deletions packages/utils/src/transformers/budgets-insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,18 @@ const getMessage = (insights: Array<[string, BudgetInsightMetric]>) => {
const budgetInsightMetricTemplate = template(
// Add escapes for (|) to avoid lodash.template syntax errors
// eslint-disable-next-line no-useless-escape
'<%= metricLabel %> value \(<%= currentValue %>\) is <%= diffLabel %> <%= budgetValue %> budget',
'<%= metricLabel %> is <%= diffLabel %> budget \(<%= currentValue %> / <%= budgetValue %>\)',
);

const resolveDiffLabel = (metricBudgetInsight: BudgetInsightMetricData): string => {
const { currentValue, budgetValue } = metricBudgetInsight;

if (currentValue > budgetValue) {
return 'over';
return 'above';
}

if (currentValue < budgetValue) {
return 'under';
return 'below';
}

return 'equal with';
Expand Down

0 comments on commit 537262b

Please sign in to comment.