aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/tests')
-rw-r--r--server/sonar-web/tests/apps/background-tasks-test.js101
-rw-r--r--server/sonar-web/tests/apps/overview/components/language-distribution-test.js11
-rw-r--r--server/sonar-web/tests/components/source-viewer-test.js14
-rw-r--r--server/sonar-web/tests/helpers/urls-test.js17
-rw-r--r--server/sonar-web/tests/jsdom-setup.js1
5 files changed, 66 insertions, 78 deletions
diff --git a/server/sonar-web/tests/apps/background-tasks-test.js b/server/sonar-web/tests/apps/background-tasks-test.js
index 9bc486c7d63..7e3a605f9ee 100644
--- a/server/sonar-web/tests/apps/background-tasks-test.js
+++ b/server/sonar-web/tests/apps/background-tasks-test.js
@@ -3,12 +3,12 @@ import React from 'react';
import ReactDOM from 'react-dom';
import TestUtils from 'react-addons-test-utils';
-import Header from '../../src/main/js/apps/background-tasks/header';
-import Stats from '../../src/main/js/apps/background-tasks/stats';
-import Search from '../../src/main/js/apps/background-tasks/search';
-import Tasks from '../../src/main/js/apps/background-tasks/tasks';
-import {STATUSES, CURRENTS, DEBOUNCE_DELAY} from '../../src/main/js/apps/background-tasks/constants';
-import {formatDuration} from '../../src/main/js/apps/background-tasks/helpers';
+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 } from '../../src/main/js/apps/background-tasks/constants';
+import { formatDuration } from '../../src/main/js/apps/background-tasks/helpers';
let chai = require('chai');
let expect = chai.expect;
@@ -19,7 +19,7 @@ describe('Background Tasks', function () {
describe('Constants', () => {
it('should have STATUSES', () => {
expect(STATUSES).to.be.a('object');
- expect(Object.keys(STATUSES).length).to.equal(6);
+ expect(Object.keys(STATUSES).length).to.equal(7);
});
it('should have CURRENTS', () => {
@@ -28,44 +28,37 @@ describe('Background Tasks', function () {
});
});
- describe('Header', () => {
- it('should render', () => {
- let component = TestUtils.renderIntoDocument(<Header/>),
- header = TestUtils.scryRenderedDOMComponentsWithTag(component, 'header');
- expect(header.length).to.equal(1);
- });
- });
-
describe('Search', () => {
it('should render search form', () => {
- let spy = sinon.spy();
- let component = TestUtils.renderIntoDocument(<Search options={{}}
- onStatusChange={spy}
- onCurrentsChange={spy}
- onDateChange={spy}/>),
- searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'search-box');
+ let component = TestUtils.renderIntoDocument(
+ <Search
+ types={[]}
+ date={{}}/>
+ ),
+ searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'js-search');
expect(searchBox).to.have.length(1);
});
it('should not render search form', () => {
- let spy = sinon.spy();
- let component = TestUtils.renderIntoDocument(<Search options={{ component: { id: 'ABCD' } }}
- onStatusChange={spy}
- onCurrentsChange={spy}
- onDateChange={spy}/>),
- searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'search-box');
+ let component = TestUtils.renderIntoDocument(
+ <Search
+ component={{ id: 'ABCD' }}
+ types={[]}
+ date={{}}/>
+ ),
+ searchBox = TestUtils.scryRenderedDOMComponentsWithClass(component, 'js-search');
expect(searchBox).to.be.empty;
});
it('should search', (done) => {
- let spy = sinon.spy(),
- searchSpy = sinon.spy();
- let component = TestUtils.renderIntoDocument(<Search options={{}}
- onStatusChange={spy}
- onCurrentsChange={spy}
- onDateChange={spy}
- onSearch={searchSpy}/>);
- let searchInput = ReactDOM.findDOMNode(TestUtils.findRenderedDOMComponentWithClass(component, 'search-box-input'));
+ let searchSpy = sinon.spy();
+ let component = TestUtils.renderIntoDocument(
+ <Search
+ types={[]}
+ date={{}}
+ onSearch={searchSpy}/>);
+ let searchInput = ReactDOM.findDOMNode(
+ TestUtils.findRenderedDOMComponentWithClass(component, 'js-search'));
searchInput.value = 'some search query';
TestUtils.Simulate.change(searchInput);
setTimeout(() => {
@@ -75,13 +68,13 @@ describe('Background Tasks', function () {
});
it('should reload', () => {
- let spy = sinon.spy(),
- reloadSpy = sinon.spy();
- let component = TestUtils.renderIntoDocument(<Search options={{}}
- onStatusChange={spy}
- onCurrentsChange={spy}
- onDateChange={spy}
- refresh={reloadSpy}/>);
+ let reloadSpy = sinon.spy();
+ let component = TestUtils.renderIntoDocument(
+ <Search
+ types={[]}
+ date={{}}
+ onRefresh={reloadSpy}/>
+ );
let reloadButton = component.refs.reloadButton;
expect(reloadSpy).to.not.have.been.called;
TestUtils.Simulate.click(reloadButton);
@@ -117,7 +110,7 @@ describe('Background Tasks', function () {
it('should trigger cancelling pending', () => {
let spy = sinon.spy();
- let result = TestUtils.renderIntoDocument(<Stats pendingCount="5" cancelPending={spy}/>),
+ let result = TestUtils.renderIntoDocument(<Stats pendingCount="5" onCancelAllPending={spy}/>),
cancelPending = result.refs.cancelPending;
expect(spy).to.not.have.been.called;
TestUtils.Simulate.click(cancelPending);
@@ -127,32 +120,32 @@ describe('Background Tasks', function () {
describe('Failures', () => {
it('should show zero failures', () => {
- let result = TestUtils.renderIntoDocument(<Stats failuresCount="0"/>),
+ let result = TestUtils.renderIntoDocument(<Stats failingCount="0"/>),
failureCounter = result.refs.failureCount;
expect(failureCounter.textContent).to.contain('0');
});
it('should show 5 failures', () => {
- let result = TestUtils.renderIntoDocument(<Stats failuresCount="5"/>),
+ let result = TestUtils.renderIntoDocument(<Stats failingCount="5"/>),
failureCounter = result.refs.failureCount;
expect(failureCounter.textContent).to.contain('5');
});
it('should not show link to failures', () => {
- let result = TestUtils.renderIntoDocument(<Stats failuresCount="0"/>),
+ let result = TestUtils.renderIntoDocument(<Stats failingCount="0"/>),
failureCounter = result.refs.failureCount;
expect(failureCounter.tagName.toLowerCase()).to.not.equal('a');
});
it('should show link to failures', () => {
- let result = TestUtils.renderIntoDocument(<Stats failuresCount="5"/>),
+ let result = TestUtils.renderIntoDocument(<Stats failingCount="5"/>),
failureCounter = result.refs.failureCount;
expect(failureCounter.tagName.toLowerCase()).to.equal('a');
});
it('should trigger filtering failures', () => {
let spy = sinon.spy();
- let result = TestUtils.renderIntoDocument(<Stats failuresCount="5" showFailures={spy}/>),
+ let result = TestUtils.renderIntoDocument(<Stats failingCount="5" onShowFailing={spy}/>),
failureCounter = result.refs.failureCount;
expect(spy).to.not.have.been.called;
TestUtils.Simulate.click(failureCounter);
@@ -181,18 +174,6 @@ describe('Background Tasks', function () {
});
});
- describe('Tasks', () => {
- it('should show list', () => {
- let tasks = [
- { id: 'a' },
- { id: 'b' },
- { id: 'c' }
- ];
- let result = TestUtils.renderIntoDocument(<Tasks tasks={tasks}/>);
- expect(TestUtils.scryRenderedDOMComponentsWithTag(result, 'tr')).to.have.length(3 + /* table header */ 1);
- });
- });
-
describe('Helpers', () => {
describe('#formatDuration()', () => {
it('should format 173ms', () => {
diff --git a/server/sonar-web/tests/apps/overview/components/language-distribution-test.js b/server/sonar-web/tests/apps/overview/components/language-distribution-test.js
index a54ba2b1260..cf5740daa55 100644
--- a/server/sonar-web/tests/apps/overview/components/language-distribution-test.js
+++ b/server/sonar-web/tests/apps/overview/components/language-distribution-test.js
@@ -35,4 +35,15 @@ describe('LanguageDistribution', function () {
it('should pass right yValues', function () {
expect(props.yValues).to.deep.equal(['19.4%', '2.1%', '1.7%']);
});
+
+ it('should correctly render very small values', function () {
+ const DISTRIBUTION_SMALL = 'java=194342;js=999';
+
+ let renderer = TestUtils.createRenderer();
+ renderer.render(<LanguageDistribution distribution={DISTRIBUTION_SMALL} lines={LINES}/>);
+ let output = renderer.getRenderOutput();
+ let child = React.Children.only(output.props.children);
+
+ expect(child.props.yValues).to.deep.equal(['19.4%', '<0.1%']);
+ });
});
diff --git a/server/sonar-web/tests/components/source-viewer-test.js b/server/sonar-web/tests/components/source-viewer-test.js
index abdad6bcaef..1a8219e6032 100644
--- a/server/sonar-web/tests/components/source-viewer-test.js
+++ b/server/sonar-web/tests/components/source-viewer-test.js
@@ -71,6 +71,20 @@ describe('Source Viewer', function () {
result = helper(code, []);
expect(result).to.equal('<span class="j">#include &lt;stdio.h&gt;</span>');
});
+
+ // TODO SONAR-7365
+ it.skip('should parse syntax and usage highlighting', function () {
+ var code = '<span class="k"><span class="sym-3 sym">this</span></span>',
+ result = helper(code, []);
+ expect(result).to.equal(code);
+ });
+
+ // TODO SONAR-7365
+ it.skip('should parse nested tags', function () {
+ var code = '<span class="k"><span class="sym-3 sym">this</span> is</span>',
+ result = helper(code, []);
+ expect(result).to.equal(code);
+ });
});
});
diff --git a/server/sonar-web/tests/helpers/urls-test.js b/server/sonar-web/tests/helpers/urls-test.js
index da02b326155..e506ea427e4 100644
--- a/server/sonar-web/tests/helpers/urls-test.js
+++ b/server/sonar-web/tests/helpers/urls-test.js
@@ -29,11 +29,6 @@ describe('URLs', function () {
it('should encode component key', function () {
expect(getComponentUrl(COMPLEX_COMPONENT_KEY)).to.equal('/dashboard?id=' + COMPLEX_COMPONENT_KEY_ENCODED);
});
-
- it('should take baseUrl into account', function () {
- window.baseUrl = '/context';
- expect(getComponentUrl(COMPLEX_COMPONENT_KEY)).to.equal('/context/dashboard?id=' + COMPLEX_COMPONENT_KEY_ENCODED);
- });
});
describe('#getComponentIssuesUrl', function () {
@@ -56,12 +51,6 @@ describe('URLs', function () {
expect(getComponentIssuesUrl(SIMPLE_COMPONENT_KEY, { componentUuids: COMPLEX_COMPONENT_KEY })).to.equal(
'/component_issues?id=' + SIMPLE_COMPONENT_KEY + '#componentUuids=' + COMPLEX_COMPONENT_KEY_ENCODED);
});
-
- it('should take baseUrl into account', function () {
- window.baseUrl = '/context';
- expect(getComponentIssuesUrl(SIMPLE_COMPONENT_KEY, {})).to.equal(
- '/context/component_issues?id=' + SIMPLE_COMPONENT_KEY + '#');
- });
});
describe('#getComponentDrilldownUrl', function () {
@@ -79,11 +68,5 @@ describe('URLs', function () {
expect(getComponentDrilldownUrl(SIMPLE_COMPONENT_KEY, METRIC, PERIOD)).to.equal(
'/drilldown/measures?id=' + SIMPLE_COMPONENT_KEY + '&metric=' + METRIC + '&period=' + PERIOD);
});
-
- it('should take baseUrl into account', function () {
- window.baseUrl = '/context';
- expect(getComponentDrilldownUrl(SIMPLE_COMPONENT_KEY, METRIC)).to.equal(
- '/context/drilldown/measures?id=' + SIMPLE_COMPONENT_KEY + '&metric=' + METRIC);
- });
});
});
diff --git a/server/sonar-web/tests/jsdom-setup.js b/server/sonar-web/tests/jsdom-setup.js
index f1d92d7d818..6fb408ff7ef 100644
--- a/server/sonar-web/tests/jsdom-setup.js
+++ b/server/sonar-web/tests/jsdom-setup.js
@@ -9,7 +9,6 @@ global.document = jsdom.jsdom('<!doctype html><html><body></body></html>');
global.window = document.defaultView;
global.navigator = document.defaultView.navigator;
-global.window.baseUrl = '';
global.window.t = global.window.tp = function () {
var args = Array.prototype.slice.call(arguments, 0);
return args.join('.');