[reviewable] Integrate @superset-ui/{core,color,chart} modules (#6234)

* Add d3 micro packages

* Replace d3 imports with specific modules import

* Define d3 colors

* import specific d3 submodules instead of entire d3

* update function name

* move function location and fix small bug

* Move primary color to control

* remove colorscalefactory usage

* remove unused d3

* fix unit test

* fix color picker

* use @superset-ui/color

* update package version

* remove files that are extracted

* replace all references

* fix two files

* Revert some changes to split to another PR

* remove adaptor

* Address Christine's comment

* remove d3 v3 from calendar

* remove d3.scale.threshold

* Get rid of colorScalerFactory and revise hexToRGB

* fix color cleaning

* fix lint
This commit is contained in:
Krist Wongsuphasawat
2018-11-11 10:07:05 -08:00
committed by Chris Williams
parent 841d5e6338
commit a7b52da6ce
129 changed files with 227 additions and 4324 deletions

View File

@@ -1,27 +0,0 @@
import convertKeysToCamelCase from '../../../src/utils/convertKeysToCamelCase';
describe('convertKeysToCamelCase(object)', () => {
it('returns undefined for undefined input', () => {
expect(convertKeysToCamelCase(undefined)).toBeUndefined();
});
it('returns null for null input', () => {
expect(convertKeysToCamelCase(null)).toBeNull();
});
it('returns a new object that has all keys in camelCase', () => {
const input = {
is_happy: true,
'is-angry': false,
isHungry: false,
};
expect(convertKeysToCamelCase(input)).toEqual({
isHappy: true,
isAngry: false,
isHungry: false,
});
});
it('throws error if input is not a plain object', () => {
expect(() => { convertKeysToCamelCase({}); }).not.toThrowError();
expect(() => { convertKeysToCamelCase(''); }).toThrowError();
expect(() => { convertKeysToCamelCase(new Map()); }).toThrowError();
});
});

View File

@@ -1,20 +0,0 @@
import isDefined from '../../../src/utils/isDefined';
describe('isDefined(value)', () => {
it('returns true if value is not null and not undefined', () => {
expect(isDefined(0)).toBe(true);
expect(isDefined(1)).toBe(true);
expect(isDefined('')).toBe(true);
expect(isDefined('a')).toBe(true);
expect(isDefined([])).toBe(true);
expect(isDefined([0])).toBe(true);
expect(isDefined([1])).toBe(true);
expect(isDefined({})).toBe(true);
expect(isDefined({ a: 1 })).toBe(true);
expect(isDefined([{}])).toBe(true);
});
it('returns false otherwise', () => {
expect(isDefined(null)).toBe(false);
expect(isDefined(undefined)).toBe(false);
});
});

View File

@@ -1,7 +0,0 @@
import isRequired from '../../../src/utils/isRequired';
describe('isRequired(field)', () => {
it('should throw error with the given field in the message', () => {
expect(() => isRequired('myField')).toThrowError(Error);
});
});

View File

@@ -1,42 +0,0 @@
import makeSingleton from '../../../src/utils/makeSingleton';
describe('makeSingleton()', () => {
class Dog {
constructor(name) {
this.name = name;
}
sit() {
this.isSitting = true;
}
}
describe('makeSingleton(BaseClass)', () => {
const getInstance = makeSingleton(Dog);
it(
'returns a function for getting singleton instance of a given base class',
() => {
expect(typeof getInstance).toBe('function');
expect(getInstance()).toBeInstanceOf(Dog);
},
);
it('returned function returns same instance across all calls', () => {
expect(getInstance()).toBe(getInstance());
});
});
describe('makeSingleton(BaseClass, ...args)', () => {
const getInstance = makeSingleton(Dog, 'Doug');
it(
'returns a function for getting singleton instance of a given base class constructed with the given arguments',
() => {
expect(typeof getInstance).toBe('function');
expect(getInstance()).toBeInstanceOf(Dog);
expect(getInstance().name).toBe('Doug');
},
);
it('returned function returns same instance across all calls', () => {
expect(getInstance()).toBe(getInstance());
});
});
});