mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-12 02:23:49 +00:00
Updated to airbnb coding styles
This commit is contained in:
@@ -27,8 +27,8 @@ describe('<ChartCard />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ 'the title', 'the title' ],
|
||||
[ () => 'the title from func', 'the title from func' ],
|
||||
['the title', 'the title'],
|
||||
[() => 'the title from func', 'the title from func'],
|
||||
])('properly renders title by parsing provided value', (title, expectedTitle) => {
|
||||
const wrapper = createWrapper(title);
|
||||
const header = wrapper.find(CardHeader);
|
||||
|
||||
@@ -4,10 +4,10 @@ import { Chart, ChartDataset } from 'chart.js';
|
||||
import { DoughnutChartLegend } from '../../../src/visits/charts/DoughnutChartLegend';
|
||||
|
||||
describe('<DoughnutChartLegend />', () => {
|
||||
const labels = [ 'foo', 'bar', 'baz', 'foo2', 'bar2' ];
|
||||
const colors = [ 'foo_color', 'bar_color', 'baz_color' ];
|
||||
const labels = ['foo', 'bar', 'baz', 'foo2', 'bar2'];
|
||||
const colors = ['foo_color', 'bar_color', 'baz_color'];
|
||||
const defaultColor = 'red';
|
||||
const datasets = [ Mock.of<ChartDataset>({ backgroundColor: colors }) ];
|
||||
const datasets = [Mock.of<ChartDataset>({ backgroundColor: colors })];
|
||||
const chart = Mock.of<Chart>({
|
||||
config: {
|
||||
data: { labels, datasets },
|
||||
|
||||
@@ -39,16 +39,16 @@ describe('<HorizontalBarChart />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[{ foo: 23 }, [ 100, 456 ], [ 23, 0 ]],
|
||||
[{ foo: 50 }, [ 73, 456 ], [ 50, 0 ]],
|
||||
[{ bar: 45 }, [ 123, 411 ], [ 0, 45 ]],
|
||||
[{ bar: 20, foo: 13 }, [ 110, 436 ], [ 13, 20 ]],
|
||||
[ undefined, [ 123, 456 ], undefined ],
|
||||
[{ foo: 23 }, [100, 456], [23, 0]],
|
||||
[{ foo: 50 }, [73, 456], [50, 0]],
|
||||
[{ bar: 45 }, [123, 411], [0, 45]],
|
||||
[{ bar: 20, foo: 13 }, [110, 436], [13, 20]],
|
||||
[undefined, [123, 456], undefined],
|
||||
])('splits highlighted data from regular data', (highlightedStats, expectedData, expectedHighlightedData) => {
|
||||
wrapper = shallow(<HorizontalBarChart stats={stats} highlightedStats={highlightedStats} />);
|
||||
const horizontal = wrapper.find(Bar);
|
||||
|
||||
const { datasets: [{ data, label }, highlightedData ] } = horizontal.prop('data') as any;
|
||||
const { datasets: [{ data, label }, highlightedData] } = horizontal.prop('data') as any;
|
||||
|
||||
expect(label).toEqual('Visits');
|
||||
expect(data).toEqual(expectedData);
|
||||
|
||||
@@ -27,13 +27,13 @@ describe('<LineChartCard />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[[], 'monthly' ],
|
||||
[[{ date: formatISO(subDays(new Date(), 1)) }], 'hourly' ],
|
||||
[[{ date: formatISO(subDays(new Date(), 3)) }], 'daily' ],
|
||||
[[{ date: formatISO(subMonths(new Date(), 2)) }], 'weekly' ],
|
||||
[[{ date: formatISO(subMonths(new Date(), 6)) }], 'weekly' ],
|
||||
[[{ date: formatISO(subMonths(new Date(), 7)) }], 'monthly' ],
|
||||
[[{ date: formatISO(subYears(new Date(), 1)) }], 'monthly' ],
|
||||
[[], 'monthly'],
|
||||
[[{ date: formatISO(subDays(new Date(), 1)) }], 'hourly'],
|
||||
[[{ date: formatISO(subDays(new Date(), 3)) }], 'daily'],
|
||||
[[{ date: formatISO(subMonths(new Date(), 2)) }], 'weekly'],
|
||||
[[{ date: formatISO(subMonths(new Date(), 6)) }], 'weekly'],
|
||||
[[{ date: formatISO(subMonths(new Date(), 7)) }], 'monthly'],
|
||||
[[{ date: formatISO(subYears(new Date(), 1)) }], 'monthly'],
|
||||
])('renders group menu and selects proper grouping item based on visits dates', (visits, expectedActiveItem) => {
|
||||
const wrapper = createWrapper(visits.map((visit) => Mock.of<NormalizedVisit>(visit)));
|
||||
const items = wrapper.find(DropdownItem);
|
||||
@@ -80,8 +80,8 @@ describe('<LineChartCard />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[[ Mock.of<NormalizedVisit>({ date: '2016-04-01' }) ], [], 1 ],
|
||||
[[ Mock.of<NormalizedVisit>({ date: '2016-04-01' }) ], [ Mock.of<NormalizedVisit>({ date: '2016-04-01' }) ], 2 ],
|
||||
[[Mock.of<NormalizedVisit>({ date: '2016-04-01' })], [], 1],
|
||||
[[Mock.of<NormalizedVisit>({ date: '2016-04-01' })], [Mock.of<NormalizedVisit>({ date: '2016-04-01' })], 2],
|
||||
])('renders chart with expected data', (visits, highlightedVisits, expectedLines) => {
|
||||
const wrapper = createWrapper(visits, highlightedVisits);
|
||||
const chart = wrapper.find(Line);
|
||||
|
||||
@@ -57,10 +57,10 @@ describe('<SortableBarChartCard />', () => {
|
||||
};
|
||||
});
|
||||
|
||||
it('name - ASC', () => assert('name', 'ASC', [ 'Bar', 'Foo' ], [ 50, 100 ]));
|
||||
it('name - DESC', () => assert('name', 'DESC', [ 'Foo', 'Bar' ], [ 100, 50 ]));
|
||||
it('value - ASC', () => assert('value', 'ASC', [ 'Bar', 'Foo' ], [ 50, 100 ]));
|
||||
it('value - DESC', () => assert('value', 'DESC', [ 'Foo', 'Bar' ], [ 100, 50 ]));
|
||||
it('name - ASC', () => assert('name', 'ASC', ['Bar', 'Foo'], [50, 100]));
|
||||
it('name - DESC', () => assert('name', 'DESC', ['Foo', 'Bar'], [100, 50]));
|
||||
it('value - ASC', () => assert('value', 'ASC', ['Bar', 'Foo'], [50, 100]));
|
||||
it('value - DESC', () => assert('value', 'DESC', ['Foo', 'Bar'], [100, 50]));
|
||||
});
|
||||
|
||||
describe('renders properly paginated stats when pagination is set', () => {
|
||||
@@ -83,7 +83,7 @@ describe('<SortableBarChartCard />', () => {
|
||||
};
|
||||
});
|
||||
|
||||
const buildExpected = (size: number): string[] => [ 'Foo', 'Bar', ...rangeOf(size - 2, (i) => `key_${i}`) ];
|
||||
const buildExpected = (size: number): string[] => ['Foo', 'Bar', ...rangeOf(size - 2, (i) => `key_${i}`)];
|
||||
|
||||
it('50 items per page', () => assert(50, buildExpected(50)));
|
||||
it('100 items per page', () => assert(100, buildExpected(100)));
|
||||
|
||||
Reference in New Issue
Block a user