diff options
Diffstat (limited to 'server/sonar-web/tests/components')
7 files changed, 0 insertions, 442 deletions
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(<BarChart data={data} width={100} height={100} barsWidth={20}/>); - 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(<BarChart data={data} xTicks={ticks} width={100} height={100} barsWidth={20}/>); - 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(<BarChart data={data} xValues={values} width={100} height={100} barsWidth={20}/>); - 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( - <BarChart data={data} xTicks={ticks} xValues={values} width={100} height={100} barsWidth={20}/>); - 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(<BubbleChart items={items} width={100} height={100}/>); - 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(<BubbleChart items={items} width={100} height={100}/>); - 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(<BubbleChart items={items} width={100} height={100}/>); - 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(<LineChart data={data} width={100} height={100}/>); - 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(<LineChart data={data} xTicks={ticks} width={100} height={100}/>); - 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(<LineChart data={data} xValues={values} width={100} height={100}/>); - 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( - <Treemap items={items} width={100} height={100} breadcrumbs={[]} canBeClicked={() => 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(<WordCloud items={items} width={100} height={100}/>); - expect(TestUtils.scryRenderedDOMComponentsWithTag(chart, 'a')).to.have.length(3); - }); - -}); diff --git a/server/sonar-web/tests/components/issue-test.js b/server/sonar-web/tests/components/issue-test.js deleted file mode 100644 index 34b0312b0fc..00000000000 --- a/server/sonar-web/tests/components/issue-test.js +++ /dev/null @@ -1,173 +0,0 @@ -import Issue from '../../src/main/js/components/issue/models/issue'; - -let sinon = require('sinon'), - sinonChai = require('sinon-chai'), - chai = require('chai'), - expect = chai.expect; - -chai.use(sinonChai); - -describe('Issue', function () { - describe('Model', function () { - it('should have correct urlRoot', function () { - var 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 }; - 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 }; - 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 }; - 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 }; - 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 }; - 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 } } }); - 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] } }); - expect(result.flows).to.deep.equal([]); - }); - - describe('Actions', function () { - it('should assign', function () { - var issue = new Issue({ key: 'issue-key' }); - var spy = sinon.spy(); - issue._action = spy; - issue.assign('admin'); - expect(spy).to.have.been.calledWith({ - data: { assignee: 'admin', issue: 'issue-key' }, - url: '/api/issues/assign' - }); - }); - - it('should unassign', function () { - var issue = new Issue({ key: 'issue-key' }); - var spy = sinon.spy(); - issue._action = spy; - issue.assign(); - expect(spy).to.have.been.calledWith({ - data: { assignee: undefined, issue: 'issue-key' }, - url: '/api/issues/assign' - }); - }); - - it('should plan', function () { - var issue = new Issue({ key: 'issue-key' }); - var 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(); - 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(); - issue._action = spy; - issue.setSeverity('BLOCKER'); - expect(spy).to.have.been.calledWith({ - data: { severity: 'BLOCKER', issue: 'issue-key' }, - url: '/api/issues/set_severity' - }); - }); - }); - - 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(); - expect(locations.length).to.equal(1); - - expect(locations[0].line).to.equal(1); - expect(locations[0].from).to.equal(0); - expect(locations[0].to).to.equal(10); - }); - - it('should return location not from 0', function () { - var issue = new Issue({ textRange: { startLine: 1, endLine: 1, startOffset: 5, endOffset: 10 } }), - locations = issue.getLinearLocations(); - expect(locations.length).to.equal(1); - - expect(locations[0].line).to.equal(1); - expect(locations[0].from).to.equal(5); - expect(locations[0].to).to.equal(10); - }); - - it('should return 2-lines location', function () { - var issue = new Issue({ textRange: { startLine: 2, endLine: 3, startOffset: 5, endOffset: 10 } }), - locations = issue.getLinearLocations(); - expect(locations.length).to.equal(2); - - expect(locations[0].line).to.equal(2); - expect(locations[0].from).to.equal(5); - expect(locations[0].to).to.equal(999999); - - expect(locations[1].line).to.equal(3); - expect(locations[1].from).to.equal(0); - expect(locations[1].to).to.equal(10); - }); - - it('should return 3-lines location', function () { - var issue = new Issue({ textRange: { startLine: 4, endLine: 6, startOffset: 5, endOffset: 10 } }), - locations = issue.getLinearLocations(); - expect(locations.length).to.equal(3); - - expect(locations[0].line).to.equal(4); - expect(locations[0].from).to.equal(5); - expect(locations[0].to).to.equal(999999); - - expect(locations[1].line).to.equal(5); - expect(locations[1].from).to.equal(0); - expect(locations[1].to).to.equal(999999); - - expect(locations[2].line).to.equal(6); - expect(locations[2].from).to.equal(0); - expect(locations[2].to).to.equal(10); - }); - - it('should return [] when no location', function () { - var issue = new Issue(), - locations = issue.getLinearLocations(); - expect(locations.length).to.equal(0); - }); - }); - }); -}); 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 = '<span class="k">if</span> (<span class="sym-2 sym">a</span> + <span class="c">1</span>) {', - locations = [{ from: 1, to: 5 }], - result = helper(code, locations, 'x'); - expect(result).to.equal([ - '<span class="k">i</span>', - '<span class="k x">f</span>', - '<span class=" x"> (</span>', - '<span class="sym-2 sym x">a</span>', - '<span class=""> + </span>', - '<span class="c">1</span>', - '<span class="">) {</span>' - ].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([ - '<span class="">a</span>', - '<span class=" x">bcdef</span>', - '<span class="">ghijk</span>', - '<span class=" x">lmnop</span>', - '<span class="">qrst</span>' - ].join('')); - }); - - it('should mark one locations', function () { - var code = '<span class="cppd"> * Copyright (C) 2008-2014 SonarSource</span>', - locations = [{ from: 15, to: 20 }], - result = helper(code, locations, 'x'); - expect(result).to.equal([ - '<span class="cppd"> * Copyright (C</span>', - '<span class="cppd x">) 200</span>', - '<span class="cppd">8-2014 SonarSource</span>' - ].join('')); - }); - - it('should mark two locations', function () { - var code = '<span class="cppd"> * Copyright (C) 2008-2014 SonarSource</span>', - locations = [ - { from: 24, to: 29 }, - { from: 15, to: 20 } - ], - result = helper(code, locations, 'x'); - expect(result).to.equal([ - '<span class="cppd"> * Copyright (C</span>', - '<span class="cppd x">) 200</span>', - '<span class="cppd">8-20</span>', - '<span class="cppd x">14 So</span>', - '<span class="cppd">narSource</span>' - ].join('')); - }); - - it('should parse line with < and >', function () { - var code = '<span class="j">#include <stdio.h></span>', - result = helper(code, []); - expect(result).to.equal('<span class="j">#include <stdio.h></span>'); - }); - - it('should parse syntax and usage highlighting', function () { - var code = '<span class="k"><span class="sym-3 sym">this</span></span>', - expected = '<span class="k sym-3 sym">this</span>', - result = helper(code, []); - expect(result).to.equal(expected); - }); - - it('should parse nested tags', function () { - var code = '<span class="k"><span class="sym-3 sym">this</span> is</span>', - expected = '<span class="k sym-3 sym">this</span><span class="k"> is</span>', - result = helper(code, []); - expect(result).to.equal(expected); - }); - }); -}); - |