Updated to airbnb coding styles

This commit is contained in:
Alejandro Celaya
2022-03-26 12:17:42 +01:00
parent 4e9b19afd1
commit a2df486280
239 changed files with 2210 additions and 3549 deletions

View File

@@ -62,10 +62,10 @@ describe('<RealTimeUpdatesSettings />', () => {
});
it.each([
[ 1, 'minute' ],
[ 2, 'minutes' ],
[ 10, 'minutes' ],
[ 100, 'minutes' ],
[1, 'minute'],
[2, 'minutes'],
[10, 'minutes'],
[100, 'minutes'],
])('shows expected children when interval is greater than 0', (interval, minutesWord) => {
const wrapper = createWrapper({ enabled: true, interval });
const span = wrapper.find('span');
@@ -78,7 +78,7 @@ describe('<RealTimeUpdatesSettings />', () => {
expect(input.prop('value')).toEqual(`${interval}`);
});
it.each([[ undefined ], [ 0 ]])('shows expected children when interval is 0 or undefined', (interval) => {
it.each([[undefined], [0]])('shows expected children when interval is 0 or undefined', (interval) => {
const wrapper = createWrapper({ enabled: true, interval });
const span = wrapper.find('span');
const formText = wrapper.find(FormText).at(1);

View File

@@ -25,9 +25,9 @@ describe('<ShortUrlCreationSettings />', () => {
afterEach(jest.clearAllMocks);
it.each([
[{ validateUrls: true }, true ],
[{ validateUrls: false }, false ],
[ undefined, false ],
[{ validateUrls: true }, true],
[{ validateUrls: false }, false],
[undefined, false],
])('URL validation switch is toggled if option is true', (shortUrlCreation, expectedChecked) => {
const wrapper = createWrapper(shortUrlCreation);
const urlValidationToggle = wrapper.find(ToggleSwitch).first();
@@ -36,9 +36,9 @@ describe('<ShortUrlCreationSettings />', () => {
});
it.each([
[{ forwardQuery: true }, true ],
[{ forwardQuery: false }, false ],
[{}, true ],
[{ forwardQuery: true }, true],
[{ forwardQuery: false }, false],
[{}, true],
])('forward query switch is toggled if option is true', (shortUrlCreation, expectedChecked) => {
const wrapper = createWrapper({ validateUrls: true, ...shortUrlCreation });
const forwardQueryToggle = wrapper.find(ToggleSwitch).last();
@@ -47,9 +47,9 @@ describe('<ShortUrlCreationSettings />', () => {
});
it.each([
[{ validateUrls: true }, '<b>Validate URL</b> checkbox will be <b>checked</b>' ],
[{ validateUrls: false }, '<b>Validate URL</b> checkbox will be <b>unchecked</b>' ],
[ undefined, '<b>Validate URL</b> checkbox will be <b>unchecked</b>' ],
[{ validateUrls: true }, '<b>Validate URL</b> checkbox will be <b>checked</b>'],
[{ validateUrls: false }, '<b>Validate URL</b> checkbox will be <b>unchecked</b>'],
[undefined, '<b>Validate URL</b> checkbox will be <b>unchecked</b>'],
])('shows expected helper text for URL validation', (shortUrlCreation, expectedText) => {
const wrapper = createWrapper(shortUrlCreation);
const validateUrlText = wrapper.find(FormText).first();
@@ -58,9 +58,9 @@ describe('<ShortUrlCreationSettings />', () => {
});
it.each([
[{ forwardQuery: true }, '<b>Forward query params on redirect</b> checkbox will be <b>checked</b>' ],
[{ forwardQuery: false }, '<b>Forward query params on redirect</b> checkbox will be <b>unchecked</b>' ],
[{}, '<b>Forward query params on redirect</b> checkbox will be <b>checked</b>' ],
[{ forwardQuery: true }, '<b>Forward query params on redirect</b> checkbox will be <b>checked</b>'],
[{ forwardQuery: false }, '<b>Forward query params on redirect</b> checkbox will be <b>unchecked</b>'],
[{}, '<b>Forward query params on redirect</b> checkbox will be <b>checked</b>'],
])('shows expected helper text for query forwarding', (shortUrlCreation, expectedText) => {
const wrapper = createWrapper({ validateUrls: true, ...shortUrlCreation });
const forwardQueryText = wrapper.find(FormText).at(1);
@@ -69,13 +69,13 @@ describe('<ShortUrlCreationSettings />', () => {
});
it.each([
[ { tagFilteringMode: 'includes' } as ShortUrlsSettings, 'Suggest tags including input', 'including' ],
[{ tagFilteringMode: 'includes' } as ShortUrlsSettings, 'Suggest tags including input', 'including'],
[
{ tagFilteringMode: 'startsWith' } as ShortUrlsSettings,
'Suggest tags starting with input',
'starting with',
],
[ undefined, 'Suggest tags starting with input', 'starting with' ],
[undefined, 'Suggest tags starting with input', 'starting with'],
])('shows expected texts for tags suggestions', (shortUrlCreation, expectedText, expectedHint) => {
const wrapper = createWrapper(shortUrlCreation);
const hintText = wrapper.find(FormText).last();
@@ -85,7 +85,7 @@ describe('<ShortUrlCreationSettings />', () => {
expect(hintText.html()).toContain(expectedHint);
});
it.each([[ true ], [ false ]])('invokes setShortUrlCreationSettings when URL validation toggle value changes', (validateUrls) => {
it.each([[true], [false]])('invokes setShortUrlCreationSettings when URL validation toggle value changes', (validateUrls) => {
const wrapper = createWrapper();
const urlValidationToggle = wrapper.find(ToggleSwitch).first();
@@ -94,7 +94,7 @@ describe('<ShortUrlCreationSettings />', () => {
expect(setShortUrlCreationSettings).toHaveBeenCalledWith({ validateUrls });
});
it.each([[ true ], [ false ]])('invokes setShortUrlCreationSettings when forward query toggle value changes', (forwardQuery) => {
it.each([[true], [false]])('invokes setShortUrlCreationSettings when forward query toggle value changes', (forwardQuery) => {
const wrapper = createWrapper();
const urlValidationToggle = wrapper.find(ToggleSwitch).last();

View File

@@ -24,8 +24,8 @@ describe('<ShortUrlsListSettings />', () => {
afterEach(jest.clearAllMocks);
it.each([
[ undefined, DEFAULT_SHORT_URLS_ORDERING ],
[{}, DEFAULT_SHORT_URLS_ORDERING ],
[undefined, DEFAULT_SHORT_URLS_ORDERING],
[{}, DEFAULT_SHORT_URLS_ORDERING],
[{ defaultOrdering: {} }, {}],
[{ defaultOrdering: { field: 'longUrl', dir: 'DESC' } as ShortUrlsOrder }, { field: 'longUrl', dir: 'DESC' }],
[{ defaultOrdering: { field: 'visits', dir: 'ASC' } as ShortUrlsOrder }, { field: 'visits', dir: 'ASC' }],
@@ -37,10 +37,10 @@ describe('<ShortUrlsListSettings />', () => {
});
it.each([
[ undefined, undefined ],
[ 'longUrl', 'ASC' ],
[ 'visits', undefined ],
[ 'title', 'DESC' ],
[undefined, undefined],
['longUrl', 'ASC'],
['visits', undefined],
['title', 'DESC'],
])('invokes setSettings when ordering changes', (field, dir) => {
const wrapper = createWrapper();
const dropdown = wrapper.find(OrderingDropdown);

View File

@@ -28,10 +28,10 @@ describe('<TagsSettings />', () => {
});
it.each([
[ undefined, 'cards' ],
[{}, 'cards' ],
[{ defaultMode: 'cards' as TagsMode }, 'cards' ],
[{ defaultMode: 'list' as TagsMode }, 'list' ],
[undefined, 'cards'],
[{}, 'cards'],
[{ defaultMode: 'cards' as TagsMode }, 'cards'],
[{ defaultMode: 'list' as TagsMode }, 'list'],
])('shows expected tags displaying mode', (tags, expectedMode) => {
const wrapper = createWrapper(tags);
const dropdown = wrapper.find(TagsModeDropdown);
@@ -42,8 +42,8 @@ describe('<TagsSettings />', () => {
});
it.each([
[ 'cards' as TagsMode ],
[ 'list' as TagsMode ],
['cards' as TagsMode],
['list' as TagsMode],
])('invokes setTagsSettings when tags mode changes', (defaultMode) => {
const wrapper = createWrapper();
const dropdown = wrapper.find(TagsModeDropdown);
@@ -54,7 +54,7 @@ describe('<TagsSettings />', () => {
});
it.each([
[ undefined, {}],
[undefined, {}],
[{}, {}],
[{ defaultOrdering: {} }, {}],
[{ defaultOrdering: { field: 'tag', dir: 'DESC' } as TagsOrder }, { field: 'tag', dir: 'DESC' }],
@@ -67,10 +67,10 @@ describe('<TagsSettings />', () => {
});
it.each([
[ undefined, undefined ],
[ 'tag', 'ASC' ],
[ 'visits', undefined ],
[ 'shortUrls', 'DESC' ],
[undefined, undefined],
['tag', 'ASC'],
['visits', undefined],
['shortUrls', 'DESC'],
])('invokes setTagsSettings when ordering changes', (field, dir) => {
const wrapper = createWrapper();
const dropdown = wrapper.find(OrderingDropdown);

View File

@@ -20,9 +20,9 @@ describe('<UserInterfaceSettings />', () => {
afterEach(jest.clearAllMocks);
it.each([
[{ theme: 'dark' as Theme }, true ],
[{ theme: 'light' as Theme }, false ],
[ undefined, false ],
[{ theme: 'dark' as Theme }, true],
[{ theme: 'light' as Theme }, false],
[undefined, false],
])('toggles switch if theme is dark', (ui, expectedChecked) => {
const wrapper = createWrapper(ui);
const toggle = wrapper.find(ToggleSwitch);
@@ -31,9 +31,9 @@ describe('<UserInterfaceSettings />', () => {
});
it.each([
[{ theme: 'dark' as Theme }, faMoon ],
[{ theme: 'light' as Theme }, faSun ],
[ undefined, faSun ],
[{ theme: 'dark' as Theme }, faMoon],
[{ theme: 'light' as Theme }, faSun],
[undefined, faSun],
])('shows different icons based on theme', (ui, expectedIcon) => {
const wrapper = createWrapper(ui);
const icon = wrapper.find(FontAwesomeIcon);
@@ -42,8 +42,8 @@ describe('<UserInterfaceSettings />', () => {
});
it.each([
[ true, 'dark' ],
[ false, 'light' ],
[true, 'dark'],
[false, 'light'],
])('invokes setUiSettings when theme toggle value changes', (checked, theme) => {
const wrapper = createWrapper();
const toggle = wrapper.find(ToggleSwitch);

View File

@@ -27,8 +27,8 @@ describe('<VisitsSettings />', () => {
});
it.each([
[ Mock.all<Settings>(), 'last30Days' ],
[ Mock.of<Settings>({ visits: {} }), 'last30Days' ],
[Mock.all<Settings>(), 'last30Days'],
[Mock.of<Settings>({ visits: {} }), 'last30Days'],
[
Mock.of<Settings>({
visits: {

View File

@@ -25,7 +25,7 @@ describe('settingsReducer', () => {
});
describe('toggleRealTimeUpdates', () => {
it.each([[ true ], [ false ]])('updates settings with provided value and then loads updates again', (enabled) => {
it.each([[true], [false]])('updates settings with provided value and then loads updates again', (enabled) => {
const result = toggleRealTimeUpdates(enabled);
expect(result).toEqual({ type: SET_SETTINGS, realTimeUpdates: { enabled } });
@@ -33,7 +33,7 @@ describe('settingsReducer', () => {
});
describe('setRealTimeUpdatesInterval', () => {
it.each([[ 0 ], [ 1 ], [ 2 ], [ 10 ]])('updates settings with provided value and then loads updates again', (interval) => {
it.each([[0], [1], [2], [10]])('updates settings with provided value and then loads updates again', (interval) => {
const result = setRealTimeUpdatesInterval(interval);
expect(result).toEqual({ type: SET_SETTINGS, realTimeUpdates: { interval } });