]> source.dussan.org Git - sonarqube.git/commitdiff
fix application leak tooltip (#3117) 3116/head
authorStas Vilchik <stas.vilchik@sonarsource.com>
Tue, 6 Mar 2018 09:18:04 +0000 (10:18 +0100)
committerGitHub <noreply@github.com>
Tue, 6 Mar 2018 09:18:04 +0000 (10:18 +0100)
server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx
server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx

index 55d8c5082ceebecb3296067267a1c33451fb22bc..6045dd6871d369e0694e703ddcf9df1fbe03854a 100644 (file)
@@ -50,7 +50,7 @@ export default class ApplicationLeakPeriodLegend extends React.Component<Props,
   }
 
   fetchLeaks = (visible: boolean) => {
-    if (visible && this.state.leaks) {
+    if (visible && !this.state.leaks) {
       getApplicationLeak(this.props.component).then(
         leaks => {
           if (this.mounted) {
index ee95828e890bb325d2d0527314679d00a29e1f30..42b2caeb24935f006cb03d343e146b4753b05247 100644 (file)
 import * as React from 'react';
 import { shallow } from 'enzyme';
 import ApplicationLeakPeriodLegend from '../ApplicationLeakPeriodLegend';
+import { waitAndUpdate } from '../../../../helpers/testUtils';
 
-it('renders', () => {
-  const wrapper = shallow(<ApplicationLeakPeriodLegend component="foo" />);
-  expect(wrapper).toMatchSnapshot();
-  wrapper.setState({
-    leaks: [
+jest.mock('../../../../api/application', () => ({
+  getApplicationLeak: jest.fn(() =>
+    Promise.resolve([
       { date: '2017-01-01T11:39:03+0100', project: 'foo', projectName: 'Foo' },
       { date: '2017-02-01T11:39:03+0100', project: 'bar', projectName: 'Bar' }
-    ]
-  });
+    ])
+  )
+}));
+
+it('renders', async () => {
+  const wrapper = shallow(<ApplicationLeakPeriodLegend component="foo" />);
+  expect(wrapper).toMatchSnapshot();
+
+  wrapper.find('Tooltip').prop<Function>('onVisibleChange')(true);
+  await waitAndUpdate(wrapper);
   expect(wrapper).toMatchSnapshot();
 });