You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2023/05/21 04:29:17 UTC

[superset] 01/01: chore(tests): GPT generated RTL tests for DropdownButton

This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch gpt-rtl-tests
in repository https://gitbox.apache.org/repos/asf/superset.git

commit abd5967eaf5f77f9e664138db14030605ead1d82
Author: Evan Rusackas <ev...@preset.io>
AuthorDate: Sat May 20 22:29:01 2023 -0600

    chore(tests): GPT generated RTL tests for DropdownButton
---
 .../DropdownButton/DropdownButton.test.tsx         | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/superset-frontend/src/components/DropdownButton/DropdownButton.test.tsx b/superset-frontend/src/components/DropdownButton/DropdownButton.test.tsx
new file mode 100644
index 0000000000..4048763739
--- /dev/null
+++ b/superset-frontend/src/components/DropdownButton/DropdownButton.test.tsx
@@ -0,0 +1,51 @@
+/**
+ * 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 { render, screen } from '@testing-library/react';
+import '@testing-library/jest-dom/extend-expect';
+import { DropdownButton } from '.';
+import React from 'react';
+
+describe('<DropdownButton />', () => {
+  const overlayElement = <div>Test Overlay</div>;
+
+  it('renders without crashing', () => {
+    render(<DropdownButton overlay={overlayElement} />);
+    const dropdownButtonElement = screen.getByRole('button');
+    expect(dropdownButtonElement).toBeInTheDocument();
+  });
+
+  it('renders tooltip when tooltip prop is provided', () => {
+    const tooltipText = 'Test Tooltip';
+    render(<DropdownButton overlay={overlayElement} tooltip={tooltipText} />);
+    const tooltipElement = screen.getByText(tooltipText);
+    expect(tooltipElement).toBeInTheDocument();
+  });
+
+  it('does not render tooltip when tooltip prop is not provided', () => {
+    render(<DropdownButton overlay={overlayElement} />);
+    const tooltipElement = screen.queryByRole('tooltip');
+    expect(tooltipElement).not.toBeInTheDocument();
+  });
+
+  it('renders overlay correctly', () => {
+    render(<DropdownButton overlay={overlayElement} />);
+    const overlayElement = screen.getByText('Test Overlay');
+    expect(overlayElement).toBeInTheDocument();
+  });
+});