Add summary and activity screens, remove private datasets from counts
[ckanext-dga-stats.git] / ckanext / dga_stats / public / ckanext / stats / test / spec / modules / stats-nav.spec.js
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
/*globals describe before beforeEach afterEach it assert sinon ckan jQuery */
describe('ckan.module.StatsNavModule()', function () {
  var StatsNavModule = ckan.module.registry['stats-nav'];
 
  beforeEach(function () {
    this.el = document.createElement('div');
    this.sandbox = ckan.sandbox();
    this.sandbox.body = this.fixture;
    this.sandbox.location = {
      href: '',
      hash: ''
    };
    this.module = new StatsNavModule(this.el, {}, this.sandbox);
 
    jQuery.fn.tab = sinon.stub();
  });
 
  afterEach(function () {
    this.module.teardown();
 
    delete jQuery.fn.tab;
  });
 
  describe('.initialize()', function () {
    it('should listen for shown events and update the location.hash', function () {
      var anchor = jQuery('<a />').attr('href', '#stats-test')[0];
 
      this.module.initialize();
      this.module.el.trigger({type: 'shown', target: anchor});
 
      assert.equal(this.sandbox.location.hash, 'test');
    });
 
    it('should select the tab from the location hash on init', function () {
      var anchor = jQuery('<a />').attr('href', '#stats-test').appendTo(this.el);
 
      this.sandbox.location.hash = '#test';
      this.module.initialize();
 
      assert.called(jQuery.fn.tab);
      assert.calledWith(jQuery.fn.tab, 'show');
    });
  });
});