<commit_before>import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('c3-chart', 'Integration | Component | c3 chart', {
  integration: true
});

test('it renders', function(assert) {
  // Set any properties with this.set('myProperty', 'value');
  // Handle any actions with this.on('myAction', function(val) { ... });

  this.render(hbs`{{c3-chart}}`);

  assert.equal(this.$().text().trim(), '');

});


test('it renders a SVG barcode', function (assert) {
  assert.expect(1);
 
  this.render(hbs`{{c3-chart data=data axis=axis}}`);

  // will display - text value is set
  this.render(hbs`{{bar-code value=code}}`);
  assert.equal(this.$('svg').attr('style'), 'transform: translate(0,0)');

});<commit_msg>added tests for basic chart types<commit_after>import { moduleForComponent, test } from "ember-qunit";
import hbs from "htmlbars-inline-precompile";

moduleForComponent("c3-chart", "Integration | Component | c3 chart", {
  integration: true
});

test("it renders a pie chart", function(assert) {
  this.set("data", {
    columns: [["data1", 30], ["data2", 120]],
    type: "pie"
  });

  // const done = assert.async();

  this.render(hbs`{{c3-chart data=this.data}}`);

  // pauses for 20 seconds
  // setTimeout(() => done(), 60000);

  assert.ok(this.$("svg"));

  assert.ok(this.$("g").hasClass("c3-legend-item"), "Pie charte has lengend");
  assert.equal(this.$(".c3-legend-item").length, 2, "Has 2 legend items");
  assert.equal(this.$("svg g").length, 72, "svg g elements");
});

test("it renders a donut chart", function(assert) {
  this.set("data", {
    columns: [["data1", 30], ["data2", 120], ["data3", 95]],
    type: "donut"
  });

  this.set("donut", { title: "<NAME>" });

  // const done = assert.async();

  this.render(hbs`{{c3-chart data=data donut=donut}}`);

  // // pauses for 60 seconds
  // setTimeout(() => done(), 60000);

  assert.ok(this.$("svg"));

  assert.ok(this.$("text").hasClass("c3-chart-arcs-title"), "Has title text");
  assert.equal(
    this.$(".c3-chart-arcs-title").text(),
    "Iris Petal Width",
    "Text matches title"
  );
  assert.equal(this.$(".c3-legend-item").length, 3, "Has 3 legend items");
  assert.equal(this.$("svg g").length, 84, "svg g elements");
});

test("it renders a gauge chart", function(assert) {
  this.set("data", {
    columns: [["data", 91.4]],
    type: "gauge",
    title: {
      text: "Percent Complete"
    }
  });

  this.set("title", {
    text: "Percent Complete"
  });

  // const done = assert.async();

  this.render(
    hbs`{{c3-chart data=data title=title gauge=gauge color=color size=size}}`
  );

  // pauses for 60 seconds
  // setTimeout(() => done(), 60000);

  assert.ok(this.$("svg"));

  assert.ok(this.$("text").hasClass("c3-title"), "Has title text");
  assert.equal(
    this.$(".c3-title").text(),
    "Percent Complete",
    "Text matches title"
  );
  assert.equal(this.$(".c3-legend-item").length, 1, "Has 1 legend items");
  assert.equal(this.$("svg g").length, 62, "svg g elements");
});

test("it renders a timeseries chart", function(assert) {
  this.set("data", {
    x: "x",
    // xFormat: '%Y%m%d', // 'xFormat' can be used as custom format of 'x'
    columns: [
      [
        "x",
        "2013-01-01",
        "2013-01-02",
        "2013-01-03",
        "2013-01-04",
        "2013-01-05",
        "2013-01-06"
      ],
      // ['x', '20130101', '20130102', '20130103', '20130104', '20130105', '20130106'],
      ["data1", 30, 200, 100, 400, 150, 250],
      ["data2", 130, 340, 200, 500, 250, 350]
    ]
  });

  this.set("axis", {
    x: {
      type: "timeseries",
      tick: {
        format: "%Y-%m-%d"
      }
    }
  }),
    this.set("title", {
      text: "Internet Speeds"
    });

  // const done = assert.async();

  this.render(
    hbs`{{c3-chart data=data title=title gauge=gauge color=color size=size}}`
  );

  // pauses for 60 seconds
  // setTimeout(() => done(), 60000);

  assert.ok(this.$("svg"));

  assert.ok(this.$("text").hasClass("c3-title"), "Has title text");
  assert.equal(
    this.$(".c3-title").text(),
    "Internet Speeds",
    "Text matches title"
  );
  assert.equal(this.$(".c3-legend-item").length, 2, "Has 2 legend items");
  assert.equal(this.$("svg g").length, 69, "svg g elements");
});

test("it renders a bar chart", function(assert) {
  this.set("data", {
    columns: [
      ["data1", 30, 200, 100, 400, 150, 250],
      ["data2", 130, 100, 140, 200, 150, 50]
    ],
    type: "bar"
  });

  this.set("bar", {
    width: {
      ratio: 0.5
    }
  });

  this.set("title", {
    text: "Regional Sales"
  });

  // const done = assert.async();

  this.render(
    hbs`{{c3-chart data=data title=title gauge=gauge color=color size=size}}`
  );

  // pauses for 60 seconds
  // setTimeout(() => done(), 60000);

  assert.ok(this.$("svg"));

  assert.ok(this.$("text").hasClass("c3-title"), "Has title text");
  assert.equal(
    this.$(".c3-title").text(),
    "Regional Sales",
    "Text matches title"
  );
  assert.equal(this.$(".c3-legend-item").length, 2, "Has 2 legend items");
  assert.equal(this.$("svg g").length, 77, "svg g elements");
});
{'fraction_non_alphanumeric': 0.22136521403779405, 'fraction_numerical': 0.052834554569996146, 'mean_word_length': 3.2, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 9, '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': '361858', 'n_tokens_mistral': 2062, 'n_tokens_neox': 1819, 'n_words': 412}