mirror of
https://github.com/apache/superset.git
synced 2026-04-20 16:44:46 +00:00
Prettify the frontend code (#8648)
* Add Prettier global configs * Format js/jsx/ts/tsx/less files
This commit is contained in:
@@ -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',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user