mirror of
https://github.com/apache/superset.git
synced 2026-04-09 19:35:21 +00:00
* add unit tests * add test structure * add unit tests for Registry * add LoaderRegistry unit test * add unit test for makeSingleton * add type check * add plugin data structures * simplify API * add preset tests * update test message * fix lint * update makeSingleton * update Plugin, Preset and unit test * revise Registry code * update unit test, add remove function * update test * update unit test * update plugin unit test * add .keys(), .entries() and .entriesAsPromise() * update test description
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import { describe, it } from 'mocha';
|
|
import { expect } from 'chai';
|
|
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).to.not.equal(undefined);
|
|
});
|
|
|
|
describe('new ChartPlugin()', () => {
|
|
it('creates a new plugin', () => {
|
|
const plugin = new ChartPlugin({
|
|
metadata,
|
|
Chart() {},
|
|
});
|
|
expect(plugin).to.be.instanceof(ChartPlugin);
|
|
});
|
|
it('throws an error if metadata is not specified', () => {
|
|
expect(() => new ChartPlugin()).to.throw(Error);
|
|
});
|
|
it('throws an error if none of Chart or loadChart is specified', () => {
|
|
expect(() => new ChartPlugin({ metadata })).to.throw(Error);
|
|
});
|
|
});
|
|
|
|
describe('.register(key)', () => {
|
|
const plugin = new ChartPlugin({
|
|
metadata,
|
|
Chart() {},
|
|
});
|
|
it('throws an error if key is not provided', () => {
|
|
expect(() => plugin.register()).to.throw(Error);
|
|
expect(() => plugin.configure({ key: 'abc' }).register()).to.not.throw(Error);
|
|
});
|
|
it('returns itself', () => {
|
|
expect(plugin.configure({ key: 'abc' }).register()).to.equal(plugin);
|
|
});
|
|
});
|
|
});
|