aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/tests/application-test.js
blob: 14146be362f088201d239fcfc1f4b281098204e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
describe.skip('Application', function () {
  describe('#collapsedDirFromPath()', function () {
    it('should return null when pass null', function () {
      assert.isNull(window.collapsedDirFromPath(null));
    });

    it('should return "/" when pass "/"', function () {
      assert.equal(window.collapsedDirFromPath('/'), '/');
    });

    it('should not cut short path', function () {
      assert.equal(window.collapsedDirFromPath('src/main/js/components/state.js'), 'src/main/js/components/');
    });

    it('should cut long path', function () {
      assert.equal(window.collapsedDirFromPath('src/main/js/components/navigator/app/models/state.js'),
          'src/.../js/components/navigator/app/models/');
    });

    it('should cut very long path', function () {
      assert.equal(window.collapsedDirFromPath('src/main/another/js/components/navigator/app/models/state.js'),
          'src/.../js/components/navigator/app/models/');
    });
  });

  describe('#fileFromPath()', function () {
    it('should return null when pass null', function () {
      assert.isNull(window.fileFromPath(null));
    });

    it('should return empty string when pass "/"', function () {
      assert.equal(window.fileFromPath('/'), '');
    });

    it('should return file name when pass only file name', function () {
      assert.equal(window.fileFromPath('file.js'), 'file.js');
    });

    it('should return file name when pass file path', function () {
      assert.equal(window.fileFromPath('src/main/js/file.js'), 'file.js');
    });

    it('should return file name when pass file name without extension', function () {
      assert.equal(window.fileFromPath('src/main/file'), 'file');
    });
  });

  describe('Severity Comparators', function () {
    describe('#severityComparator', function () {
      it('should have correct order', function () {
        assert.equal(window.severityComparator('BLOCKER'), 0);
        assert.equal(window.severityComparator('CRITICAL'), 1);
        assert.equal(window.severityComparator('MAJOR'), 2);
        assert.equal(window.severityComparator('MINOR'), 3);
        assert.equal(window.severityComparator('INFO'), 4);
      });
    });

    describe('#severityColumnsComparator', function () {
      it('should have correct order', function () {
        assert.equal(window.severityColumnsComparator('BLOCKER'), 0);
        assert.equal(window.severityColumnsComparator('CRITICAL'), 2);
        assert.equal(window.severityColumnsComparator('MAJOR'), 4);
        assert.equal(window.severityColumnsComparator('MINOR'), 1);
        assert.equal(window.severityColumnsComparator('INFO'), 3);
      });
    });
  });
});