Prettify the frontend code (#8648)

* Add Prettier global configs

* Format js/jsx/ts/tsx/less files
This commit is contained in:
Erik Ritter
2019-11-27 14:02:48 -08:00
committed by GitHub
parent e21f768a92
commit 44d919c757
398 changed files with 8700 additions and 6117 deletions

View File

@@ -16,15 +16,27 @@
* specific language governing permissions and limitations
* under the License.
*/
import { optionFromValue, prepareCopyToClipboardTabularData } from '../../../src/utils/common';
import {
optionFromValue,
prepareCopyToClipboardTabularData,
} from '../../../src/utils/common';
describe('utils/common', () => {
describe('optionFromValue', () => {
it('converts values as expected', () => {
expect(optionFromValue(false)).toEqual({ value: false, label: '<false>' });
expect(optionFromValue(false)).toEqual({
value: false,
label: '<false>',
});
expect(optionFromValue(true)).toEqual({ value: true, label: '<true>' });
expect(optionFromValue(null)).toEqual({ value: '<NULL>', label: '<NULL>' });
expect(optionFromValue('')).toEqual({ value: '', label: '<empty string>' });
expect(optionFromValue(null)).toEqual({
value: '<NULL>',
label: '<NULL>',
});
expect(optionFromValue('')).toEqual({
value: '',
label: '<empty string>',
});
expect(optionFromValue('foo')).toEqual({ value: 'foo', label: 'foo' });
expect(optionFromValue(5)).toEqual({ value: 5, label: '5' });
});
@@ -36,10 +48,12 @@ describe('utils/common', () => {
});
it('converts non empty array', () => {
const array = [
{ column1: 'lorem', column2: 'ipsum' },
{ column1: 'dolor', column2: 'sit', column3: 'amet' },
{ column1: 'lorem', column2: 'ipsum' },
{ column1: 'dolor', column2: 'sit', column3: 'amet' },
];
expect(prepareCopyToClipboardTabularData(array)).toEqual('lorem\tipsum\ndolor\tsit\tamet\n');
expect(prepareCopyToClipboardTabularData(array)).toEqual(
'lorem\tipsum\ndolor\tsit\tamet\n',
);
});
});
});

View File

@@ -27,7 +27,7 @@ describe('getClientErrorObject()', () => {
it('Returns a Promise that resolves to an object with an error key', () => {
const error = 'error';
return getClientErrorObject(error).then((errorObj) => {
return getClientErrorObject(error).then(errorObj => {
expect(errorObj).toMatchObject({ error });
});
});
@@ -36,15 +36,17 @@ describe('getClientErrorObject()', () => {
const jsonError = { something: 'something', error: 'Error message' };
const jsonErrorString = JSON.stringify(jsonError);
return getClientErrorObject(new Response(jsonErrorString)).then((errorObj) => {
expect(errorObj).toMatchObject(jsonError);
});
return getClientErrorObject(new Response(jsonErrorString)).then(
errorObj => {
expect(errorObj).toMatchObject(jsonError);
},
);
});
it('Handles Response that can be parsed as text', () => {
const textError = 'Hello I am a text error';
return getClientErrorObject(new Response(textError)).then((errorObj) => {
return getClientErrorObject(new Response(textError)).then(errorObj => {
expect(errorObj).toMatchObject({ error: textError });
});
});
@@ -52,7 +54,7 @@ describe('getClientErrorObject()', () => {
it('Handles plain text as input', () => {
const error = 'error';
return getClientErrorObject(error).then((errorObj) => {
return getClientErrorObject(error).then(errorObj => {
expect(errorObj).toMatchObject({ error });
});
});