diff options
author | Jeremy Davis <jeremy.davis@sonarsource.com> | 2021-01-14 18:30:25 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-01-20 20:32:16 +0000 |
commit | d6b1b8a262b3890ffe5fd741d0bbeaaabd25a880 (patch) | |
tree | 08f3158c506d6b6f141dd007470b5d393be02ea9 /server/sonar-web/src/main/js/components/SourceViewer | |
parent | 81fc4043e73b22679de97d1336ff943b4724a62b (diff) | |
download | sonarqube-d6b1b8a262b3890ffe5fd741d0bbeaaabd25a880.tar.gz sonarqube-d6b1b8a262b3890ffe5fd741d0bbeaaabd25a880.zip |
SONAR-14309 Update eslint, typescript and fix issues
Diffstat (limited to 'server/sonar-web/src/main/js/components/SourceViewer')
4 files changed, 14 insertions, 8 deletions
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx index 918f8d2cec9..d300da764ec 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerBase.tsx @@ -223,9 +223,9 @@ export default class SourceViewerBase extends React.PureComponent<Props, State> const firstLine = sources[0]; const lastList = sources[sources.length - 1]; return lineNumber < firstLine.line || lineNumber > lastList.line; - } else { - return true; } + + return true; } fetchComponent() { @@ -383,10 +383,9 @@ export default class SourceViewerBase extends React.PureComponent<Props, State> // request one additional line to define `hasSourcesAfter` to++; - return this.propsLoadSources(this.props.component, from, to, this.props.branchLike).then( - sources => resolve(sources), - onFailLoadSources - ); + this.propsLoadSources(this.props.component, from, to, this.props.branchLike).then(sources => { + resolve(sources); + }, onFailLoadSources); }); }; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx index 316faf2c5ca..eea4cbd8247 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewerBase-test.tsx @@ -146,6 +146,13 @@ it('should load sources after', async () => { expect(wrapper.state().issues).toHaveLength(2); }); +it('should handle no sources when checking ranges', () => { + const wrapper = shallowRender(); + + wrapper.setState({ sources: undefined }); + expect(wrapper.instance().isLineOutsideOfRange(12)).toBe(true); +}); + function shallowRender(overrides: Partial<SourceViewerBase['props']> = {}) { return shallow<SourceViewerBase>( <SourceViewerBase branchLike={mockMainBranch()} component="my-component" {...overrides} /> diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineSCM-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineSCM-test.tsx index aa69190a747..a1493b031e6 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineSCM-test.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineSCM-test.tsx @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* eslint-disable sonarjs/no-duplicate-string */ + import { shallow } from 'enzyme'; import * as React from 'react'; import { LineSCM, LineSCMProps } from '../LineSCM'; diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/SCMPopup-test.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/SCMPopup-test.tsx index 9db75c86dc2..c8a5daff578 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/SCMPopup-test.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/SCMPopup-test.tsx @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* eslint-disable sonarjs/no-duplicate-string */ + import { shallow } from 'enzyme'; import * as React from 'react'; import { SCMPopup, SCMPopupProps } from '../SCMPopup'; |