2021-10-28 06:27:35 -04:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2022-01-07 20:16:24 -05:00
|
|
|
import { ChartMetadata } from '@superset-ui/core';
|
2018-11-06 17:45:50 -05:00
|
|
|
|
|
|
|
describe('ChartMetadata', () => {
|
|
|
|
it('exists', () => {
|
|
|
|
expect(ChartMetadata).toBeDefined();
|
|
|
|
});
|
|
|
|
describe('new ChartMetadata({})', () => {
|
|
|
|
it('creates new metadata instance', () => {
|
|
|
|
const metadata = new ChartMetadata({
|
|
|
|
name: 'test chart',
|
|
|
|
credits: [],
|
|
|
|
description: 'some kind of chart',
|
|
|
|
thumbnail: 'test.png',
|
|
|
|
});
|
|
|
|
expect(metadata).toBeInstanceOf(ChartMetadata);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
describe('.canBeAnnotationType(type)', () => {
|
|
|
|
const metadata = new ChartMetadata({
|
|
|
|
name: 'test chart',
|
2019-02-28 13:36:45 -05:00
|
|
|
canBeAnnotationTypes: ['event'],
|
2018-11-06 17:45:50 -05:00
|
|
|
credits: [],
|
|
|
|
description: 'some kind of chart',
|
|
|
|
thumbnail: 'test.png',
|
|
|
|
});
|
|
|
|
it('returns true if can', () => {
|
|
|
|
expect(metadata.canBeAnnotationType('event')).toBeTruthy();
|
|
|
|
});
|
|
|
|
it('returns false otherwise', () => {
|
|
|
|
expect(metadata.canBeAnnotationType('invalid-type')).toBeFalsy();
|
|
|
|
});
|
|
|
|
});
|
2019-02-28 13:36:45 -05:00
|
|
|
describe('.clone()', () => {
|
|
|
|
const metadata = new ChartMetadata({
|
|
|
|
name: 'test chart',
|
|
|
|
canBeAnnotationTypes: ['event'],
|
|
|
|
credits: [],
|
|
|
|
description: 'some kind of chart',
|
|
|
|
thumbnail: 'test.png',
|
|
|
|
});
|
|
|
|
const clone = metadata.clone();
|
|
|
|
|
|
|
|
it('returns a new instance', () => {
|
|
|
|
expect(metadata).not.toBe(clone);
|
|
|
|
});
|
|
|
|
it('returns a new instance with same field values', () => {
|
|
|
|
expect(metadata.name).toEqual(clone.name);
|
|
|
|
expect(metadata.credits).toEqual(clone.credits);
|
|
|
|
expect(metadata.description).toEqual(clone.description);
|
|
|
|
expect(metadata.canBeAnnotationTypes).toEqual(clone.canBeAnnotationTypes);
|
|
|
|
expect(metadata.thumbnail).toEqual(clone.thumbnail);
|
|
|
|
});
|
|
|
|
});
|
2018-11-06 17:45:50 -05:00
|
|
|
});
|