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/24 15:52:11 UTC

[GitHub] [superset] yardz opened a new pull request #13320: test: for component FaveStar

yardz opened a new pull request #13320:
URL: https://github.com/apache/superset/pull/13320


   ### SUMMARY
   - moving `FaveStar.tsx` to `FaveStar` folder
   - switching FaveStar to function component
   - tests for FaveStar component
   
   ### TEST PLAN
   No change in behavior. All tests must pass.
   


----------------------------------------------------------------
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


[GitHub] [superset] codecov-io edited a comment on pull request #13320: test: tests for component FaveStar

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #13320:
URL: https://github.com/apache/superset/pull/13320#issuecomment-785268095


   # [Codecov](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=h1) Report
   > Merging [#13320](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=desc) (5bf1b42) into [master](https://codecov.io/gh/apache/superset/commit/29d6420ecc2187db951f08dd47289277a11f4db5?el=desc) (29d6420) will **decrease** coverage by `18.66%`.
   > The diff coverage is `100.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/superset/pull/13320/graphs/tree.svg?width=650&height=150&src=pr&token=KsB0fHcx6l)](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #13320       +/-   ##
   ===========================================
   - Coverage   77.20%   58.54%   -18.67%     
   ===========================================
     Files         872      480      -392     
     Lines       45101    16004    -29097     
     Branches     5435     4130     -1305     
   ===========================================
   - Hits        34820     9369    -25451     
   + Misses      10158     6635     -3523     
   + Partials      123        0      -123     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | cypress | `58.54% <100.00%> (+<0.01%)` | :arrow_up: |
   | javascript | `?` | |
   | python | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [...uperset-frontend/src/components/FaveStar/index.tsx](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2NvbXBvbmVudHMvRmF2ZVN0YXIvaW5kZXgudHN4) | `100.00% <100.00%> (ø)` | |
   | [...uperset-frontend/src/dashboard/util/dnd-reorder.js](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC91dGlsL2RuZC1yZW9yZGVyLmpz) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...rset-frontend/src/dashboard/util/getEmptyLayout.js](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC91dGlsL2dldEVtcHR5TGF5b3V0Lmpz) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...dashboard/components/resizable/ResizableHandle.jsx](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL3Jlc2l6YWJsZS9SZXNpemFibGVIYW5kbGUuanN4) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...tersConfigModal/Footer/CancelConfirmationAlert.tsx](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvRmlsdGVyc0NvbmZpZ01vZGFsL0Zvb3Rlci9DYW5jZWxDb25maXJtYXRpb25BbGVydC50c3g=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...ConfigModal/FiltersConfigForm/FilterScope/state.ts](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvRmlsdGVyc0NvbmZpZ01vZGFsL0ZpbHRlcnNDb25maWdGb3JtL0ZpbHRlclNjb3BlL3N0YXRlLnRz) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...odal/FiltersConfigForm/FilterScope/ScopingTree.tsx](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvRmlsdGVyc0NvbmZpZ01vZGFsL0ZpbHRlcnNDb25maWdGb3JtL0ZpbHRlclNjb3BlL1Njb3BpbmdUcmVlLnRzeA==) | `6.25% <0.00%> (-93.75%)` | :arrow_down: |
   | [.../src/dashboard/util/getFilterScopeFromNodesTree.js](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC91dGlsL2dldEZpbHRlclNjb3BlRnJvbU5vZGVzVHJlZS5qcw==) | `0.00% <0.00%> (-93.48%)` | :arrow_down: |
   | [...src/dashboard/components/gridComponents/Header.jsx](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL2dyaWRDb21wb25lbnRzL0hlYWRlci5qc3g=) | `10.52% <0.00%> (-86.85%)` | :arrow_down: |
   | [superset-frontend/src/components/IconTooltip.tsx](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2NvbXBvbmVudHMvSWNvblRvb2x0aXAudHN4) | `13.33% <0.00%> (-86.67%)` | :arrow_down: |
   | ... and [735 more](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=footer). Last update [29d6420...5bf1b42](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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


[GitHub] [superset] codecov-io commented on pull request #13320: test: tests for component FaveStar

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #13320:
URL: https://github.com/apache/superset/pull/13320#issuecomment-785268095


   # [Codecov](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=h1) Report
   > Merging [#13320](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=desc) (5bf1b42) into [master](https://codecov.io/gh/apache/superset/commit/29d6420ecc2187db951f08dd47289277a11f4db5?el=desc) (29d6420) will **decrease** coverage by `19.06%`.
   > The diff coverage is `100.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/superset/pull/13320/graphs/tree.svg?width=650&height=150&src=pr&token=KsB0fHcx6l)](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #13320       +/-   ##
   ===========================================
   - Coverage   77.20%   58.14%   -19.07%     
   ===========================================
     Files         872      480      -392     
     Lines       45101    16004    -29097     
     Branches     5435     4130     -1305     
   ===========================================
   - Hits        34820     9305    -25515     
   + Misses      10158     6699     -3459     
   + Partials      123        0      -123     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | cypress | `58.14% <100.00%> (-0.40%)` | :arrow_down: |
   | javascript | `?` | |
   | python | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [...uperset-frontend/src/components/FaveStar/index.tsx](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2NvbXBvbmVudHMvRmF2ZVN0YXIvaW5kZXgudHN4) | `100.00% <100.00%> (ø)` | |
   | [...uperset-frontend/src/dashboard/util/dnd-reorder.js](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC91dGlsL2RuZC1yZW9yZGVyLmpz) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...rset-frontend/src/dashboard/util/getEmptyLayout.js](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC91dGlsL2dldEVtcHR5TGF5b3V0Lmpz) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...dashboard/components/resizable/ResizableHandle.jsx](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL3Jlc2l6YWJsZS9SZXNpemFibGVIYW5kbGUuanN4) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...tersConfigModal/Footer/CancelConfirmationAlert.tsx](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvRmlsdGVyc0NvbmZpZ01vZGFsL0Zvb3Rlci9DYW5jZWxDb25maXJtYXRpb25BbGVydC50c3g=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...ConfigModal/FiltersConfigForm/FilterScope/state.ts](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvRmlsdGVyc0NvbmZpZ01vZGFsL0ZpbHRlcnNDb25maWdGb3JtL0ZpbHRlclNjb3BlL3N0YXRlLnRz) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...odal/FiltersConfigForm/FilterScope/ScopingTree.tsx](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL25hdGl2ZUZpbHRlcnMvRmlsdGVyc0NvbmZpZ01vZGFsL0ZpbHRlcnNDb25maWdGb3JtL0ZpbHRlclNjb3BlL1Njb3BpbmdUcmVlLnRzeA==) | `6.25% <0.00%> (-93.75%)` | :arrow_down: |
   | [.../src/dashboard/util/getFilterScopeFromNodesTree.js](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC91dGlsL2dldEZpbHRlclNjb3BlRnJvbU5vZGVzVHJlZS5qcw==) | `0.00% <0.00%> (-93.48%)` | :arrow_down: |
   | [...src/dashboard/components/gridComponents/Header.jsx](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2Rhc2hib2FyZC9jb21wb25lbnRzL2dyaWRDb21wb25lbnRzL0hlYWRlci5qc3g=) | `10.52% <0.00%> (-86.85%)` | :arrow_down: |
   | [superset-frontend/src/components/IconTooltip.tsx](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2NvbXBvbmVudHMvSWNvblRvb2x0aXAudHN4) | `13.33% <0.00%> (-86.67%)` | :arrow_down: |
   | ... and [735 more](https://codecov.io/gh/apache/superset/pull/13320/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=footer). Last update [29d6420...5bf1b42](https://codecov.io/gh/apache/superset/pull/13320?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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


[GitHub] [superset] geido commented on a change in pull request #13320: test: tests for component FaveStar

Posted by GitBox <gi...@apache.org>.
geido commented on a change in pull request #13320:
URL: https://github.com/apache/superset/pull/13320#discussion_r582207027



##########
File path: superset-frontend/src/components/FaveStar/FaveStar.test.tsx
##########
@@ -0,0 +1,105 @@
+/**
+ * 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 userEvent from '@testing-library/user-event';
+import FaveStar from '.';
+
+jest.mock('../Icon', () => ({
+  __esModule: true,
+  default: ({ name }: { name: string }) => (
+    <div data-test="icon" data-name={name} />
+  ),
+}));
+
+jest.mock('src/common/components/Tooltip', () => ({
+  Tooltip: (props: any) => <div data-test="tooltip" {...props} />,
+}));
+
+test('render right content', () => {
+  const props = {
+    itemId: 3,
+    saveFaveStar: jest.fn(),
+  };
+
+  const { rerender } = render(<FaveStar {...props} isStarred />);
+  expect(screen.getByRole('button')).toBeInTheDocument();
+  expect(screen.getByTestId('icon')).toBeInTheDocument();
+  expect(screen.getByTestId('icon')).toHaveAttribute(
+    'data-name',
+    'favorite-selected',
+  );
+
+  expect(props.saveFaveStar).toBeCalledTimes(0);
+  userEvent.click(screen.getByRole('button'));
+  expect(props.saveFaveStar).toBeCalledTimes(1);
+  expect(props.saveFaveStar).toBeCalledWith(props.itemId, true);
+
+  rerender(<FaveStar {...props} />);
+  expect(screen.getByTestId('icon')).toBeInTheDocument();
+  expect(screen.getByTestId('icon')).toHaveAttribute(
+    'data-name',
+    'favorite-unselected',
+  );
+
+  expect(props.saveFaveStar).toBeCalledTimes(1);
+  userEvent.click(screen.getByRole('button'));
+  expect(props.saveFaveStar).toBeCalledTimes(2);
+  expect(props.saveFaveStar).toBeCalledWith(props.itemId, false);
+});
+
+test('render content on tooltip', () => {
+  const props = {
+    itemId: 3,
+    showTooltip: true,
+    saveFaveStar: jest.fn(),
+  };
+
+  render(<FaveStar {...props} />);
+
+  expect(screen.getByTestId('tooltip')).toBeInTheDocument();
+  expect(screen.getByTestId('tooltip')).toHaveAttribute(
+    'id',
+    'fave-unfave-tooltip',
+  );
+  expect(screen.getByTestId('tooltip')).toHaveAttribute(
+    'title',
+    'Click to favorite/unfavorite',
+  );
+  expect(screen.getByRole('button')).toBeInTheDocument();
+});
+
+test('Call fetchFaveStar only on the first render', () => {
+  const props = {
+    itemId: 3,
+    fetchFaveStar: jest.fn(),
+    saveFaveStar: jest.fn(),
+    isStarred: false,
+    showTooltip: false,
+  };
+
+  const { rerender } = render(<FaveStar {...props} />);
+  expect(props.fetchFaveStar).toBeCalledTimes(1);
+  expect(props.fetchFaveStar).toBeCalledWith(props.itemId);
+
+  rerender(<FaveStar {...{ ...props, itemId: 2 }} />);
+  expect(props.fetchFaveStar).toBeCalledTimes(1);
+  // expect(screen.getByText('backend-name')).toBeInTheDocument();

Review comment:
       Seems like you forgot to remove a comment




----------------------------------------------------------------
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


[GitHub] [superset] yardz commented on a change in pull request #13320: test: tests for component FaveStar

Posted by GitBox <gi...@apache.org>.
yardz commented on a change in pull request #13320:
URL: https://github.com/apache/superset/pull/13320#discussion_r582277090



##########
File path: superset-frontend/src/components/FaveStar/FaveStar.test.tsx
##########
@@ -0,0 +1,105 @@
+/**
+ * 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 userEvent from '@testing-library/user-event';
+import FaveStar from '.';
+
+jest.mock('../Icon', () => ({
+  __esModule: true,
+  default: ({ name }: { name: string }) => (
+    <div data-test="icon" data-name={name} />
+  ),
+}));
+
+jest.mock('src/common/components/Tooltip', () => ({
+  Tooltip: (props: any) => <div data-test="tooltip" {...props} />,
+}));
+
+test('render right content', () => {
+  const props = {
+    itemId: 3,
+    saveFaveStar: jest.fn(),
+  };
+
+  const { rerender } = render(<FaveStar {...props} isStarred />);
+  expect(screen.getByRole('button')).toBeInTheDocument();
+  expect(screen.getByTestId('icon')).toBeInTheDocument();
+  expect(screen.getByTestId('icon')).toHaveAttribute(
+    'data-name',
+    'favorite-selected',
+  );
+
+  expect(props.saveFaveStar).toBeCalledTimes(0);
+  userEvent.click(screen.getByRole('button'));
+  expect(props.saveFaveStar).toBeCalledTimes(1);
+  expect(props.saveFaveStar).toBeCalledWith(props.itemId, true);
+
+  rerender(<FaveStar {...props} />);
+  expect(screen.getByTestId('icon')).toBeInTheDocument();
+  expect(screen.getByTestId('icon')).toHaveAttribute(
+    'data-name',
+    'favorite-unselected',
+  );
+
+  expect(props.saveFaveStar).toBeCalledTimes(1);
+  userEvent.click(screen.getByRole('button'));
+  expect(props.saveFaveStar).toBeCalledTimes(2);
+  expect(props.saveFaveStar).toBeCalledWith(props.itemId, false);
+});
+
+test('render content on tooltip', () => {
+  const props = {
+    itemId: 3,
+    showTooltip: true,
+    saveFaveStar: jest.fn(),
+  };
+
+  render(<FaveStar {...props} />);
+
+  expect(screen.getByTestId('tooltip')).toBeInTheDocument();
+  expect(screen.getByTestId('tooltip')).toHaveAttribute(
+    'id',
+    'fave-unfave-tooltip',
+  );
+  expect(screen.getByTestId('tooltip')).toHaveAttribute(
+    'title',
+    'Click to favorite/unfavorite',
+  );
+  expect(screen.getByRole('button')).toBeInTheDocument();
+});
+
+test('Call fetchFaveStar only on the first render', () => {
+  const props = {
+    itemId: 3,
+    fetchFaveStar: jest.fn(),
+    saveFaveStar: jest.fn(),
+    isStarred: false,
+    showTooltip: false,
+  };
+
+  const { rerender } = render(<FaveStar {...props} />);
+  expect(props.fetchFaveStar).toBeCalledTimes(1);
+  expect(props.fetchFaveStar).toBeCalledWith(props.itemId);
+
+  rerender(<FaveStar {...{ ...props, itemId: 2 }} />);
+  expect(props.fetchFaveStar).toBeCalledTimes(1);
+  // expect(screen.getByText('backend-name')).toBeInTheDocument();

Review comment:
       Tnks!




----------------------------------------------------------------
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


[GitHub] [superset] pkdotson merged pull request #13320: test: tests for component FaveStar

Posted by GitBox <gi...@apache.org>.
pkdotson merged pull request #13320:
URL: https://github.com/apache/superset/pull/13320


   


----------------------------------------------------------------
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