mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
[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:
committed by
Chris Williams
parent
841d5e6338
commit
a7b52da6ce
@@ -84,7 +84,7 @@ describe('getBreakPointColorScaler', () => {
|
||||
const features = [];
|
||||
const scaler = getBreakPointColorScaler(fd, features);
|
||||
expect(scaler({ count: -1 })).toEqual([0, 0, 0, 0]);
|
||||
expect(scaler({ count: 11 })).toEqual([0, 0, 0, 0]);
|
||||
expect(scaler({ count: 11 })).toEqual([255, 255, 255, 0]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
import ChartPlugin from '../../../../src/visualizations/core/models/ChartPlugin';
|
||||
import ChartMetadata from '../../../../src/visualizations/core/models/ChartMetadata';
|
||||
|
||||
describe('ChartPlugin', () => {
|
||||
const metadata = new ChartMetadata({});
|
||||
|
||||
it('exists', () => {
|
||||
expect(ChartPlugin).toBeDefined();
|
||||
});
|
||||
|
||||
describe('new ChartPlugin()', () => {
|
||||
it('creates a new plugin', () => {
|
||||
const plugin = new ChartPlugin({
|
||||
metadata,
|
||||
Chart() {},
|
||||
});
|
||||
expect(plugin).toBeInstanceOf(ChartPlugin);
|
||||
});
|
||||
it('throws an error if metadata is not specified', () => {
|
||||
expect(() => new ChartPlugin()).toThrowError(Error);
|
||||
});
|
||||
it('throws an error if none of Chart or loadChart is specified', () => {
|
||||
expect(() => new ChartPlugin({ metadata })).toThrowError(Error);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.register(key)', () => {
|
||||
const plugin = new ChartPlugin({
|
||||
metadata,
|
||||
Chart() {},
|
||||
});
|
||||
it('throws an error if key is not provided', () => {
|
||||
expect(() => plugin.register()).toThrowError(Error);
|
||||
expect(() => plugin.configure({ key: 'abc' }).register()).not.toThrowError(Error);
|
||||
});
|
||||
it('returns itself', () => {
|
||||
expect(plugin.configure({ key: 'abc' }).register()).toBe(plugin);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,52 +0,0 @@
|
||||
import Plugin from '../../../../src/visualizations/core/models/Plugin';
|
||||
|
||||
describe('Plugin', () => {
|
||||
it('exists', () => {
|
||||
expect(Plugin).toBeDefined();
|
||||
});
|
||||
|
||||
describe('new Plugin()', () => {
|
||||
it('creates a new plugin', () => {
|
||||
const plugin = new Plugin();
|
||||
expect(plugin).toBeInstanceOf(Plugin);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.configure(config, replace)', () => {
|
||||
it(
|
||||
'extends the default config with given config when replace is not set or false',
|
||||
() => {
|
||||
const plugin = new Plugin();
|
||||
plugin.configure({ key: 'abc', foo: 'bar' });
|
||||
plugin.configure({ key: 'def' });
|
||||
expect(plugin.config).toEqual({ key: 'def', foo: 'bar' });
|
||||
},
|
||||
);
|
||||
it(
|
||||
'replaces the default config with given config when replace is true',
|
||||
() => {
|
||||
const plugin = new Plugin();
|
||||
plugin.configure({ key: 'abc', foo: 'bar' });
|
||||
plugin.configure({ key: 'def' }, true);
|
||||
expect(plugin.config).toEqual({ key: 'def' });
|
||||
},
|
||||
);
|
||||
it('returns the plugin itself', () => {
|
||||
const plugin = new Plugin();
|
||||
expect(plugin.configure({ key: 'abc' })).toBe(plugin);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.resetConfig()', () => {
|
||||
it('resets config back to default', () => {
|
||||
const plugin = new Plugin();
|
||||
plugin.configure({ key: 'abc', foo: 'bar' });
|
||||
plugin.resetConfig();
|
||||
expect(plugin.config).toEqual({});
|
||||
});
|
||||
it('returns the plugin itself', () => {
|
||||
const plugin = new Plugin();
|
||||
expect(plugin.resetConfig()).toBe(plugin);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,63 +0,0 @@
|
||||
import Preset from '../../../../src/visualizations/core/models/Preset';
|
||||
import Plugin from '../../../../src/visualizations/core/models/Plugin';
|
||||
|
||||
describe('Preset', () => {
|
||||
it('exists', () => {
|
||||
expect(Preset).toBeDefined();
|
||||
});
|
||||
|
||||
describe('new Preset()', () => {
|
||||
it('creates new preset', () => {
|
||||
const preset = new Preset();
|
||||
expect(preset).toBeInstanceOf(Preset);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.register()', () => {
|
||||
it('register all listed presets then plugins', () => {
|
||||
const values = [];
|
||||
class Plugin1 extends Plugin {
|
||||
register() {
|
||||
values.push(1);
|
||||
}
|
||||
}
|
||||
class Plugin2 extends Plugin {
|
||||
register() {
|
||||
values.push(2);
|
||||
}
|
||||
}
|
||||
class Plugin3 extends Plugin {
|
||||
register() {
|
||||
values.push(3);
|
||||
}
|
||||
}
|
||||
class Plugin4 extends Plugin {
|
||||
register() {
|
||||
const { key } = this.config;
|
||||
values.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
const preset1 = new Preset({
|
||||
plugins: [new Plugin1()],
|
||||
});
|
||||
const preset2 = new Preset({
|
||||
plugins: [new Plugin2()],
|
||||
});
|
||||
const preset3 = new Preset({
|
||||
presets: [preset1, preset2],
|
||||
plugins: [
|
||||
new Plugin3(),
|
||||
new Plugin4().configure({ key: 'abc' }),
|
||||
],
|
||||
});
|
||||
preset3.register();
|
||||
expect(values).toEqual([1, 2, 3, 'abc']);
|
||||
});
|
||||
|
||||
it('returns itself', () => {
|
||||
const preset = new Preset();
|
||||
expect(preset.register()).toBe(preset);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user