You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/02/22 13:58:35 UTC

[GitHub] [superset] geido commented on a change in pull request #13277: test: Pagination component

geido commented on a change in pull request #13277:
URL: https://github.com/apache/superset/pull/13277#discussion_r580263572



##########
File path: superset-frontend/src/components/Pagination/Ellipsis.test.tsx
##########
@@ -0,0 +1,39 @@
+/**
+ * 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 '@testing-library/jest-dom';
+import { render, screen, fireEvent } from '@testing-library/react';
+import { Ellipsis } from './Ellipsis';
+
+test('Ellipsis - click when the button is enabled', () => {
+  const click = jest.fn();
+  render(<Ellipsis onClick={click} />);
+  expect(click).toBeCalledTimes(0);
+  fireEvent.click(screen.getByRole('button'));

Review comment:
       We are trying to use the user-event from @testing-library/user-event wherever it is possible. I think we can use it here as well.

##########
File path: superset-frontend/src/components/Pagination/Item.test.tsx
##########
@@ -0,0 +1,49 @@
+/**
+ * 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 '@testing-library/jest-dom';
+import { render, screen, fireEvent } from '@testing-library/react';
+import { Item } from './Item';
+
+test('Item - click when the item is not active', () => {
+  const click = jest.fn();
+  render(
+    <Item onClick={click}>
+      <div data-test-id="test" />
+    </Item>,
+  );
+  expect(click).toBeCalledTimes(0);
+  fireEvent.click(screen.getByRole('button'));

Review comment:
       Same as my other comment concerning user-event




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org