superset/superset-frontend/packages/superset-ui-core/test/color/ColorSchemeRegistry.test.ts
Geido 6b0c3032b2
chore: Update color scheme when deleted or changed (#20589)
* feat(explore): Use v1/explore endpoint data instead of bootstrapData

* Add tests

* Fix ci

* Remove redundant dependency

* Use form_data_key in cypress tests

* Add auth headers to for data request

* Address comments

* Remove displaying danger toast

* Conditionally add auth headers

* Address comments

* Fix typing bug

* fix

* Fix opening dataset

* Fix sqllab chart create

* Run queries in parallel

* Fallback to default color scheme

* Fix dashboard id autofill

* Fix lint

* Fix test

* Fix hydrate action

* Update dashboard colors

* Add color scheme domain

* Add check for default scheme

* Make me pretty

* Clean up

* Nit

* Clean up

* Pretty

* Fix missing sequential

* Lint

* Enhance test

* Lint

Co-authored-by: Kamil Gabryjelski <kamil.gabryjelski@gmail.com>
2022-07-25 18:50:49 -04:00

44 lines
1.7 KiB
TypeScript

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import ColorSchemeRegistry from '../../src/color/ColorSchemeRegistry';
import schemes from '../../src/color/colorSchemes/categorical/d3';
import CategoricalScheme from '../../src/color/CategoricalScheme';
describe('ColorSchemeRegistry', () => {
it('exists', () => {
expect(ColorSchemeRegistry).toBeDefined();
expect(ColorSchemeRegistry).toBeInstanceOf(Function);
});
it('returns undefined', () => {
const registry = new ColorSchemeRegistry();
expect(registry.get('something')).toBeUndefined();
});
it('returns default', () => {
const registry = new ColorSchemeRegistry();
registry.registerValue('SUPERSET_DEFAULT', schemes[0]);
expect(registry.get('something')).toBeInstanceOf(CategoricalScheme);
});
it('returns undefined in strict mode', () => {
const registry = new ColorSchemeRegistry();
registry.registerValue('SUPERSET_DEFAULT', schemes[0]);
expect(registry.get('something', true)).toBeUndefined();
});
});