<commit_before>'use strict';

var d3 = require('d3');
var expect = require('chai').expect;

var util = require('../../src/util'),
  Encoding = require('../../src/Encoding'),
  vlscale = require('../../src/compiler/scale'),
  colorbrewer = require('colorbrewer');

describe('vl.compile.scale', function() {
  describe('domain()', function() {
    var linearScaleDef = {
      name: 'y',
      type: 'linear'
    };

    var ordinalScaleDef = {
      name: 'y',
      type: 'ordinal'
    };
    var timeScaleDef = {
      name: 'y',
      type: 'time'
    };

    describe('for stack', function() {
      it('should return correct stack', function() {
        var domain = vlscale.domain(linearScaleDef, Encoding.fromSpec({
          encoding: {
            y: {
              name: 'origin'
            }
          }
        }), {}, {
          stack: 'y',
          facet: true
        });

        expect(domain).to.eql({
          data: 'stacked',
          field: 'max_sum_origin'
        });
      });

      it('should return correct aggregated stack', function() {
        var domain = vlscale.domain(linearScaleDef, Encoding.fromSpec({
          encoding: {
            y: {
              aggregate: 'sum',
              name: 'origin'
            }
          }
        }), {}, {
          stack: 'y',
          facet: true
        });

        expect(domain).to.eql({
          data: 'stacked',
          field: 'max_sum_sum_origin'
        });
      });
    });

    describe('for quantitative', function() {
      it('should return the right domain if binned Q',
        function() {
          var domain = vlscale.domain(ordinalScaleDef, Encoding.fromSpec({
            encoding: {
              y: {
                bin: {maxbins: 15},
                name: 'origin',
                scale: {useRawDomain: true},
                type: Q
              }
            }
          }), {origin: {min: -5, max:48}}, {});<commit_msg>@domoritz – fix tests<commit_after>'use strict';

var d3 = require('d3');
var expect = require('chai').expect;

var util = require('../../src/util'),
  Encoding = require('../../src/Encoding'),
  vlscale = require('../../src/compiler/scale'),
  colorbrewer = require('colorbrewer');

describe('vl.compile.scale', function() {
  describe('domain()', function() {
    var linearScaleDef = {
      name: 'y',
      type: 'linear'
    };

    var ordinalScaleDef = {
      name: 'y',
      type: 'ordinal'
    };
    var timeScaleDef = {
      name: 'y',
      type: 'time'
    };

    describe('for stack', function() {
      it('should return correct stack', function() {
        var domain = vlscale.domain(linearScaleDef, Encoding.fromSpec({
          marktype: 'bar',
          encoding: {
            y: {
              aggregate: 'sum',
              name: 'origin'
            },
            x: {name: 'x', type: 'O'},
            color: {name: 'color', type: 'O'}
          }
        }), {}, true);

        expect(domain).to.eql({
          data: 'stacked',
          field: 'max_sum_sum_origin'
        });
      });

      it('should return correct aggregated stack', function() {
        var domain = vlscale.domain(linearScaleDef, Encoding.fromSpec({
          marktype: 'bar',
          encoding: {
            y: {
              aggregate: 'sum',
              name: 'origin'
            },
            x: {name: 'x', type: 'O'},
            color: {name: 'color', type: 'O'}
          }
        }), {}, true);

        expect(domain).to.eql({
          data: 'stacked',
          field: 'max_sum_sum_origin'
        });
      });
    });

    describe('for quantitative', function() {
      it('should return the right domain if binned Q',
        function() {
          var domain = vlscale.domain(ordinalScaleDef, Encoding.fromSpec({
            encoding: {
              y: {
                bin: {maxbins: 15},
                name: 'origin',
                scale: {useRawDomain: true},
                type: Q
              }
            }
          }), {origin: {min: -5, max:48}}, {});
{'fraction_non_alphanumeric': 0.16073194856577647, 'fraction_numerical': 0.0034619188921859545, 'mean_word_length': 1.5797193877551021, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7458486', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1160, 'n_words': 265}