diff --git a/superset-frontend/jest.config.js b/superset-frontend/jest.config.js index 6a5931e840d3e..2d02d8386cf01 100644 --- a/superset-frontend/jest.config.js +++ b/superset-frontend/jest.config.js @@ -17,7 +17,7 @@ * under the License. */ module.exports = { - testRegex: '\\/spec\\/.*(_spec|\\.test)\\.(j|t)sx?$', + testRegex: '(\\/spec|\\/src)\\/.*(_spec|\\.test)\\.(j|t)sx?$', moduleNameMapper: { '\\.(css|less)$': '/spec/__mocks__/styleMock.js', '\\.(gif|ttf|eot)$': '/spec/__mocks__/fileMock.js', diff --git a/superset-frontend/src/components/Label/label.stories.jsx b/superset-frontend/src/components/Label/Label.stories.tsx similarity index 92% rename from superset-frontend/src/components/Label/label.stories.jsx rename to superset-frontend/src/components/Label/Label.stories.tsx index be1153f2832ef..35ab1b997f9ef 100644 --- a/superset-frontend/src/components/Label/label.stories.jsx +++ b/superset-frontend/src/components/Label/Label.stories.tsx @@ -25,9 +25,10 @@ export default { title: 'Label', component: Label, decorators: [withKnobs], + excludeStories: ['bsStyleKnob'], }; -const bsStyleKnob = { +export const bsStyleKnob = { label: 'Types', options: { default: 'default', @@ -63,9 +64,10 @@ export const InteractiveLabel = () => ( bsStyleKnob.label, bsStyleKnob.options, bsStyleKnob.defaultValue, - bsStyleKnob.groupId, )} - onClick={boolean('Has onClick action', false) ? action('clicked') : false} + onClick={ + boolean('Has onClick action', false) ? action('clicked') : undefined + } > {text('Label', 'Label!')} diff --git a/superset-frontend/src/components/Label/Label.test.tsx b/superset-frontend/src/components/Label/Label.test.tsx new file mode 100644 index 0000000000000..92277271d7ec0 --- /dev/null +++ b/superset-frontend/src/components/Label/Label.test.tsx @@ -0,0 +1,58 @@ +/** + * 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. + */ + +/* global jest */ +import React from 'react'; +/* eslint-disable-next-line import/no-extraneous-dependencies */ +import { ReactWrapper } from 'enzyme'; +import { styledMount as mount } from 'spec/helpers/theming'; +import Label from '.'; +import { LabelGallery, bsStyleKnob } from './Label.stories'; + +describe('Label', () => { + let wrapper: ReactWrapper; + + // test the basic component + it('renders the base component (no onClick)', () => { + expect(React.isValidElement(