Sha256: 685e7a02f6c3e4ee3418032e869efbcf96bc0c11a03f0c18076660997248f2af

Contents?: true

Size: 1.68 KB

Versions: 7

Compression:

Stored size: 1.68 KB

Contents

describe('pageflow.sitemap.SelectioNavigator', function() {
  var s = pageflow.sitemap;

  describe('on select:chapters', function() {
    it('navigates to chapter if only one is selected', function() {
      var api = {navigate: sinon.spy()};
      var selection = new s.Selection();
      var selectionNavigator = new s.SelectionNavigator({
        api: api,
        selection: selection
      });
      var chapter = new Backbone.Model({id: 6});

      selectionNavigator.attach();
      selection.select('chapters', [chapter]);

      expect(api.navigate).to.have.been.calledWith('/chapters/6', {trigger: true});
    });

    it('navigates to multiSelectionPath if more than one is selected', function() {
      var api = {navigate: sinon.spy()};
      var selection = new s.Selection();
      var selectionNavigator = new s.SelectionNavigator({
        api: api,
        selection: selection,
        multiSelectionPath: '/multi'
      });
      var chapter0 = new Backbone.Model({id: 6});
      var chapter1 = new Backbone.Model({id: 7});

      selectionNavigator.attach();
      selection.select('chapters', [chapter0, chapter1]);

      expect(api.navigate).to.have.been.calledWith('/multi', {trigger: true});
    });

    it('navigates to emptySelectionPath if more than one is selected', function() {
      var api = {navigate: sinon.spy()};
      var selection = new s.Selection();
      var selectionNavigator = new s.SelectionNavigator({
        api: api,
        selection: selection,
        emptySelectionPath: '/none'
      });

      selectionNavigator.attach();
      selection.select('chapters', []);

      expect(api.navigate).to.have.been.calledWith('/none', {trigger: true});
    });
  });
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pageflow-sitemap-1.5.0 spec/javascripts/pageflow/sitemap/editor/controllers/selection_navigator_spec.js
pageflow-sitemap-1.4.0 spec/javascripts/pageflow/sitemap/editor/controllers/selection_navigator_spec.js
pageflow-sitemap-1.3.0 spec/javascripts/pageflow/sitemap/editor/controllers/selection_navigator_spec.js
pageflow-sitemap-1.2.0 spec/javascripts/pageflow/sitemap/editor/controllers/selection_navigator_spec.js
pageflow-sitemap-1.1.0 spec/javascripts/pageflow/sitemap/editor/controllers/selection_navigator_spec.js
pageflow-sitemap-1.0.0 spec/javascripts/pageflow/sitemap/editor/controllers/selection_navigator_spec.js
pageflow-sitemap-0.1.0 spec/javascripts/pageflow/sitemap/editor/controllers/selection_navigator_spec.js