lint
add accessors to vale add headers
This commit is contained in:
@@ -94,6 +94,7 @@ Zalando
|
||||
Zhou
|
||||
Zolotusky
|
||||
abc
|
||||
accessors
|
||||
adamdmharvey
|
||||
andrewthauer
|
||||
api
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2020 Spotify AB
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import pluralize from 'pluralize';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
@@ -16,29 +32,27 @@ const mockData: ProjectGrowthData = {
|
||||
aggregation: [0, 0],
|
||||
change: {
|
||||
ratio: 0,
|
||||
amount: 0
|
||||
amount: 0,
|
||||
},
|
||||
products: [
|
||||
{
|
||||
id: 'product-a',
|
||||
aggregation: [0, 0]
|
||||
}
|
||||
aggregation: [0, 0],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// suppress recharts componentDidUpdate deprecation warnings
|
||||
jest.spyOn(console, 'warn').mockImplementation(() => { });
|
||||
jest.spyOn(console, 'warn').mockImplementation(() => {});
|
||||
|
||||
async function renderInContext(children: JSX.Element) {
|
||||
return renderInTestApp(
|
||||
<MockConfigProvider>
|
||||
<MockBillingDateProvider>
|
||||
<MockCurrencyProvider>
|
||||
{children}
|
||||
</MockCurrencyProvider>
|
||||
<MockCurrencyProvider>{children}</MockCurrencyProvider>
|
||||
</MockBillingDateProvider>
|
||||
</MockConfigProvider>
|
||||
)
|
||||
</MockConfigProvider>,
|
||||
);
|
||||
}
|
||||
|
||||
class CustomProjectGrowthAlert extends ProjectGrowthAlert {
|
||||
@@ -46,7 +60,11 @@ class CustomProjectGrowthAlert extends ProjectGrowthAlert {
|
||||
return 'path/to/resource';
|
||||
}
|
||||
get title() {
|
||||
return `Investigate cost growth in ${pluralize('project', this.data.products.length, true)}`;
|
||||
return `Investigate cost growth in ${pluralize(
|
||||
'project',
|
||||
this.data.products.length,
|
||||
true,
|
||||
)}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +75,12 @@ describe('ProjectGrowthAlert', () => {
|
||||
const { getByText, queryByText } = await renderInContext(alert.element);
|
||||
|
||||
expect(alert.url).toBe('/cost-insights/investigating-growth');
|
||||
expect(alert.title).toBe('Investigate cost growth in project test-project');
|
||||
expect(alert.subtitle).toBe('Cost growth outpacing business growth is unsustainable long-term.');
|
||||
expect(alert.title).toBe(
|
||||
'Investigate cost growth in project test-project',
|
||||
);
|
||||
expect(alert.subtitle).toBe(
|
||||
'Cost growth outpacing business growth is unsustainable long-term.',
|
||||
);
|
||||
expect(getByText('1 product')).toBeInTheDocument();
|
||||
expect(queryByText('sorted by cost')).not.toBeInTheDocument();
|
||||
});
|
||||
@@ -69,9 +91,11 @@ describe('ProjectGrowthAlert', () => {
|
||||
|
||||
expect(alert.url).toBe('path/to/resource');
|
||||
expect(alert.title).toBe('Investigate cost growth in 1 project');
|
||||
expect(alert.subtitle).toBe('Cost growth outpacing business growth is unsustainable long-term.');
|
||||
expect(alert.subtitle).toBe(
|
||||
'Cost growth outpacing business growth is unsustainable long-term.',
|
||||
);
|
||||
expect(getByText('1 product')).toBeInTheDocument();
|
||||
expect(queryByText('sorted by cost')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2020 Spotify AB
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import pluralize from 'pluralize';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
@@ -18,24 +34,22 @@ const mockData: UnlabeledDataflowData = {
|
||||
{
|
||||
id: 'project-a',
|
||||
labeledCost: 0,
|
||||
unlabeledCost: 0
|
||||
}
|
||||
]
|
||||
unlabeledCost: 0,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// suppress recharts componentDidUpdate deprecation warnings
|
||||
jest.spyOn(console, 'warn').mockImplementation(() => { });
|
||||
jest.spyOn(console, 'warn').mockImplementation(() => {});
|
||||
|
||||
async function renderInContext(children: JSX.Element) {
|
||||
return renderInTestApp(
|
||||
<MockConfigProvider>
|
||||
<MockBillingDateProvider>
|
||||
<MockCurrencyProvider>
|
||||
{children}
|
||||
</MockCurrencyProvider>
|
||||
<MockCurrencyProvider>{children}</MockCurrencyProvider>
|
||||
</MockBillingDateProvider>
|
||||
</MockConfigProvider>
|
||||
)
|
||||
</MockConfigProvider>,
|
||||
);
|
||||
}
|
||||
|
||||
class CustomUnlabeledDataflowAlert extends UnlabeledDataflowAlert {
|
||||
@@ -43,7 +57,11 @@ class CustomUnlabeledDataflowAlert extends UnlabeledDataflowAlert {
|
||||
return 'path/to/resource';
|
||||
}
|
||||
get title() {
|
||||
return `Add labels to ${pluralize('workflow', this.data.projects.length, true)}`;
|
||||
return `Add labels to ${pluralize(
|
||||
'workflow',
|
||||
this.data.projects.length,
|
||||
true,
|
||||
)}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +73,14 @@ describe('UnlabeledDataflowAlert', () => {
|
||||
|
||||
expect(alert.url).toBe('/cost-insights/labeling-jobs');
|
||||
expect(alert.title).toBe('Add labels to workflows');
|
||||
expect(alert.subtitle).toBe('Labels show in billing data, enabling cost insights for each workflow.');
|
||||
expect(getByText('Showing costs from 1 project with unlabeled Dataflow jobs in the last 30 days.')).toBeInTheDocument();
|
||||
expect(alert.subtitle).toBe(
|
||||
'Labels show in billing data, enabling cost insights for each workflow.',
|
||||
);
|
||||
expect(
|
||||
getByText(
|
||||
'Showing costs from 1 project with unlabeled Dataflow jobs in the last 30 days.',
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('a subclass can inherit and override defaults using accessors', async () => {
|
||||
@@ -65,8 +89,14 @@ describe('UnlabeledDataflowAlert', () => {
|
||||
|
||||
expect(alert.url).toBe('path/to/resource');
|
||||
expect(alert.title).toBe('Add labels to 1 workflow');
|
||||
expect(alert.subtitle).toBe('Labels show in billing data, enabling cost insights for each workflow.');
|
||||
expect(getByText('Showing costs from 1 project with unlabeled Dataflow jobs in the last 30 days.')).toBeInTheDocument();
|
||||
expect(alert.subtitle).toBe(
|
||||
'Labels show in billing data, enabling cost insights for each workflow.',
|
||||
);
|
||||
expect(
|
||||
getByText(
|
||||
'Showing costs from 1 project with unlabeled Dataflow jobs in the last 30 days.',
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user