Commit 9b1d8b4c authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 24 files: 8 of 8

Mandatory not to break master. Automatically created with prettier.
parent 57da6321
......@@ -11,11 +11,7 @@ const CACHE_PATHS = [
const resolvePath = file => path.resolve(__dirname, '../..', file);
const readFile = file => fs.readFileSync(file);
const fileHash = buffer =>
crypto
.createHash('md5')
.update(buffer)
.digest('hex');
const fileHash = buffer => crypto.createHash('md5').update(buffer).digest('hex');
module.exports = () => {
const fileBuffers = CACHE_PATHS.map(resolvePath).map(readFile);
......
......@@ -104,7 +104,7 @@ if (specFilters.length) {
}
// Karma configuration
module.exports = function(config) {
module.exports = function (config) {
process.env.TZ = 'Etc/UTC';
const fixturesPath = `tmp/tests/frontend/fixtures${IS_EE ? '-ee' : ''}`;
......
......@@ -344,7 +344,7 @@ module.exports = {
// webpack-rails only needs assetsByChunkName to function properly
new StatsWriterPlugin({
filename: 'manifest.json',
transform: function(data, opts) {
transform: function (data, opts) {
const stats = opts.compiler.getStats().toJson({
chunkModules: false,
source: false,
......
......@@ -9,12 +9,7 @@ const exec = (command, args) => {
return execFileSync(command, args, options);
};
const execGitCmd = args =>
exec('git', args)
.trim()
.toString()
.split('\n')
.filter(Boolean);
const execGitCmd = args => exec('git', args).trim().toString().split('\n').filter(Boolean);
module.exports = {
getStagedFiles: fileExtensionFilter => {
......
......@@ -11,7 +11,7 @@ const globIgnore = ['**/node_modules/**', 'vendor/**', 'public/**'];
const readFileAsync = (file, options) =>
new Promise((resolve, reject) => {
fs.readFile(file, options, function(err, data) {
fs.readFile(file, options, function (err, data) {
if (err) reject(err);
else resolve(data);
});
......@@ -19,7 +19,7 @@ const readFileAsync = (file, options) =>
const writeFileAsync = (file, data, options) =>
new Promise((resolve, reject) => {
fs.writeFile(file, data, options, function(err) {
fs.writeFile(file, data, options, function (err) {
if (err) reject(err);
else resolve();
});
......
......@@ -8,12 +8,12 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
},
});
module.exports = stylelint.createPlugin(ruleName, function(enabled) {
module.exports = stylelint.createPlugin(ruleName, function (enabled) {
if (!enabled) {
return;
}
return function(root, result) {
return function (root, result) {
const selectorGroups = {};
utils.createPropertiesHashmap(root, result, ruleName, messages, selectorGroups, true);
};
......
......@@ -10,12 +10,12 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
},
});
module.exports = stylelint.createPlugin(ruleName, function(enabled) {
module.exports = stylelint.createPlugin(ruleName, function (enabled) {
if (!enabled) {
return;
}
return function(root, result) {
return function (root, result) {
utils.createPropertiesHashmap(root, result, ruleName, messages, utilityClasses, false);
};
});
......
......@@ -42,7 +42,7 @@ sass.render(
prettierOptions,
);
fs.writeFile(hashMapPath, prettyHashmap, function(err) {
fs.writeFile(hashMapPath, prettyHashmap, function (err) {
if (err) {
return console.log(err);
}
......
......@@ -25,7 +25,7 @@ module.exports.createPropertiesHashmap = (
)
) {
let cssArray = [];
rule.nodes.forEach(function(property) {
rule.nodes.forEach(function (property) {
const { prop, value } = property;
if (property && value) {
const propval = `${prop}${value}${property.important ? '!important' : ''}`;
......
......@@ -51,7 +51,7 @@ else {
// print useful messages for nodemon events
nodemon
.on('start', function() {
.on('start', function () {
console.log(`Starting webpack webserver on http://${DEV_SERVER_HOST}:${DEV_SERVER_PORT}`);
if (STATIC_MODE) {
console.log('You are starting webpack in compile-once mode');
......@@ -59,10 +59,10 @@ nodemon
console.log('If you change them often, you might want to unset DEV_SERVER_STATIC');
}
})
.on('quit', function() {
.on('quit', function () {
console.log('Shutting down webpack process');
process.exit();
})
.on('restart', function(files) {
.on('restart', function (files) {
console.log('Restarting webpack process due to: ', files);
});
......@@ -57,9 +57,7 @@ describe('AwardsHandler', () => {
preloadFixtures('snippets/show.html');
const openAndWaitForEmojiMenu = (sel = '.js-add-award') => {
$(sel)
.eq(0)
.click();
$(sel).eq(0).click();
jest.runOnlyPendingTimers();
......@@ -337,9 +335,7 @@ describe('AwardsHandler', () => {
it('should remove already selected emoji', async () => {
await openEmojiMenuAndAddEmoji();
$('.js-add-award')
.eq(0)
.click();
$('.js-add-award').eq(0).click();
const $block = $('.js-awards-block');
const $emoji = $('.emoji-menu').find(
`.emoji-menu-list:not(.frequent-emojis) ${emojiSelector}`,
......
......@@ -78,9 +78,7 @@ describe('ConfirmModal', () => {
describe('when button clicked', () => {
beforeEach(() => {
initConfirmModal();
findJsHooks()
.item(0)
.click();
findJsHooks().item(0).click();
});
it('does not replace JsHook with GlModal', () => {
......@@ -116,9 +114,7 @@ describe('ConfirmModal', () => {
`(`when multiple buttons exist`, ({ index }) => {
beforeEach(() => {
initConfirmModal();
findJsHooks()
.item(index)
.click();
findJsHooks().item(index).click();
});
it('correct props are passed to gl-modal', () => {
......
......@@ -27,20 +27,14 @@ describe('CreateItemDropdown', () => {
function createItemAndClearInput(text) {
// Filter for the new item
$wrapperEl
.find('.dropdown-input-field')
.val(text)
.trigger('input');
$wrapperEl.find('.dropdown-input-field').val(text).trigger('input');
// Create the new item
const $createButton = $wrapperEl.find('.js-dropdown-create-new-item');
$createButton.click();
// Clear out the filter
$wrapperEl
.find('.dropdown-input-field')
.val('')
.trigger('input');
$wrapperEl.find('.dropdown-input-field').val('').trigger('input');
}
beforeEach(() => {
......@@ -91,10 +85,7 @@ describe('CreateItemDropdown', () => {
$('.js-dropdown-menu-toggle').click();
// Filter for the new item
$wrapperEl
.find('.dropdown-input-field')
.val(NEW_ITEM_TEXT)
.trigger('input');
$wrapperEl.find('.dropdown-input-field').val(NEW_ITEM_TEXT).trigger('input');
});
it('create new item button should include the filter text', () => {
......
......@@ -230,10 +230,7 @@ describe('deprecatedJQueryDropdown', () => {
it('should still have input value on close and restore', () => {
const $searchInput = $(SEARCH_INPUT_SELECTOR);
initDropDown.call(this, false, true);
$searchInput
.trigger('focus')
.val('g')
.trigger('input');
$searchInput.trigger('focus').val('g').trigger('input');
expect($searchInput.val()).toEqual('g');
test.dropdownButtonElement.trigger('hidden.bs.dropdown');
......
......@@ -656,10 +656,7 @@ describe('GfmAutoComplete', () => {
});
const triggerDropdown = text => {
$textarea
.trigger('focus')
.val(text)
.caret('pos', -1);
$textarea.trigger('focus').val(text).caret('pos', -1);
$textarea.trigger('keyup');
return new Promise(window.requestAnimationFrame);
......
......@@ -41,18 +41,9 @@ describe('GL Style Field Errors', () => {
});
it('should not show any errors before submit attempt', () => {
testContext.$form
.find('.email')
.val('not-a-valid-email')
.keyup();
testContext.$form
.find('.text-required')
.val('')
.keyup();
testContext.$form
.find('.alphanumberic')
.val('?---*')
.keyup();
testContext.$form.find('.email').val('not-a-valid-email').keyup();
testContext.$form.find('.text-required').val('').keyup();
testContext.$form.find('.alphanumberic').val('?---*').keyup();
const errorsShown = testContext.$form.find('.gl-field-error-outline');
......@@ -60,18 +51,9 @@ describe('GL Style Field Errors', () => {
});
it('should show errors when input valid is submitted', () => {
testContext.$form
.find('.email')
.val('not-a-valid-email')
.keyup();
testContext.$form
.find('.text-required')
.val('')
.keyup();
testContext.$form
.find('.alphanumberic')
.val('?---*')
.keyup();
testContext.$form.find('.email').val('not-a-valid-email').keyup();
testContext.$form.find('.text-required').val('').keyup();
testContext.$form.find('.alphanumberic').val('?---*').keyup();
testContext.$form.submit();
......
......@@ -88,9 +88,7 @@ describe('LineHighlighter', () => {
describe('clickHandler', () => {
it('handles clicking on a child icon element', () => {
const spy = jest.spyOn(testContext.class, 'setHash');
$('#L13 i')
.mousedown()
.click();
$('#L13 i').mousedown().click();
expect(spy).toHaveBeenCalledWith(13);
expect($('#LC13')).toHaveClass(testContext.css);
......
......@@ -40,10 +40,7 @@ export default {
let clearMatch;
try {
clearReceived = received
.replace(/\s\s+/gm, ' ')
.replace(/\s\./gm, '.')
.trim();
clearReceived = received.replace(/\s\s+/gm, ' ').replace(/\s\./gm, '.').trim();
} catch (e) {
return { actual: received, message: 'The received value is not a string', pass: false };
}
......
......@@ -32,10 +32,7 @@ describe('MergeRequest', () => {
jest.spyOn($, 'ajax').mockImplementation();
const changeEvent = document.createEvent('HTMLEvents');
changeEvent.initEvent('change', true, true);
$('input[type=checkbox]')
.first()
.attr('checked', true)[0]
.dispatchEvent(changeEvent);
$('input[type=checkbox]').first().attr('checked', true)[0].dispatchEvent(changeEvent);
setImmediate(() => {
expect($('.js-task-list-field').val()).toBe(
'- [x] Task List Item\n- [ ]\n- [ ] Task List Item 2\n',
......@@ -49,10 +46,7 @@ describe('MergeRequest', () => {
jest.spyOn($, 'ajax').mockImplementation();
const changeEvent = document.createEvent('HTMLEvents');
changeEvent.initEvent('change', true, true);
$('input[type=checkbox]')
.last()
.attr('checked', true)[0]
.dispatchEvent(changeEvent);
$('input[type=checkbox]').last().attr('checked', true)[0].dispatchEvent(changeEvent);
setImmediate(() => {
expect($('.js-task-list-field').val()).toBe(
'- [ ] Task List Item\n- [ ]\n- [x] Task List Item 2\n',
......
......@@ -12,9 +12,7 @@ describe('Branch', () => {
preloadFixtures('branches/new_branch.html');
function fillNameWith(value) {
$('.js-branch-name')
.val(value)
.trigger('blur');
$('.js-branch-name').val(value).trigger('blur');
}
function expectToHaveError(error) {
......
......@@ -3,9 +3,7 @@ import OAuthRememberMe from '~/pages/sessions/new/oauth_remember_me';
describe('OAuthRememberMe', () => {
const findFormAction = selector => {
return $(`#oauth-container .oauth-login${selector}`)
.parent('form')
.attr('action');
return $(`#oauth-container .oauth-login${selector}`).parent('form').attr('action');
};
preloadFixtures('static/oauth_remember_me.html');
......
......@@ -58,7 +58,10 @@ describe('ProjectFindFile', () => {
mock = new MockAdapter(axios);
element = $(TEMPLATE);
mock.onGet(FILE_FIND_URL).replyOnce(200, files.map(x => x.path));
mock.onGet(FILE_FIND_URL).replyOnce(
200,
files.map(x => x.path),
);
getProjectFindFileInstance(); // This triggers a load / axios call + subsequent render in the constructor
setImmediate(done);
......
......@@ -13,41 +13,19 @@ describe('setupTransferEdit', () => {
});
it('disables submit button on load', () => {
expect(
$(formSelector)
.find(':submit')
.prop('disabled'),
).toBe(true);
expect($(formSelector).find(':submit').prop('disabled')).toBe(true);
});
it('enables submit button when selection changes to non-empty value', () => {
const nonEmptyValue = $(formSelector)
.find(targetSelector)
.find('option')
.not(':empty')
.val();
$(formSelector)
.find(targetSelector)
.val(nonEmptyValue)
.trigger('change');
expect(
$(formSelector)
.find(':submit')
.prop('disabled'),
).toBeFalsy();
const nonEmptyValue = $(formSelector).find(targetSelector).find('option').not(':empty').val();
$(formSelector).find(targetSelector).val(nonEmptyValue).trigger('change');
expect($(formSelector).find(':submit').prop('disabled')).toBeFalsy();
});
it('disables submit button when selection changes to empty value', () => {
$(formSelector)
.find(targetSelector)
.val('')
.trigger('change');
expect(
$(formSelector)
.find(':submit')
.prop('disabled'),
).toBe(true);
$(formSelector).find(targetSelector).val('').trigger('change');
expect($(formSelector).find(':submit').prop('disabled')).toBe(true);
});
});
......@@ -19,7 +19,7 @@ describe('VersionCheckImage', () => {
it('registers an error event', () => {
jest.spyOn($.prototype, 'on').mockImplementation(() => {});
// eslint-disable-next-line func-names
jest.spyOn($.prototype, 'off').mockImplementation(function() {
jest.spyOn($.prototype, 'off').mockImplementation(function () {
return this;
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment