<commit_before>'use strict';

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

var time = require('../../src/compiler/time'),
  Encoding = require('../../src/Encoding');

describe('time', function() {
  var fieldName = 'a',
    timeUnit = 'month',
    encoding = Encoding.fromSpec({
      encoding: {
        x: {name: fieldName, type: 'T', timeUnit: timeUnit}
      }
    }),
    spec = time({data: [{name: RAW}, {name: TABLE}]}, encoding, {});

  it('should add formula transform', function() {
    var data = spec.data[0];
    expect(data.transform).to.be.ok;

    expect(data.transform.filter(function(t) {
      return t.type === 'formula' && t.field === encoding.fieldRef('x') &&
        t.expr === time.formula(encoding._enc.x);
    }).length).to.be.above(0);
  });

  it('should add custom axis scale', function() {
    expect(spec.scales.filter(function(scale) {
      return scale.name == 'time-'+ timeUnit;
    }).length).to.equal(1);
  });

  describe('maxLength', function(){
    it('should return max length based on time format', function () {
      expect(time.maxLength(undefined /*no timeUnit*/, {
          config: function(){ return '%A %B %e %H:%M:%S %Y';}
        }))
        .to.eql('Wednesday September 17 04:00:00 2014'.length);
    });

    it('should return max length of the month custom scale', function () {
      expect(time.maxLength('month', Encoding.fromSpec({mark: 'point'})))
        .to.eql(3);
    });

    it('should return max length of the day custom scale', function () {
      expect(time.maxLength('day', Encoding.fromSpec({mark: 'point'})))
        .to.eql(3);
    });

    it.only('should return max length of the month custom scale', function () {
      expect(time.maxLength('month', Encoding.fromSpec({
        mark: 'point',
        config: {
          timeScaleLabelLength: 0
        }
      }))).to.eql(9);
    });
  });
});<commit_msg>remove "only" from test case<commit_after>'use strict';

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

var time = require('../../src/compiler/time'),
  Encoding = require('../../src/Encoding');

describe('time', function() {
  var fieldName = 'a',
    timeUnit = 'month',
    encoding = Encoding.fromSpec({
      encoding: {
        x: {name: fieldName, type: 'T', timeUnit: timeUnit}
      }
    }),
    spec = time({data: [{name: RAW}, {name: TABLE}]}, encoding, {});

  it('should add formula transform', function() {
    var data = spec.data[0];
    expect(data.transform).to.be.ok;

    expect(data.transform.filter(function(t) {
      return t.type === 'formula' && t.field === encoding.fieldRef('x') &&
        t.expr === time.formula(encoding._enc.x);
    }).length).to.be.above(0);
  });

  it('should add custom axis scale', function() {
    expect(spec.scales.filter(function(scale) {
      return scale.name == 'time-'+ timeUnit;
    }).length).to.equal(1);
  });

  describe('maxLength', function(){
    it('should return max length based on time format', function () {
      expect(time.maxLength(undefined /*no timeUnit*/, {
          config: function(){ return '%A %B %e %H:%M:%S %Y';}
        }))
        .to.eql('Wednesday September 17 04:00:00 2014'.length);
    });

    it('should return max length of the month custom scale', function () {
      expect(time.maxLength('month', Encoding.fromSpec({mark: 'point'})))
        .to.eql(3);
    });

    it('should return max length of the day custom scale', function () {
      expect(time.maxLength('day', Encoding.fromSpec({mark: 'point'})))
        .to.eql(3);
    });

    it('should return max length of the month custom scale', function () {
      expect(time.maxLength('month', Encoding.fromSpec({
        mark: 'point',
        config: {
          timeScaleLabelLength: 0
        }
      }))).to.eql(9);
    });
  });
});
{'fraction_non_alphanumeric': 0.19048884165781083, 'fraction_numerical': 0.010095642933049946, 'mean_word_length': 2.873456790123457, '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': '2103652', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1158, 'n_words': 278}