{"size": 2989, "ext": "js", "max_stars_repo_path": "test/spec/bundle/scale/zoomableSpec.js", "max_stars_repo_name": "clhubert/techan.js", "max_stars_repo_stars_event_min_datetime": "2021-08-06T17:23:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-06T17:23:27.000Z", "max_issues_repo_path": "test/spec/bundle/scale/zoomableSpec.js", "max_issues_repo_name": "dmitrykvochkin/techan.js", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/spec/bundle/scale/zoomableSpec.js", "max_forks_repo_name": "dmitrykvochkin/techan.js", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.5940594059, "max_line_length": 92, "alphanum_fraction": 0.5212445634}
techanModule('scale/zoomable', function(specBuilder) {
  'use strict';

  var techan = require('../../../../src/techan');

  var actualInit = function(module) {
    return module;
  };

  specBuilder.require(require('../../../../src/scale/zoomable'), function(instanceBuilder) {
    instanceBuilder.instance('actual', actualInit, function(scope) {
      var zoomable,
          linear;

      describe('And initialised with a scale and callback', function() {
        var zoomedCallback;

        beforeEach(function() {
          zoomedCallback = jasmine.createSpy('zoomedCallback');
          linear = d3.scale.linear().domain([0,10]);
          zoomable = scope.zoomable(linear, zoomedCallback);
        });

        it('Then throws an exception when reading the domain', function() {
          expect(zoomable.domain).toThrow();
        });

        it('Then throws an exception when writing the range', function() {
          expect(function() {
            zoomable.range([]);
          }).toThrow();
        });

        it('Then scale of first index should return scaled min range', function() {
          expect(linear(0)).toEqual(0);
        });

        it('Then scale of last index should return max range', function() {
          expect(linear(10)).toEqual(1);
        });

        it('Then the range should be default', function() {
          expect(linear.range()).toEqual([0, 1]);
        });

        describe('And copied', function() {
          var cloned;

          beforeEach(function() {
            cloned = zoomable.copy();
          });

          it('Then should not be equal to source', function() {
            expect(cloned).not.toEqual(zoomable);
          });
        });

        describe('And a zoom applied', function() {
          var zoom = null;

          beforeEach(function() {
            zoom = d3.behavior.zoom();
            zoom.x(zoomable);
          });

          describe('And translated to the left', function() {
            beforeEach(function() {
              zoom.translate([-11, 0]);
            });

            it('Then scale of first index should return scaled min range', function() {
              expect(linear(0)).toEqual(1.1);
            });

            it('Then scale of last index should return max range', function() {
              expect(linear(10)).toEqual(1);
            });

            it('Then the callback is invoked', function() {
              expect(zoomedCallback).toHaveBeenCalled();
            });
          });

          describe('And scaled by 2', function() {
            beforeEach(function() {
              zoom.scale(2).translate([-1,0]);
            });

            it('Then scale of first index should return min range', function() {
              expect(linear(0)).toEqual(-1);
            });

            it('Then scale of last index should return 2 max range', function() {
              expect(linear(10)).toEqual(1);
            });
          });
        });
      });
    });
  });
});