<commit_before>module("View - Graph");

test('basics', function () {
  var dataset = Fixture.getDataset();
  var view = new recline.View.Graph({
    model: dataset
  });
  $('.fixtures').append(view.el);
  equal(view.state.get('graphType'), 'lines-and-points');
  // view will auto render ...
  assertPresent('.editor', view.elSidebar);
  view.remove();
});

test('initialize', function () {
  var dataset = Fixture.getDataset();
  var view = new recline.View.Graph({
    model: dataset,
    state: {
      'graphType': 'lines',
      'group': 'x',
      'series': ['y', 'z']
    }
  });
  $('.fixtures').append(view.el);
  equal(view.state.get('graphType'), 'lines');
  deepEqual(view.state.get('series'), ['y', 'z']);

  // check we have updated editor with state info
  equal(view.elSidebar.find('.editor-type select').val(), 'lines');
  equal(view.elSidebar.find('.editor-group select').val(), 'x');
  var out = _.map(view.elSidebar.find('.editor-series select'), function($el) {
    return $($el).val();
  });
  deepEqual(out, ['y', 'z']);

  view.remove();
});

test('dates in graph view', function () {
  expect(0);
  var dataset = Fixture.getDataset();
  var view = new recline.View.Graph({
    model: dataset,
    state: {
      'graphType': 'lines',
      'group': 'date',
      'series': ['y', 'z']
    }
  });
  $('.fixtures').append(view.el);

  view.remove();
});

test('GraphControls basics', function () {
  var dataset = Fixture.getDataset();
  var view = new recline.View.GraphControls({
    model: dataset,
    state: {
      graphType: 'bars',
      series: [] 
    }
  });
  $('.fixtures').append(view.el);
  equal(view.state.get('graphType'), 'bars');
  // view will auto render ...
  assertPresent('.editor', view.el);
  view.remove();
});
<commit_msg>Added test case for 'graphOptions'<commit_after>module("View - Graph");

test('basics', function () {
  var dataset = Fixture.getDataset();
  var view = new recline.View.Graph({
    model: dataset
  });
  $('.fixtures').append(view.el);
  equal(view.state.get('graphType'), 'lines-and-points');
  // view will auto render ...
  assertPresent('.editor', view.elSidebar);
  view.remove();
});

test('initialize', function () {
  var dataset = Fixture.getDataset();
  var view = new recline.View.Graph({
    model: dataset,
    state: {
      'graphType': 'lines',
      'group': 'x',
      'series': ['y', 'z']
    }
  });
  $('.fixtures').append(view.el);
  equal(view.state.get('graphType'), 'lines');
  deepEqual(view.state.get('series'), ['y', 'z']);

  // check we have updated editor with state info
  equal(view.elSidebar.find('.editor-type select').val(), 'lines');
  equal(view.elSidebar.find('.editor-group select').val(), 'x');
  var out = _.map(view.elSidebar.find('.editor-series select'), function($el) {
    return $($el).val();
  });
  deepEqual(out, ['y', 'z']);

  view.remove();
});

test('dates in graph view', function () {
  expect(0);
  var dataset = Fixture.getDataset();
  var view = new recline.View.Graph({
    model: dataset,
    state: {
      'graphType': 'lines',
      'group': 'date',
      'series': ['y', 'z']
    }
  });
  $('.fixtures').append(view.el);

  view.remove();
});

test('GraphControls basics', function () {
  var dataset = Fixture.getDataset();
  var view = new recline.View.GraphControls({
    model: dataset,
    state: {
      graphType: 'bars',
      series: [] 
    }
  });
  $('.fixtures').append(view.el);
  equal(view.state.get('graphType'), 'bars');
  // view will auto render ...
  assertPresent('.editor', view.el);
  view.remove();
});

test('Overriding graph options', function () {
  var dataset = Fixture.getDataset();
  var randomWidth = Math.random();
  var view = new recline.View.Graph({
    model: dataset,
    state: {
      'graphType': 'bars',
      'group': 'date',
      'series': ['y', 'z'],
      'graphOptions': { bars: {barWidth: randomWidth}}
    }
  });
  equal(view.getGraphOptions('bars').bars.barWidth, randomWidth)
  view.remove();
});
{'fraction_non_alphanumeric': 0.21362384172301527, 'fraction_numerical': 0.0005008765339343851, 'mean_word_length': 3.379385964912281, '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': '6504552', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1329, 'n_words': 283}