aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/test
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-04-16 16:51:09 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-04-16 16:51:09 +0200
commitfa47b8c758378ddad8647d039873e4f3fae8e1cf (patch)
tree276222629c2f0ec0ce689a7163a469a836c41252 /server/sonar-web/src/test
parent3b843391830ec3bb02fd229300167dd85fe45d87 (diff)
downloadsonarqube-fa47b8c758378ddad8647d039873e4f3fae8e1cf.tar.gz
sonarqube-fa47b8c758378ddad8647d039873e4f3fae8e1cf.zip
add some web tests
Diffstat (limited to 'server/sonar-web/src/test')
-rw-r--r--server/sonar-web/src/test/js/application-spec.js (renamed from server/sonar-web/src/test/js/format-measures.js)123
1 files changed, 107 insertions, 16 deletions
diff --git a/server/sonar-web/src/test/js/format-measures.js b/server/sonar-web/src/test/js/application-spec.js
index dfcee7c49ce..32db4ab2901 100644
--- a/server/sonar-web/src/test/js/format-measures.js
+++ b/server/sonar-web/src/test/js/application-spec.js
@@ -19,31 +19,77 @@
*/
/* globals casper: false */
var lib = require('../lib'),
- testName = lib.testName('Format Measures');
+ testName = lib.testName('Application');
lib.initMessages();
lib.configureCasper();
-function formatMeasure (measure, type) {
- return casper.evaluate(function (measure, type) {
- return formatMeasure(measure, type);
- }, measure, type);
-}
+casper.test.begin(testName('collapsedDirFromPath() & fileFromPath()'), function (test) {
-function formatMeasureVariation (measure, type) {
- return casper.evaluate(function (measure, type) {
- return formatMeasureVariation(measure, type);
- }, measure, type);
-}
+ function collapsedDirFromPath (path) {
+ return casper.evaluate(function (path) {
+ return window.collapsedDirFromPath(path);
+ }, path);
+ }
-var HOURS_IN_DAY = 8,
- ONE_MINUTE = 1,
- ONE_HOUR = ONE_MINUTE * 60,
- ONE_DAY = HOURS_IN_DAY * ONE_HOUR;
+ function fileFromPath (path) {
+ return casper.evaluate(function (path) {
+ return window.fileFromPath(path);
+ }, path);
+ }
+ casper
+ .start(lib.buildUrl('ui-global-messages'), function () {
+ lib.setDefaultViewport();
+ })
+
+ .then(function () {
+ test.assert(!collapsedDirFromPath(null));
+ test.assertEqual(collapsedDirFromPath('/'), '/');
+ test.assertEqual(collapsedDirFromPath('src/main/js/components/state.js'), 'src/main/js/components/');
+ test.assertEqual(collapsedDirFromPath('src/main/js/components/navigator/app/models/state.js'),
+ 'src/.../js/components/navigator/app/models/');
+ test.assertEqual(collapsedDirFromPath('src/main/another/js/components/navigator/app/models/state.js'),
+ 'src/.../js/components/navigator/app/models/');
+ })
+
+ .then(function () {
+ test.assert(!fileFromPath(null));
+ test.assertEqual(fileFromPath('/'), '');
+ test.assertEqual(fileFromPath('state.js'), 'state.js');
+ test.assertEqual(fileFromPath('src/main/js/components/state.js'), 'state.js');
+ })
+
+ .then(function () {
+ lib.sendCoverage();
+ })
+
+ .run(function () {
+ test.done();
+ });
+});
+
+
+casper.test.begin(testName('Format Measures'), function (test) {
+
+ function formatMeasure (measure, type) {
+ return casper.evaluate(function (measure, type) {
+ return formatMeasure(measure, type);
+ }, measure, type);
+ }
+
+ function formatMeasureVariation (measure, type) {
+ return casper.evaluate(function (measure, type) {
+ return formatMeasureVariation(measure, type);
+ }, measure, type);
+ }
+
+ var HOURS_IN_DAY = 8,
+ ONE_MINUTE = 1,
+ ONE_HOUR = ONE_MINUTE * 60,
+ ONE_DAY = HOURS_IN_DAY * ONE_HOUR;
-casper.test.begin(testName(), function (test) {
casper
.start(lib.buildUrl('ui-global-messages'), function () {
lib.setDefaultViewport();
@@ -167,3 +213,48 @@ casper.test.begin(testName(), function (test) {
test.done();
});
});
+
+
+casper.test.begin(testName('Severity Comparators'), function (test) {
+
+ function severityComparator (severity) {
+ return casper.evaluate(function (severity) {
+ return window.severityComparator(severity);
+ }, severity);
+ }
+
+ function severityColumnsComparator (severity) {
+ return casper.evaluate(function (severity) {
+ return window.severityColumnsComparator(severity);
+ }, severity);
+ }
+
+ casper
+ .start(lib.buildUrl('ui-global-messages'), function () {
+ lib.setDefaultViewport();
+ })
+
+ .then(function () {
+ test.assertEqual(severityComparator('BLOCKER'), 0);
+ test.assertEqual(severityComparator('CRITICAL'), 1);
+ test.assertEqual(severityComparator('MAJOR'), 2);
+ test.assertEqual(severityComparator('MINOR'), 3);
+ test.assertEqual(severityComparator('INFO'), 4);
+ })
+
+ .then(function () {
+ test.assertEqual(severityColumnsComparator('BLOCKER'), 0);
+ test.assertEqual(severityColumnsComparator('CRITICAL'), 2);
+ test.assertEqual(severityColumnsComparator('MAJOR'), 4);
+ test.assertEqual(severityColumnsComparator('MINOR'), 1);
+ test.assertEqual(severityColumnsComparator('INFO'), 3);
+ })
+
+ .then(function () {
+ lib.sendCoverage();
+ })
+
+ .run(function () {
+ test.done();
+ });
+});