From 364cd42b9bb92eb42f0adce613185e0bb8771672 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 19 May 2016 18:26:36 +0200 Subject: [PATCH] move tests --- server/sonar-web/package.json | 2 +- server/sonar-web/pom.xml | 4 +- .../__tests__}/background-tasks-test.js | 104 ++++++++++------- .../components/__tests__}/App-test.js | 6 +- .../__tests__}/EmptyOverview-test.js | 2 +- .../__tests__}/QualityGateCondition-test.js | 4 +- .../__tests__}/permission-templates-test.js | 78 ++++++++----- .../apps/projects/__tests__/projects-test.js | 54 +++++++++ .../js/apps/system/__tests__}/system-test.js | 59 ++++++---- .../js/components/__tests__}/issue-test.js | 100 +++++++++------- .../__tests__/source-viewer-test.js | 109 ++++++++++++++++++ .../charts/__tests__/bar-chart-test.js | 97 ++++++++++++++++ .../charts/__tests__/bubble-chart-test.js | 58 ++++++++++ .../charts/__tests__/line-chart-test.js | 74 ++++++++++++ .../charts/__tests__/treemap-test.js | 44 +++++++ .../charts/__tests__/work-cloud-test.js | 38 ++++++ .../main/js/helpers/__tests__}/l10n-test.js | 21 +++- .../js/helpers/__tests__}/measures-test.js | 32 +++-- .../main/js/helpers/__tests__}/path-test.js | 21 +++- .../main/js/helpers/__tests__}/urls-test.js | 26 ++++- .../main/js/main/nav/__tests__/nav-test.js | 39 +++++++ server/sonar-web/tests/apps/projects-test.js | 36 ------ .../tests/components/charts/bar-chart-test.js | 56 --------- .../components/charts/bubble-chart-test.js | 40 ------- .../components/charts/line-chart-test.js | 42 ------- .../tests/components/charts/treemap-test.js | 21 ---- .../components/charts/work-cloud-test.js | 20 ---- .../tests/components/source-viewer-test.js | 90 --------------- server/sonar-web/tests/nav-test.js | 22 ---- 29 files changed, 815 insertions(+), 484 deletions(-) rename server/sonar-web/{tests/apps => src/main/js/apps/background-tasks/__tests__}/background-tasks-test.js (56%) rename server/sonar-web/{tests/apps/overview/components => src/main/js/apps/overview/components/__tests__}/App-test.js (87%) rename server/sonar-web/{tests/apps/overview/components => src/main/js/apps/overview/components/__tests__}/EmptyOverview-test.js (93%) rename server/sonar-web/{tests/apps/overview/qualityGate => src/main/js/apps/overview/qualityGate/__tests__}/QualityGateCondition-test.js (89%) rename server/sonar-web/{tests/apps => src/main/js/apps/permission-templates/__tests__}/permission-templates-test.js (58%) create mode 100644 server/sonar-web/src/main/js/apps/projects/__tests__/projects-test.js rename server/sonar-web/{tests/apps => src/main/js/apps/system/__tests__}/system-test.js (51%) rename server/sonar-web/{tests/components => src/main/js/components/__tests__}/issue-test.js (59%) create mode 100644 server/sonar-web/src/main/js/components/__tests__/source-viewer-test.js create mode 100644 server/sonar-web/src/main/js/components/charts/__tests__/bar-chart-test.js create mode 100644 server/sonar-web/src/main/js/components/charts/__tests__/bubble-chart-test.js create mode 100644 server/sonar-web/src/main/js/components/charts/__tests__/line-chart-test.js create mode 100644 server/sonar-web/src/main/js/components/charts/__tests__/treemap-test.js create mode 100644 server/sonar-web/src/main/js/components/charts/__tests__/work-cloud-test.js rename server/sonar-web/{tests/helpers => src/main/js/helpers/__tests__}/l10n-test.js (73%) rename server/sonar-web/{tests/helpers => src/main/js/helpers/__tests__}/measures-test.js (91%) rename server/sonar-web/{tests/helpers => src/main/js/helpers/__tests__}/path-test.js (65%) rename server/sonar-web/{tests/helpers => src/main/js/helpers/__tests__}/urls-test.js (77%) create mode 100644 server/sonar-web/src/main/js/main/nav/__tests__/nav-test.js delete mode 100644 server/sonar-web/tests/apps/projects-test.js delete mode 100644 server/sonar-web/tests/components/charts/bar-chart-test.js delete mode 100644 server/sonar-web/tests/components/charts/bubble-chart-test.js delete mode 100644 server/sonar-web/tests/components/charts/line-chart-test.js delete mode 100644 server/sonar-web/tests/components/charts/treemap-test.js delete mode 100644 server/sonar-web/tests/components/charts/work-cloud-test.js delete mode 100644 server/sonar-web/tests/components/source-viewer-test.js delete mode 100644 server/sonar-web/tests/nav-test.js diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index 5e4da37d17b..58ea1221ec9 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -85,7 +85,7 @@ "scripts": { "build-fast": "gulp build:dev", "build": "gulp build", - "test": "mocha --opts tests/mocha.opts tests", + "test": "mocha --opts tests/mocha.opts src/main/js/**/__tests__/**/*", "coverage": "babel-node node_modules/.bin/isparta cover --root 'src/main/js' --include-all-sources --excludes '**/libs/**' --dir 'target/coverage' node_modules/.bin/_mocha -- --opts tests/mocha.opts tests", "lint": "eslint src/main/js && jscs src/main/js", "dev": "NODE_ENV=hot node devServer" diff --git a/server/sonar-web/pom.xml b/server/sonar-web/pom.xml index 96617d15b40..6b465ece10b 100644 --- a/server/sonar-web/pom.xml +++ b/server/sonar-web/pom.xml @@ -14,7 +14,9 @@ src/main/js,src/main/less - src/main/js/libs/third-party/**/*,src/main/js/libs/require.js + src/main/js + src/main/js/**/__tests__/** + src/main/js/libs/third-party/**/*,src/main/js/libs/require.js,src/main/js/**/__tests__/** build diff --git a/server/sonar-web/tests/apps/background-tasks-test.js b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js similarity index 56% rename from server/sonar-web/tests/apps/background-tasks-test.js rename to server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js index acb38ebe0a8..ab0583a3c50 100644 --- a/server/sonar-web/tests/apps/background-tasks-test.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js @@ -1,19 +1,35 @@ -/* eslint no-unused-expressions: 0 */ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ import React from 'react'; import ReactDOM from 'react-dom'; import TestUtils from 'react-addons-test-utils'; +import chai, { expect } from 'chai'; +import sinon from 'sinon'; +import sinonChai from 'sinon-chai'; -import Header from '../../src/main/js/apps/background-tasks/components/Header'; -import Stats from '../../src/main/js/apps/background-tasks/components/Stats'; -import Search from '../../src/main/js/apps/background-tasks/components/Search'; -import Tasks from '../../src/main/js/apps/background-tasks/components/Tasks'; -import { STATUSES, CURRENTS, DEBOUNCE_DELAY, DEFAULT_FILTERS } from '../../src/main/js/apps/background-tasks/constants'; -import { formatDuration } from '../../src/main/js/apps/background-tasks/utils'; +import Stats from '../components/Stats'; +import Search from '../components/Search'; +import { STATUSES, CURRENTS, DEBOUNCE_DELAY, DEFAULT_FILTERS } from '../constants'; +import { formatDuration } from '../utils'; -let chai = require('chai'); -let expect = chai.expect; -let sinon = require('sinon'); -chai.use(require('sinon-chai')); +chai.use(sinonChai); describe('Background Tasks', function () { describe('Constants', () => { @@ -38,41 +54,41 @@ describe('Background Tasks', function () { }; it('should render search form', () => { - let component = TestUtils.renderIntoDocument( + const component = TestUtils.renderIntoDocument( ); - let searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'js-search'); + const searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'js-search'); expect(searchBox).to.have.length(1); }); it('should not render search form', () => { - let component = TestUtils.renderIntoDocument( + const component = TestUtils.renderIntoDocument( ); - let searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'js-search'); + const searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'js-search'); expect(searchBox).to.be.empty; }); it('should search', (done) => { - let searchSpy = sinon.spy(); - let component = TestUtils.renderIntoDocument( + const searchSpy = sinon.spy(); + const component = TestUtils.renderIntoDocument( ); - let searchInput = ReactDOM.findDOMNode( + const searchInput = ReactDOM.findDOMNode( TestUtils.findRenderedDOMComponentWithClass(component, 'js-search')); searchInput.value = 'some search query'; TestUtils.Simulate.change(searchInput); setTimeout(() => { - expect(searchSpy).to.have.been.calledWith({ query: "some search query" }); + expect(searchSpy).to.have.been.calledWith({ query: 'some search query' }); done(); }, DEBOUNCE_DELAY); }); it('should reload', () => { - let reloadSpy = sinon.spy(); - let component = TestUtils.renderIntoDocument( + const reloadSpy = sinon.spy(); + const component = TestUtils.renderIntoDocument( ); - let reloadButton = component.refs.reloadButton; + const reloadButton = component.refs.reloadButton; expect(reloadSpy).to.not.have.been.called; TestUtils.Simulate.click(reloadButton); expect(reloadSpy).to.have.been.called; @@ -82,33 +98,33 @@ describe('Background Tasks', function () { describe('Stats', () => { describe('Pending', () => { it('should show zero pending', () => { - let result = TestUtils.renderIntoDocument(); - let pendingCounter = result.refs.pendingCount; + const result = TestUtils.renderIntoDocument(); + const pendingCounter = result.refs.pendingCount; expect(pendingCounter.textContent).to.contain('0'); }); it('should show 5 pending', () => { - let result = TestUtils.renderIntoDocument(); - let pendingCounter = result.refs.pendingCount; + const result = TestUtils.renderIntoDocument(); + const pendingCounter = result.refs.pendingCount; expect(pendingCounter.textContent).to.contain('5'); }); it('should not show cancel pending button', () => { - let result = TestUtils.renderIntoDocument(); - let cancelPending = result.refs.cancelPending; + const result = TestUtils.renderIntoDocument(); + const cancelPending = result.refs.cancelPending; expect(cancelPending).to.not.be.ok; }); it('should show cancel pending button', () => { - let result = TestUtils.renderIntoDocument(); - let cancelPending = result.refs.cancelPending; + const result = TestUtils.renderIntoDocument(); + const cancelPending = result.refs.cancelPending; expect(cancelPending).to.be.ok; }); it('should trigger cancelling pending', () => { - let spy = sinon.spy(); - let result = TestUtils.renderIntoDocument(); - let cancelPending = result.refs.cancelPending; + const spy = sinon.spy(); + const result = TestUtils.renderIntoDocument(); + const cancelPending = result.refs.cancelPending; expect(spy).to.not.have.been.called; TestUtils.Simulate.click(cancelPending); expect(spy).to.have.been.called; @@ -117,33 +133,33 @@ describe('Background Tasks', function () { describe('Failures', () => { it('should show zero failures', () => { - let result = TestUtils.renderIntoDocument(); - let failureCounter = result.refs.failureCount; + const result = TestUtils.renderIntoDocument(); + const failureCounter = result.refs.failureCount; expect(failureCounter.textContent).to.contain('0'); }); it('should show 5 failures', () => { - let result = TestUtils.renderIntoDocument(); - let failureCounter = result.refs.failureCount; + const result = TestUtils.renderIntoDocument(); + const failureCounter = result.refs.failureCount; expect(failureCounter.textContent).to.contain('5'); }); it('should not show link to failures', () => { - let result = TestUtils.renderIntoDocument(); - let failureCounter = result.refs.failureCount; + const result = TestUtils.renderIntoDocument(); + const failureCounter = result.refs.failureCount; expect(failureCounter.tagName.toLowerCase()).to.not.equal('a'); }); it('should show link to failures', () => { - let result = TestUtils.renderIntoDocument(); - let failureCounter = result.refs.failureCount; + const result = TestUtils.renderIntoDocument(); + const failureCounter = result.refs.failureCount; expect(failureCounter.tagName.toLowerCase()).to.equal('a'); }); it('should trigger filtering failures', () => { - let spy = sinon.spy(); - let result = TestUtils.renderIntoDocument(); - let failureCounter = result.refs.failureCount; + const spy = sinon.spy(); + const result = TestUtils.renderIntoDocument(); + const failureCounter = result.refs.failureCount; expect(spy).to.not.have.been.called; TestUtils.Simulate.click(failureCounter); expect(spy).to.have.been.called; diff --git a/server/sonar-web/tests/apps/overview/components/App-test.js b/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.js similarity index 87% rename from server/sonar-web/tests/apps/overview/components/App-test.js rename to server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.js index 08488916e7a..ad699ec13ab 100644 --- a/server/sonar-web/tests/apps/overview/components/App-test.js +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.js @@ -21,9 +21,9 @@ import React from 'react'; import { expect } from 'chai'; import { shallow } from 'enzyme'; -import App from '../../../../src/main/js/apps/overview/components/App'; -import OverviewApp from '../../../../src/main/js/apps/overview/components/OverviewApp'; -import EmptyOverview from '../../../../src/main/js/apps/overview/components/EmptyOverview'; +import App from '../App'; +import OverviewApp from '../OverviewApp'; +import EmptyOverview from '../EmptyOverview'; describe('Overview :: App', () => { it('should render OverviewApp', () => { diff --git a/server/sonar-web/tests/apps/overview/components/EmptyOverview-test.js b/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.js similarity index 93% rename from server/sonar-web/tests/apps/overview/components/EmptyOverview-test.js rename to server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.js index 65a1c0dae3c..d9c499a9bfe 100644 --- a/server/sonar-web/tests/apps/overview/components/EmptyOverview-test.js +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/EmptyOverview-test.js @@ -21,7 +21,7 @@ import React from 'react'; import { expect } from 'chai'; import { shallow } from 'enzyme'; -import EmptyOverview from '../../../../src/main/js/apps/overview/components/EmptyOverview'; +import EmptyOverview from '../EmptyOverview'; describe('Overview :: EmptyOverview', () => { it('should render component key', () => { diff --git a/server/sonar-web/tests/apps/overview/qualityGate/QualityGateCondition-test.js b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGateCondition-test.js similarity index 89% rename from server/sonar-web/tests/apps/overview/qualityGate/QualityGateCondition-test.js rename to server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGateCondition-test.js index 3f0e924cc81..dcd29111176 100644 --- a/server/sonar-web/tests/apps/overview/qualityGate/QualityGateCondition-test.js +++ b/server/sonar-web/src/main/js/apps/overview/qualityGate/__tests__/QualityGateCondition-test.js @@ -21,8 +21,8 @@ import React from 'react'; import { expect } from 'chai'; import { shallow } from 'enzyme'; -import QualityGateCondition from '../../../../src/main/js/apps/overview/qualityGate/QualityGateCondition'; -import { DrilldownLink } from '../../../../src/main/js/components/shared/drilldown-link'; +import QualityGateCondition from '../QualityGateCondition'; +import { DrilldownLink } from '../../../../components/shared/drilldown-link'; describe('Overview :: QualityGateCondition', () => { it('should render DrilldownLink', () => { diff --git a/server/sonar-web/tests/apps/permission-templates-test.js b/server/sonar-web/src/main/js/apps/permission-templates/__tests__/permission-templates-test.js similarity index 58% rename from server/sonar-web/tests/apps/permission-templates-test.js rename to server/sonar-web/src/main/js/apps/permission-templates/__tests__/permission-templates-test.js index be99e6f54fd..ade4d7b5872 100644 --- a/server/sonar-web/tests/apps/permission-templates-test.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/__tests__/permission-templates-test.js @@ -1,19 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ /* eslint no-unused-expressions: 0 */ import React from 'react'; import TestUtils from 'react-addons-test-utils'; +import { expect } from 'chai'; +import sinon from 'sinon'; -import Defaults from '../../src/main/js/apps/permission-templates/permission-template-defaults'; -import SetDefaults from '../../src/main/js/apps/permission-templates/permission-template-set-defaults'; - -let expect = require('chai').expect; -let sinon = require('sinon'); +import Defaults from '../permission-template-defaults'; +import SetDefaults from '../permission-template-set-defaults'; describe('Permission Templates', function () { describe('Defaults', () => { it('should display one qualifier', () => { - let permissionTemplate = { defaultFor: ['VW'] }, - topQualifiers = ['TRK', 'VW']; - let result = TestUtils.renderIntoDocument( + const permissionTemplate = { defaultFor: ['VW'] }; + const topQualifiers = ['TRK', 'VW']; + const result = TestUtils.renderIntoDocument( ); expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'icon-qualifier-trk')).to.be.empty; @@ -21,9 +39,9 @@ describe('Permission Templates', function () { }); it('should display two qualifiers', () => { - let permissionTemplate = { defaultFor: ['TRK', 'VW'] }, - topQualifiers = ['TRK', 'VW']; - let result = TestUtils.renderIntoDocument( + const permissionTemplate = { defaultFor: ['TRK', 'VW'] }; + const topQualifiers = ['TRK', 'VW']; + const result = TestUtils.renderIntoDocument( ); expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'icon-qualifier-trk')).to.have.length(1); @@ -31,9 +49,9 @@ describe('Permission Templates', function () { }); it('should not display qualifiers', () => { - let permissionTemplate = { defaultFor: [] }, - topQualifiers = ['TRK', 'VW']; - let result = TestUtils.renderIntoDocument( + const permissionTemplate = { defaultFor: [] }; + const topQualifiers = ['TRK', 'VW']; + const result = TestUtils.renderIntoDocument( ); expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'icon-qualifier-trk')).to.be.empty; @@ -41,9 +59,9 @@ describe('Permission Templates', function () { }); it('should omit "project" if there is only one qualifier', () => { - let permissionTemplate = { defaultFor: ['TRK'] }, - topQualifiers = ['TRK']; - let result = TestUtils.renderIntoDocument( + const permissionTemplate = { defaultFor: ['TRK'] }; + const topQualifiers = ['TRK']; + const result = TestUtils.renderIntoDocument( ); expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'icon-qualifier-trk')).to.be.empty; @@ -51,12 +69,12 @@ describe('Permission Templates', function () { }); describe('SetDefaults', () => { - var refresh = sinon.spy(); + const refresh = sinon.spy(); it('should display a dropdown with one option', () => { - let permissionTemplate = { defaultFor: ['VW'] }, - topQualifiers = ['TRK', 'VW']; - let result = TestUtils.renderIntoDocument( + const permissionTemplate = { defaultFor: ['VW'] }; + const topQualifiers = ['TRK', 'VW']; + const result = TestUtils.renderIntoDocument( ); expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'dropdown')).to.have.length(1); @@ -64,9 +82,9 @@ describe('Permission Templates', function () { }); it('should display a dropdown with two options', () => { - let permissionTemplate = { defaultFor: [] }, - topQualifiers = ['TRK', 'VW']; - let result = TestUtils.renderIntoDocument( + const permissionTemplate = { defaultFor: [] }; + const topQualifiers = ['TRK', 'VW']; + const result = TestUtils.renderIntoDocument( ); expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'dropdown')).to.have.length(1); @@ -74,9 +92,9 @@ describe('Permission Templates', function () { }); it('should not display a dropdown', () => { - let permissionTemplate = { defaultFor: ['TRK', 'VW'] }, - topQualifiers = ['TRK', 'VW']; - let result = TestUtils.renderIntoDocument( + const permissionTemplate = { defaultFor: ['TRK', 'VW'] }; + const topQualifiers = ['TRK', 'VW']; + const result = TestUtils.renderIntoDocument( ); expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'dropdown')).to.be.empty; @@ -84,9 +102,9 @@ describe('Permission Templates', function () { }); it('should omit dropdown if there is only one qualifier', () => { - let permissionTemplate = { defaultFor: [] }, - topQualifiers = ['TRK']; - let result = TestUtils.renderIntoDocument( + const permissionTemplate = { defaultFor: [] }; + const topQualifiers = ['TRK']; + const result = TestUtils.renderIntoDocument( ); expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'dropdown')).to.be.empty; diff --git a/server/sonar-web/src/main/js/apps/projects/__tests__/projects-test.js b/server/sonar-web/src/main/js/apps/projects/__tests__/projects-test.js new file mode 100644 index 00000000000..51f0ba2945c --- /dev/null +++ b/server/sonar-web/src/main/js/apps/projects/__tests__/projects-test.js @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import { expect } from 'chai'; +import sinon from 'sinon'; + +import Projects from '../projects'; + +describe('Projects', function () { + describe('Projects', () => { + it('should render list of projects with no selection', () => { + const projects = [ + { id: '1', key: 'a', name: 'A', qualifier: 'TRK' }, + { id: '2', key: 'b', name: 'B', qualifier: 'TRK' } + ]; + + const result = TestUtils.renderIntoDocument( + ); + expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'tr')).to.have.length(2); + expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'icon-checkbox-checked')).to.be.empty; + }); + + it('should render list of projects with one selected', () => { + const projects = [ + { id: '1', key: 'a', name: 'A', qualifier: 'TRK' }, + { id: '2', key: 'b', name: 'B', qualifier: 'TRK' } + ]; + const selection = ['1']; + + const result = TestUtils.renderIntoDocument( + ); + expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'tr')).to.have.length(2); + expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'icon-checkbox-checked')).to.have.length(1); + }); + }); +}); diff --git a/server/sonar-web/tests/apps/system-test.js b/server/sonar-web/src/main/js/apps/system/__tests__/system-test.js similarity index 51% rename from server/sonar-web/tests/apps/system-test.js rename to server/sonar-web/src/main/js/apps/system/__tests__/system-test.js index a7a9c529d2d..2de40ad8393 100644 --- a/server/sonar-web/tests/apps/system-test.js +++ b/server/sonar-web/src/main/js/apps/system/__tests__/system-test.js @@ -1,53 +1,72 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ import React from 'react'; import ReactDOM from 'react-dom'; import TestUtils from 'react-addons-test-utils'; +import { expect } from 'chai'; -import ItemValue from '../../src/main/js/apps/system/item-value'; - -let expect = require('chai').expect; -let sinon = require('sinon'); +import ItemValue from '../item-value'; describe('System', function () { describe('Item Value', function () { it('should render string', () => { - let result = TestUtils.renderIntoDocument(); - let content = ReactDOM.findDOMNode(TestUtils.findRenderedDOMComponentWithTag(result, 'code')); + const result = TestUtils.renderIntoDocument(); + const content = ReactDOM.findDOMNode(TestUtils.findRenderedDOMComponentWithTag(result, 'code')); expect(content.textContent).to.equal('/some/path/as/an/example'); }); it('should render `true`', () => { - let result = TestUtils.renderIntoDocument(); + const result = TestUtils.renderIntoDocument(); TestUtils.findRenderedDOMComponentWithClass(result, 'icon-check'); }); it('should render `false`', () => { - let result = TestUtils.renderIntoDocument(); + const result = TestUtils.renderIntoDocument(); TestUtils.findRenderedDOMComponentWithClass(result, 'icon-delete'); }); it('should render object', () => { - let result = TestUtils.renderIntoDocument(); + const result = TestUtils.renderIntoDocument(); TestUtils.findRenderedDOMComponentWithTag(result, 'table'); expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'tr')).to.have.length(2); }); it('should render `true` inside object', () => { - let result = TestUtils.renderIntoDocument(); + const result = TestUtils.renderIntoDocument(); TestUtils.findRenderedDOMComponentWithTag(result, 'table'); TestUtils.findRenderedDOMComponentWithClass(result, 'icon-check'); }); it('should render object inside object', () => { - let result = TestUtils.renderIntoDocument( - ); + const result = TestUtils.renderIntoDocument( + ); expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'table')).to.have.length(3); expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'tr')).to.have.length(6); }); }); describe('Log Level', function () { - var previousFetch, fetchUrl, fetchOptions; + let previousFetch; + let fetchUrl; + let fetchOptions; before(function () { previousFetch = window.fetch; @@ -63,30 +82,30 @@ describe('System', function () { }); it('should render select box', () => { - let result = TestUtils.renderIntoDocument(); + const result = TestUtils.renderIntoDocument(); TestUtils.findRenderedDOMComponentWithTag(result, 'select'); expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'option')).to.have.length(3); }); it('should set initial value', () => { - let result = TestUtils.renderIntoDocument(); - let select = ReactDOM.findDOMNode(TestUtils.findRenderedDOMComponentWithTag(result, 'select')); + const result = TestUtils.renderIntoDocument(); + const select = ReactDOM.findDOMNode(TestUtils.findRenderedDOMComponentWithTag(result, 'select')); expect(select.value).to.equal('DEBUG'); }); it('should render warning', () => { - let result = TestUtils.renderIntoDocument(); + const result = TestUtils.renderIntoDocument(); TestUtils.findRenderedDOMComponentWithClass(result, 'alert'); }); it('should not render warning', () => { - let result = TestUtils.renderIntoDocument(); + const result = TestUtils.renderIntoDocument(); expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'alert')).to.be.empty; }); it('should change value', () => { - let result = TestUtils.renderIntoDocument(); - let select = ReactDOM.findDOMNode(TestUtils.findRenderedDOMComponentWithTag(result, 'select')); + const result = TestUtils.renderIntoDocument(); + const select = ReactDOM.findDOMNode(TestUtils.findRenderedDOMComponentWithTag(result, 'select')); select.value = 'TRACE'; TestUtils.Simulate.change(select); expect(fetchUrl).to.equal('/api/system/change_log_level'); diff --git a/server/sonar-web/tests/components/issue-test.js b/server/sonar-web/src/main/js/components/__tests__/issue-test.js similarity index 59% rename from server/sonar-web/tests/components/issue-test.js rename to server/sonar-web/src/main/js/components/__tests__/issue-test.js index 34b0312b0fc..75d4e89f119 100644 --- a/server/sonar-web/tests/components/issue-test.js +++ b/server/sonar-web/src/main/js/components/__tests__/issue-test.js @@ -1,68 +1,86 @@ -import Issue from '../../src/main/js/components/issue/models/issue'; - -let sinon = require('sinon'), - sinonChai = require('sinon-chai'), - chai = require('chai'), - expect = chai.expect; +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import chai, { expect } from 'chai'; +import sinon from 'sinon'; +import sinonChai from 'sinon-chai'; + +import Issue from '../issue/models/issue'; chai.use(sinonChai); describe('Issue', function () { describe('Model', function () { it('should have correct urlRoot', function () { - var issue = new Issue(); + const issue = new Issue(); expect(issue.urlRoot()).to.equal('/api/issues'); }); it('should parse response without root issue object', function () { - var issue = new Issue(); - var example = { a: 1 }; + const issue = new Issue(); + const example = { a: 1 }; expect(issue.parse(example)).to.deep.equal(example); }); it('should parse response with the root issue object', function () { - var issue = new Issue(); - var example = { a: 1 }; + const issue = new Issue(); + const example = { a: 1 }; expect(issue.parse({ issue: example })).to.deep.equal(example); }); it('should reset attributes (no attributes initially)', function () { - var issue = new Issue(); - var example = { a: 1 }; + const issue = new Issue(); + const example = { a: 1 }; issue.reset(example); expect(issue.toJSON()).to.deep.equal(example); }); it('should reset attributes (override attribute)', function () { - var issue = new Issue({ a: 2 }); - var example = { a: 1 }; + const issue = new Issue({ a: 2 }); + const example = { a: 1 }; issue.reset(example); expect(issue.toJSON()).to.deep.equal(example); }); it('should reset attributes (different attributes)', function () { - var issue = new Issue({ a: 2 }); - var example = { b: 1 }; + const issue = new Issue({ a: 2 }); + const example = { b: 1 }; issue.reset(example); expect(issue.toJSON()).to.deep.equal(example); }); it('should unset `textRange` of a closed issue', function () { - var issue = new Issue(); - var result = issue.parse({ issue: { status: 'CLOSED', textRange: { startLine: 5 } } }); + const issue = new Issue(); + const result = issue.parse({ issue: { status: 'CLOSED', textRange: { startLine: 5 } } }); expect(result.textRange).to.not.be.ok; }); it('should unset `flows` of a closed issue', function () { - var issue = new Issue(); - var result = issue.parse({ issue: { status: 'CLOSED', flows: [1, 2, 3] } }); + const issue = new Issue(); + const result = issue.parse({ issue: { status: 'CLOSED', flows: [1, 2, 3] } }); expect(result.flows).to.deep.equal([]); }); describe('Actions', function () { it('should assign', function () { - var issue = new Issue({ key: 'issue-key' }); - var spy = sinon.spy(); + const issue = new Issue({ key: 'issue-key' }); + const spy = sinon.spy(); issue._action = spy; issue.assign('admin'); expect(spy).to.have.been.calledWith({ @@ -72,8 +90,8 @@ describe('Issue', function () { }); it('should unassign', function () { - var issue = new Issue({ key: 'issue-key' }); - var spy = sinon.spy(); + const issue = new Issue({ key: 'issue-key' }); + const spy = sinon.spy(); issue._action = spy; issue.assign(); expect(spy).to.have.been.calledWith({ @@ -83,24 +101,24 @@ describe('Issue', function () { }); it('should plan', function () { - var issue = new Issue({ key: 'issue-key' }); - var spy = sinon.spy(); + const issue = new Issue({ key: 'issue-key' }); + const spy = sinon.spy(); issue._action = spy; issue.plan('plan'); expect(spy).to.have.been.calledWith({ data: { plan: 'plan', issue: 'issue-key' }, url: '/api/issues/plan' }); }); it('should unplan', function () { - var issue = new Issue({ key: 'issue-key' }); - var spy = sinon.spy(); + const issue = new Issue({ key: 'issue-key' }); + const spy = sinon.spy(); issue._action = spy; issue.plan(); expect(spy).to.have.been.calledWith({ data: { plan: undefined, issue: 'issue-key' }, url: '/api/issues/plan' }); }); it('should set severity', function () { - var issue = new Issue({ key: 'issue-key' }); - var spy = sinon.spy(); + const issue = new Issue({ key: 'issue-key' }); + const spy = sinon.spy(); issue._action = spy; issue.setSeverity('BLOCKER'); expect(spy).to.have.been.calledWith({ @@ -112,8 +130,8 @@ describe('Issue', function () { describe('#getLinearLocations', function () { it('should return single line location', function () { - var issue = new Issue({ textRange: { startLine: 1, endLine: 1, startOffset: 0, endOffset: 10 } }), - locations = issue.getLinearLocations(); + const issue = new Issue({ textRange: { startLine: 1, endLine: 1, startOffset: 0, endOffset: 10 } }); + const locations = issue.getLinearLocations(); expect(locations.length).to.equal(1); expect(locations[0].line).to.equal(1); @@ -122,8 +140,8 @@ describe('Issue', function () { }); it('should return location not from 0', function () { - var issue = new Issue({ textRange: { startLine: 1, endLine: 1, startOffset: 5, endOffset: 10 } }), - locations = issue.getLinearLocations(); + const issue = new Issue({ textRange: { startLine: 1, endLine: 1, startOffset: 5, endOffset: 10 } }); + const locations = issue.getLinearLocations(); expect(locations.length).to.equal(1); expect(locations[0].line).to.equal(1); @@ -132,8 +150,8 @@ describe('Issue', function () { }); it('should return 2-lines location', function () { - var issue = new Issue({ textRange: { startLine: 2, endLine: 3, startOffset: 5, endOffset: 10 } }), - locations = issue.getLinearLocations(); + const issue = new Issue({ textRange: { startLine: 2, endLine: 3, startOffset: 5, endOffset: 10 } }); + const locations = issue.getLinearLocations(); expect(locations.length).to.equal(2); expect(locations[0].line).to.equal(2); @@ -146,8 +164,8 @@ describe('Issue', function () { }); it('should return 3-lines location', function () { - var issue = new Issue({ textRange: { startLine: 4, endLine: 6, startOffset: 5, endOffset: 10 } }), - locations = issue.getLinearLocations(); + const issue = new Issue({ textRange: { startLine: 4, endLine: 6, startOffset: 5, endOffset: 10 } }); + const locations = issue.getLinearLocations(); expect(locations.length).to.equal(3); expect(locations[0].line).to.equal(4); @@ -164,8 +182,8 @@ describe('Issue', function () { }); it('should return [] when no location', function () { - var issue = new Issue(), - locations = issue.getLinearLocations(); + const issue = new Issue(); + const locations = issue.getLinearLocations(); expect(locations.length).to.equal(0); }); }); diff --git a/server/sonar-web/src/main/js/components/__tests__/source-viewer-test.js b/server/sonar-web/src/main/js/components/__tests__/source-viewer-test.js new file mode 100644 index 00000000000..99ce9b0d700 --- /dev/null +++ b/server/sonar-web/src/main/js/components/__tests__/source-viewer-test.js @@ -0,0 +1,109 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { expect } from 'chai'; + +import helper from '../source-viewer/helpers/code-with-issue-locations-helper'; + +describe('Source Viewer', function () { + describe('Code With Issue Locations Helper', function () { + it('should be a function', function () { + expect(helper).to.be.a('function'); + }); + + it('should mark one location', function () { + const code = 'if (a + 1) {'; + const locations = [{ from: 1, to: 5 }]; + const result = helper(code, locations, 'x'); + expect(result).to.equal([ + 'i', + 'f', + ' (', + 'a', + ' + ', + '1', + ') {' + ].join('')); + }); + + it('should mark two locations', function () { + const code = 'abcdefghijklmnopqrst'; + const locations = [ + { from: 1, to: 6 }, + { from: 11, to: 16 } + ]; + const result = helper(code, locations, 'x'); + expect(result).to.equal([ + 'a', + 'bcdef', + 'ghijk', + 'lmnop', + 'qrst' + ].join('')); + }); + + it('should mark one locations', function () { + const code = ' * Copyright (C) 2008-2014 SonarSource'; + const locations = [{ from: 15, to: 20 }]; + const result = helper(code, locations, 'x'); + expect(result).to.equal([ + ' * Copyright (C', + ') 200', + '8-2014 SonarSource' + ].join('')); + }); + + it('should mark two locations', function () { + const code = ' * Copyright (C) 2008-2014 SonarSource'; + const locations = [ + { from: 24, to: 29 }, + { from: 15, to: 20 } + ]; + const result = helper(code, locations, 'x'); + expect(result).to.equal([ + ' * Copyright (C', + ') 200', + '8-20', + '14 So', + 'narSource' + ].join('')); + }); + + it('should parse line with < and >', function () { + const code = '#include <stdio.h>'; + const result = helper(code, []); + expect(result).to.equal('#include <stdio.h>'); + }); + + it('should parse syntax and usage highlighting', function () { + const code = 'this'; + const expected = 'this'; + const result = helper(code, []); + expect(result).to.equal(expected); + }); + + it('should parse nested tags', function () { + const code = 'this is'; + const expected = 'this is'; + const result = helper(code, []); + expect(result).to.equal(expected); + }); + }); +}); + diff --git a/server/sonar-web/src/main/js/components/charts/__tests__/bar-chart-test.js b/server/sonar-web/src/main/js/components/charts/__tests__/bar-chart-test.js new file mode 100644 index 00000000000..d3c50a49eb6 --- /dev/null +++ b/server/sonar-web/src/main/js/components/charts/__tests__/bar-chart-test.js @@ -0,0 +1,97 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import { expect } from 'chai'; + +import { BarChart } from '../bar-chart'; + +describe('Bar Chart', function () { + + it('should display bars', function () { + const data = [ + { x: 1, y: 10 }, + { x: 2, y: 30 }, + { x: 3, y: 20 } + ]; + const chart = TestUtils.renderIntoDocument( + ); + expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bar-chart-bar')).to.have.length(3); + }); + + it('should display ticks', function () { + const data = [ + { x: 1, y: 10 }, + { x: 2, y: 30 }, + { x: 3, y: 20 } + ]; + const ticks = ['A', 'B', 'C']; + const chart = TestUtils.renderIntoDocument( + ); + expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bar-chart-tick')).to.have.length(3); + }); + + it('should display values', function () { + const data = [ + { x: 1, y: 10 }, + { x: 2, y: 30 }, + { x: 3, y: 20 } + ]; + const values = ['A', 'B', 'C']; + const chart = TestUtils.renderIntoDocument( + ); + expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bar-chart-tick')).to.have.length(3); + }); + + it('should display bars, ticks and values', function () { + const data = [ + { x: 1, y: 10 }, + { x: 2, y: 30 }, + { x: 3, y: 20 } + ]; + const ticks = ['A', 'B', 'C']; + const values = ['A', 'B', 'C']; + const chart = TestUtils.renderIntoDocument( + ); + expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bar-chart-bar')).to.have.length(3); + expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bar-chart-tick')).to.have.length(6); + }); + +}); diff --git a/server/sonar-web/src/main/js/components/charts/__tests__/bubble-chart-test.js b/server/sonar-web/src/main/js/components/charts/__tests__/bubble-chart-test.js new file mode 100644 index 00000000000..bb03185276a --- /dev/null +++ b/server/sonar-web/src/main/js/components/charts/__tests__/bubble-chart-test.js @@ -0,0 +1,58 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import { expect } from 'chai'; + +import { BubbleChart } from '../bubble-chart'; + +describe('Bubble Chart', function () { + + it('should display bubbles', function () { + const items = [ + { x: 1, y: 10, size: 7 }, + { x: 2, y: 30, size: 5 }, + { x: 3, y: 20, size: 2 } + ]; + const chart = TestUtils.renderIntoDocument(); + expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bubble-chart-bubble')).to.have.length(3); + }); + + it('should display grid', function () { + const items = [ + { x: 1, y: 10, size: 7 }, + { x: 2, y: 30, size: 5 }, + { x: 3, y: 20, size: 2 } + ]; + const chart = TestUtils.renderIntoDocument(); + expect(TestUtils.scryRenderedDOMComponentsWithTag(chart, 'line')).to.not.be.empty; + }); + + it('should display ticks', function () { + const items = [ + { x: 1, y: 10, size: 7 }, + { x: 2, y: 30, size: 5 }, + { x: 3, y: 20, size: 2 } + ]; + const chart = TestUtils.renderIntoDocument(); + expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bubble-chart-tick')).to.not.be.empty; + }); + +}); diff --git a/server/sonar-web/src/main/js/components/charts/__tests__/line-chart-test.js b/server/sonar-web/src/main/js/components/charts/__tests__/line-chart-test.js new file mode 100644 index 00000000000..e4144bb97bf --- /dev/null +++ b/server/sonar-web/src/main/js/components/charts/__tests__/line-chart-test.js @@ -0,0 +1,74 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import { expect } from 'chai'; + +import { LineChart } from '../line-chart'; + +describe('Line Chart', function () { + + it('should display line', function () { + const data = [ + { x: 1, y: 10 }, + { x: 2, y: 30 }, + { x: 3, y: 20 } + ]; + const chart = TestUtils.renderIntoDocument( + ); + expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'line-chart-path')).to.have.length(1); + }); + + it('should display ticks', function () { + const data = [ + { x: 1, y: 10 }, + { x: 2, y: 30 }, + { x: 3, y: 20 } + ]; + const ticks = ['A', 'B', 'C']; + const chart = TestUtils.renderIntoDocument( + ); + expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'line-chart-tick')).to.have.length(3); + }); + + it('should display values', function () { + const data = [ + { x: 1, y: 10 }, + { x: 2, y: 30 }, + { x: 3, y: 20 } + ]; + const values = ['A', 'B', 'C']; + const chart = TestUtils.renderIntoDocument( + ); + expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'line-chart-tick')).to.have.length(3); + }); + +}); diff --git a/server/sonar-web/src/main/js/components/charts/__tests__/treemap-test.js b/server/sonar-web/src/main/js/components/charts/__tests__/treemap-test.js new file mode 100644 index 00000000000..1ce0054bcb7 --- /dev/null +++ b/server/sonar-web/src/main/js/components/charts/__tests__/treemap-test.js @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import { expect } from 'chai'; + +import { Treemap } from '../treemap'; + +describe('Treemap', function () { + + it('should display', function () { + const items = [ + { size: 10, color: '#777', label: 'SonarQube :: Server' }, + { size: 30, color: '#777', label: 'SonarQube :: Web' }, + { size: 20, color: '#777', label: 'SonarQube :: Search' } + ]; + const chart = TestUtils.renderIntoDocument( + true}/>); + expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'treemap-cell')).to.have.length(3); + }); + +}); diff --git a/server/sonar-web/src/main/js/components/charts/__tests__/work-cloud-test.js b/server/sonar-web/src/main/js/components/charts/__tests__/work-cloud-test.js new file mode 100644 index 00000000000..177151ae053 --- /dev/null +++ b/server/sonar-web/src/main/js/components/charts/__tests__/work-cloud-test.js @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import { expect } from 'chai'; + +import { WordCloud } from '../word-cloud'; + +describe('Word Cloud', function () { + + it('should display', function () { + const items = [ + { size: 10, link: '#', text: 'SonarQube :: Server' }, + { size: 30, link: '#', text: 'SonarQube :: Web' }, + { size: 20, link: '#', text: 'SonarQube :: Search' } + ]; + const chart = TestUtils.renderIntoDocument(); + expect(TestUtils.scryRenderedDOMComponentsWithTag(chart, 'a')).to.have.length(3); + }); + +}); diff --git a/server/sonar-web/tests/helpers/l10n-test.js b/server/sonar-web/src/main/js/helpers/__tests__/l10n-test.js similarity index 73% rename from server/sonar-web/tests/helpers/l10n-test.js rename to server/sonar-web/src/main/js/helpers/__tests__/l10n-test.js index 068cb5b22e8..2bfb21308c1 100644 --- a/server/sonar-web/tests/helpers/l10n-test.js +++ b/server/sonar-web/src/main/js/helpers/__tests__/l10n-test.js @@ -1,5 +1,24 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ import { expect } from 'chai'; -import { resetBundle, translate, translateWithParameters } from '../../src/main/js/helpers/l10n'; +import { resetBundle, translate, translateWithParameters } from '../l10n'; describe('l10n', () => { afterEach(() => { diff --git a/server/sonar-web/tests/helpers/measures-test.js b/server/sonar-web/src/main/js/helpers/__tests__/measures-test.js similarity index 91% rename from server/sonar-web/tests/helpers/measures-test.js rename to server/sonar-web/src/main/js/helpers/__tests__/measures-test.js index 0b27578c852..e6c377bce01 100644 --- a/server/sonar-web/tests/helpers/measures-test.js +++ b/server/sonar-web/src/main/js/helpers/__tests__/measures-test.js @@ -1,14 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ import { expect } from 'chai'; -import { resetBundle } from '../../src/main/js/helpers/l10n'; -import { formatMeasure, formatMeasureVariation } from '../../src/main/js/helpers/measures'; - +import { resetBundle } from '../l10n'; +import { formatMeasure, formatMeasureVariation } from '../measures'; describe('Measures', function () { - var HOURS_IN_DAY = 8, - ONE_MINUTE = 1, - ONE_HOUR = ONE_MINUTE * 60, - ONE_DAY = HOURS_IN_DAY * ONE_HOUR; + const HOURS_IN_DAY = 8; + const ONE_MINUTE = 1; + const ONE_HOUR = ONE_MINUTE * 60; + const ONE_DAY = HOURS_IN_DAY * ONE_HOUR; before(function () { resetBundle({ diff --git a/server/sonar-web/tests/helpers/path-test.js b/server/sonar-web/src/main/js/helpers/__tests__/path-test.js similarity index 65% rename from server/sonar-web/tests/helpers/path-test.js rename to server/sonar-web/src/main/js/helpers/__tests__/path-test.js index f663fb59b12..cdd4fb885c8 100644 --- a/server/sonar-web/tests/helpers/path-test.js +++ b/server/sonar-web/src/main/js/helpers/__tests__/path-test.js @@ -1,5 +1,24 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ import { expect } from 'chai'; -import { collapsedDirFromPath, fileFromPath } from '../../src/main/js/helpers/path' +import { collapsedDirFromPath, fileFromPath } from '../path'; describe('Path', function () { describe('#collapsedDirFromPath()', function () { diff --git a/server/sonar-web/tests/helpers/urls-test.js b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.js similarity index 77% rename from server/sonar-web/tests/helpers/urls-test.js rename to server/sonar-web/src/main/js/helpers/__tests__/urls-test.js index 39b7c43b963..293b8632253 100644 --- a/server/sonar-web/tests/helpers/urls-test.js +++ b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.js @@ -1,17 +1,33 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ import { expect } from 'chai'; -import { getComponentUrl, getComponentIssuesUrl, getComponentDrilldownUrl } from '../../src/main/js/helpers/urls'; - +import { getComponentUrl, getComponentIssuesUrl, getComponentDrilldownUrl } from '../urls'; const SIMPLE_COMPONENT_KEY = 'sonarqube'; const COMPLEX_COMPONENT_KEY = 'org.sonarsource.sonarqube:sonarqube'; const COMPLEX_COMPONENT_KEY_ENCODED = encodeURIComponent(COMPLEX_COMPONENT_KEY); const METRIC = 'coverage'; -const PERIOD = '3'; - describe('URLs', function () { - var oldBaseUrl; + let oldBaseUrl; beforeEach(function () { oldBaseUrl = window.baseUrl; diff --git a/server/sonar-web/src/main/js/main/nav/__tests__/nav-test.js b/server/sonar-web/src/main/js/main/nav/__tests__/nav-test.js new file mode 100644 index 00000000000..f9b88a7da26 --- /dev/null +++ b/server/sonar-web/src/main/js/main/nav/__tests__/nav-test.js @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import { expect } from 'chai'; + +import ComponentNavBreadcrumbs from '../component/component-nav-breadcrumbs'; + +describe('Nav', function () { + describe('ComponentNavBreadcrumbs', () => { + it('should not render breadcrumbs with one element', function () { + const breadcrumbs = [ + { key: 'my-project', name: 'My Project', qualifier: 'TRK' } + ]; + const result = TestUtils.renderIntoDocument( + React.createElement(ComponentNavBreadcrumbs, { breadcrumbs }) + ); + expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'li')).to.have.length(1); + expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'a')).to.have.length(1); + }); + }); +}); diff --git a/server/sonar-web/tests/apps/projects-test.js b/server/sonar-web/tests/apps/projects-test.js deleted file mode 100644 index 3fb1768df84..00000000000 --- a/server/sonar-web/tests/apps/projects-test.js +++ /dev/null @@ -1,36 +0,0 @@ -import React from 'react'; -import TestUtils from 'react-addons-test-utils'; - -import Projects from '../../src/main/js/apps/projects/projects'; - -let expect = require('chai').expect; -let sinon = require('sinon'); - -describe('Projects', function () { - describe('Projects', () => { - it('should render list of projects with no selection', () => { - let projects = [ - { id: '1', key: 'a', name: 'A', qualifier: 'TRK' }, - { id: '2', key: 'b', name: 'B', qualifier: 'TRK' } - ]; - - let result = TestUtils.renderIntoDocument( - ); - expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'tr')).to.have.length(2); - expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'icon-checkbox-checked')).to.be.empty; - }); - - it('should render list of projects with one selected', () => { - let projects = [ - { id: '1', key: 'a', name: 'A', qualifier: 'TRK' }, - { id: '2', key: 'b', name: 'B', qualifier: 'TRK' } - ], - selection = ['1']; - - let result = TestUtils.renderIntoDocument( - ); - expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'tr')).to.have.length(2); - expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'icon-checkbox-checked')).to.have.length(1); - }); - }); -}); diff --git a/server/sonar-web/tests/components/charts/bar-chart-test.js b/server/sonar-web/tests/components/charts/bar-chart-test.js deleted file mode 100644 index e56497e4891..00000000000 --- a/server/sonar-web/tests/components/charts/bar-chart-test.js +++ /dev/null @@ -1,56 +0,0 @@ -import React from 'react'; -import TestUtils from 'react-addons-test-utils'; -import { expect } from 'chai'; - -import { BarChart } from '../../../src/main/js/components/charts/bar-chart'; - - -describe('Bar Chart', function () { - - it('should display bars', function () { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 } - ]; - let chart = TestUtils.renderIntoDocument(); - expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bar-chart-bar')).to.have.length(3); - }); - - it('should display ticks', function () { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 } - ]; - const ticks = ['A', 'B', 'C']; - let chart = TestUtils.renderIntoDocument(); - expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bar-chart-tick')).to.have.length(3); - }); - - it('should display values', function () { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 } - ]; - const values = ['A', 'B', 'C']; - let chart = TestUtils.renderIntoDocument(); - expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bar-chart-tick')).to.have.length(3); - }); - - it('should display bars, ticks and values', function () { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 } - ]; - const ticks = ['A', 'B', 'C']; - const values = ['A', 'B', 'C']; - let chart = TestUtils.renderIntoDocument( - ); - expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bar-chart-bar')).to.have.length(3); - expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bar-chart-tick')).to.have.length(6); - }); - -}); diff --git a/server/sonar-web/tests/components/charts/bubble-chart-test.js b/server/sonar-web/tests/components/charts/bubble-chart-test.js deleted file mode 100644 index f9994eacd54..00000000000 --- a/server/sonar-web/tests/components/charts/bubble-chart-test.js +++ /dev/null @@ -1,40 +0,0 @@ -import React from 'react'; -import TestUtils from 'react-addons-test-utils'; -import { expect } from 'chai'; - -import { BubbleChart } from '../../../src/main/js/components/charts/bubble-chart'; - - -describe('Bubble Chart', function () { - - it('should display bubbles', function () { - const items = [ - { x: 1, y: 10, size: 7 }, - { x: 2, y: 30, size: 5 }, - { x: 3, y: 20, size: 2 } - ]; - let chart = TestUtils.renderIntoDocument(); - expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bubble-chart-bubble')).to.have.length(3); - }); - - it('should display grid', function () { - const items = [ - { x: 1, y: 10, size: 7 }, - { x: 2, y: 30, size: 5 }, - { x: 3, y: 20, size: 2 } - ]; - let chart = TestUtils.renderIntoDocument(); - expect(TestUtils.scryRenderedDOMComponentsWithTag(chart, 'line')).to.not.be.empty; - }); - - it('should display ticks', function () { - const items = [ - { x: 1, y: 10, size: 7 }, - { x: 2, y: 30, size: 5 }, - { x: 3, y: 20, size: 2 } - ]; - let chart = TestUtils.renderIntoDocument(); - expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'bubble-chart-tick')).to.not.be.empty; - }); - -}); diff --git a/server/sonar-web/tests/components/charts/line-chart-test.js b/server/sonar-web/tests/components/charts/line-chart-test.js deleted file mode 100644 index 5e6ee4175b3..00000000000 --- a/server/sonar-web/tests/components/charts/line-chart-test.js +++ /dev/null @@ -1,42 +0,0 @@ -import React from 'react'; -import TestUtils from 'react-addons-test-utils'; -import { expect } from 'chai'; - -import { LineChart } from '../../../src/main/js/components/charts/line-chart'; - - -describe('Line Chart', function () { - - it('should display line', function () { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 } - ]; - let chart = TestUtils.renderIntoDocument(); - expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'line-chart-path')).to.have.length(1); - }); - - it('should display ticks', function () { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 } - ]; - const ticks = ['A', 'B', 'C']; - let chart = TestUtils.renderIntoDocument(); - expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'line-chart-tick')).to.have.length(3); - }); - - it('should display values', function () { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 } - ]; - const values = ['A', 'B', 'C']; - let chart = TestUtils.renderIntoDocument(); - expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'line-chart-tick')).to.have.length(3); - }); - -}); diff --git a/server/sonar-web/tests/components/charts/treemap-test.js b/server/sonar-web/tests/components/charts/treemap-test.js deleted file mode 100644 index 3200db3b11a..00000000000 --- a/server/sonar-web/tests/components/charts/treemap-test.js +++ /dev/null @@ -1,21 +0,0 @@ -import React from 'react'; -import TestUtils from 'react-addons-test-utils'; -import { expect } from 'chai'; - -import { Treemap } from '../../../src/main/js/components/charts/treemap'; - - -describe('Treemap', function () { - - it('should display', function () { - const items = [ - { size: 10, color: '#777', label: 'SonarQube :: Server' }, - { size: 30, color: '#777', label: 'SonarQube :: Web' }, - { size: 20, color: '#777', label: 'SonarQube :: Search' } - ]; - let chart = TestUtils.renderIntoDocument( - true}/>); - expect(TestUtils.scryRenderedDOMComponentsWithClass(chart, 'treemap-cell')).to.have.length(3); - }); - -}); diff --git a/server/sonar-web/tests/components/charts/work-cloud-test.js b/server/sonar-web/tests/components/charts/work-cloud-test.js deleted file mode 100644 index 4bdafe1d472..00000000000 --- a/server/sonar-web/tests/components/charts/work-cloud-test.js +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react'; -import TestUtils from 'react-addons-test-utils'; -import { expect } from 'chai'; - -import { WordCloud } from '../../../src/main/js/components/charts/word-cloud'; - - -describe('Word Cloud', function () { - - it('should display', function () { - const items = [ - { size: 10, link: '#', text: 'SonarQube :: Server' }, - { size: 30, link: '#', text: 'SonarQube :: Web' }, - { size: 20, link: '#', text: 'SonarQube :: Search' } - ]; - let chart = TestUtils.renderIntoDocument(); - expect(TestUtils.scryRenderedDOMComponentsWithTag(chart, 'a')).to.have.length(3); - }); - -}); diff --git a/server/sonar-web/tests/components/source-viewer-test.js b/server/sonar-web/tests/components/source-viewer-test.js deleted file mode 100644 index 1ee6fee310d..00000000000 --- a/server/sonar-web/tests/components/source-viewer-test.js +++ /dev/null @@ -1,90 +0,0 @@ -import helper from '../../src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper'; - -let expect = require('chai').expect; - -describe('Source Viewer', function () { - describe('Code With Issue Locations Helper', function () { - it('should be a function', function () { - expect(helper).to.be.a('function'); - }); - - it('should mark one location', function () { - var code = 'if (a + 1) {', - locations = [{ from: 1, to: 5 }], - result = helper(code, locations, 'x'); - expect(result).to.equal([ - 'i', - 'f', - ' (', - 'a', - ' + ', - '1', - ') {' - ].join('')); - }); - - it('should mark two locations', function () { - var code = 'abcdefghijklmnopqrst', - locations = [ - { from: 1, to: 6 }, - { from: 11, to: 16 } - ], - result = helper(code, locations, 'x'); - expect(result).to.equal([ - 'a', - 'bcdef', - 'ghijk', - 'lmnop', - 'qrst' - ].join('')); - }); - - it('should mark one locations', function () { - var code = ' * Copyright (C) 2008-2014 SonarSource', - locations = [{ from: 15, to: 20 }], - result = helper(code, locations, 'x'); - expect(result).to.equal([ - ' * Copyright (C', - ') 200', - '8-2014 SonarSource' - ].join('')); - }); - - it('should mark two locations', function () { - var code = ' * Copyright (C) 2008-2014 SonarSource', - locations = [ - { from: 24, to: 29 }, - { from: 15, to: 20 } - ], - result = helper(code, locations, 'x'); - expect(result).to.equal([ - ' * Copyright (C', - ') 200', - '8-20', - '14 So', - 'narSource' - ].join('')); - }); - - it('should parse line with < and >', function () { - var code = '#include <stdio.h>', - result = helper(code, []); - expect(result).to.equal('#include <stdio.h>'); - }); - - it('should parse syntax and usage highlighting', function () { - var code = 'this', - expected = 'this', - result = helper(code, []); - expect(result).to.equal(expected); - }); - - it('should parse nested tags', function () { - var code = 'this is', - expected = 'this is', - result = helper(code, []); - expect(result).to.equal(expected); - }); - }); -}); - diff --git a/server/sonar-web/tests/nav-test.js b/server/sonar-web/tests/nav-test.js deleted file mode 100644 index fc9f18eaaff..00000000000 --- a/server/sonar-web/tests/nav-test.js +++ /dev/null @@ -1,22 +0,0 @@ -import React from 'react'; -import TestUtils from 'react-addons-test-utils'; -import ComponentNavBreadcrumbs from '../src/main/js/main/nav/component/component-nav-breadcrumbs'; - - -let expect = require('chai').expect; - - -describe('Nav', function () { - describe('ComponentNavBreadcrumbs', () => { - it('should not render breadcrumbs with one element', function () { - var breadcrumbs = [ - { key: 'my-project', name: 'My Project', qualifier: 'TRK' } - ]; - var result = TestUtils.renderIntoDocument( - React.createElement(ComponentNavBreadcrumbs, { breadcrumbs: breadcrumbs }) - ); - expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'li')).to.have.length(1); - expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'a')).to.have.length(1); - }); - }); -}); -- 2.39.5