From 68c6bd05a591557ebe86f87585b742d370609cd4 Mon Sep 17 00:00:00 2001 From: geido Date: Wed, 24 Feb 2021 19:36:01 +0200 Subject: [PATCH] Add LanguagePicker tests --- .../components/Menu/LanguagePicker.test.tsx | 54 +++++++++++++++++++ .../src/components/Menu/NewMenu.tsx | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 superset-frontend/src/components/Menu/LanguagePicker.test.tsx diff --git a/superset-frontend/src/components/Menu/LanguagePicker.test.tsx b/superset-frontend/src/components/Menu/LanguagePicker.test.tsx new file mode 100644 index 0000000000000..ad494d620ca81 --- /dev/null +++ b/superset-frontend/src/components/Menu/LanguagePicker.test.tsx @@ -0,0 +1,54 @@ +/** + * 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 React from 'react'; +import { render, screen } from 'spec/helpers/testing-library'; +import LanguagePicker from './LanguagePicker'; + +const mockedProps = { + locale: 'en', + languages: { + en: { + flag: 'us', + name: 'English', + url: '/lang/en', + }, + it: { + flag: 'it', + name: 'Italian', + url: '/lang/it', + }, + }, +}; + +test('should render', () => { + const { container } = render(); + expect(container).toBeInTheDocument(); +}); + +test('should render the button', () => { + render(); + const button = screen.getByRole('button'); + expect(button).toHaveAttribute('href', '#'); +}); + +test('should render the menuitem', () => { + render(); + const menuitem = screen.getByRole('menuitem'); + expect(menuitem).toHaveTextContent('Italian'); +}); diff --git a/superset-frontend/src/components/Menu/NewMenu.tsx b/superset-frontend/src/components/Menu/NewMenu.tsx index b2aa9b2ad7d2b..8ff46d29538f9 100644 --- a/superset-frontend/src/components/Menu/NewMenu.tsx +++ b/superset-frontend/src/components/Menu/NewMenu.tsx @@ -21,7 +21,7 @@ import { t, styled } from '@superset-ui/core'; import { Menu } from 'src/common/components'; import NavDropdown from 'src/components/NavDropdown'; -const dropdownItems = [ +export const dropdownItems = [ { label: t('SQL query'), url: '/superset/sqllab',