Skip to content

Commit

Permalink
fix: core coverage and add a coverage step in workflow (#20784)
Browse files Browse the repository at this point in the history
* fix: core coverage

* add step in workflow
  • Loading branch information
zhaoyongjie authored Jul 20, 2022
1 parent 5ed85f5 commit 9c7bcfc
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/superset-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ jobs:
if: steps.check.outcome == 'failure'
working-directory: ./superset-frontend
run: npm run plugins:build-storybook
- name: superset-ui/core coverage
if: steps.check.outcome == 'failure'
working-directory: ./superset-frontend
run: |
npm run core:cover
- name: unit tests
if: steps.check.outcome == 'failure'
working-directory: ./superset-frontend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,4 @@ export const DEFAULT_METRICS: Metric[] = [
},
];

export const isValidDatasourceType = (datasource: DatasourceType) =>
Object.values(DatasourceType).includes(datasource);

export default {};
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
import { DatasourceKey } from '@superset-ui/core';

describe('DatasourceKey', () => {
const tableKey = '5__table';

it('should handle table data sources', () => {
const datasourceKey = new DatasourceKey(tableKey);
expect(datasourceKey.toString()).toBe(tableKey);
const datasourceKey = new DatasourceKey('5__table');
expect(datasourceKey.toString()).toBe('5__table');
expect(datasourceKey.toObject()).toEqual({ id: 5, type: 'table' });
});

it('should handle query data sources', () => {
const datasourceKey = new DatasourceKey('5__query');
expect(datasourceKey.toString()).toBe('5__query');
expect(datasourceKey.toObject()).toEqual({ id: 5, type: 'query' });
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* 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 { DatasourceType, DEFAULT_METRICS } from '@superset-ui/core';

test('DEFAULT_METRICS', () => {
expect(DEFAULT_METRICS).toEqual([
{
metric_name: 'COUNT(*)',
expression: 'COUNT(*)',
},
]);
});

test('DatasourceType', () => {
expect(Object.keys(DatasourceType).length).toBe(5);
expect(DatasourceType.Table).toBe('table');
expect(DatasourceType.Query).toBe('query');
expect(DatasourceType.Dataset).toBe('dataset');
expect(DatasourceType.SlTable).toBe('sl_table');
expect(DatasourceType.SavedQuery).toBe('saved_query');
});

0 comments on commit 9c7bcfc

Please sign in to comment.