summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/page/logout.spec.js
blob: 7e384cad764c2b66a80df4edb25b64b0085b557d (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
describeComponent('page/logout', function () {
  'use strict';

  describe('logout link', function () {
    var features;

    beforeEach(function() {
      features = require('features');
    });

    it('should provide logout link if logout is enabled', function () {
      spyOn(features, 'isLogoutEnabled').and.returnValue(true);

      this.setupComponent('<nav id="logout"></nav>', {});

      var logout_link = this.component.$node.find('a')[0];
      expect(logout_link).toExist();
      expect(logout_link.href).toMatch('test/logout/url');
    });

    it('should not provide logout link if disabled', function() {
      spyOn(features, 'isLogoutEnabled').and.returnValue(false);

      this.setupComponent('<nav id="logout"></nav>', {});

      var logout_link = this.component.$node.find('a')[0];
      expect(logout_link).not.toExist();
    });

    it('should render logout in collapsed nav bar if logout is enabled', function() {
      spyOn(features, 'isLogoutEnabled').and.returnValue(true);

      this.setupComponent('<ul id="logout-shortcuts" class="shortcuts"></ul>', {});

      var logout_icon = this.component.$node.find('a')[0];
      expect(logout_icon).toExist();
      expect(logout_icon.innerHTML).toContain('<div class="fa fa-sign-out"></div>');
    });
  });
});