<commit_before>import React from "react";
import { shallow } from "enzyme";
import Candle from "src/victory-primitives/candle";
import { merge } from "lodash";

describe("victory-primitives/candle", () => {
  const baseProps = {
    data: [
      { x: 1, open: 10, close: 30, high: 50, low: 5, eventKey: 0 },
      { x: 2, open: 40, close: 80, high: 100, low: 10, eventKey: 1 }
    ],
    datum: { x: 1, open: 10, close: 30, high: 50, low: 5, eventKey: 0 },
    x: 5,
    high: 50,
    low: 5,
    candleHeight: 20,
    width: 10,
    padding: 1
  };

  it("should render a wick line", () => {
    const wrapper = shallow(<Candle {...baseProps}/>);
    const wicks = wrapper.find("line");

    wicks.forEach((wick) => {
      expect(wick.prop("x1")).to.eql(5);
      expect(wick.prop("x2")).to.eql(5);
      // expect(wick.prop("y1")).to.eql(50 || 5);
      // expect(wick.prop("y2")).to.eql(50 || 5);
    });
  });

  it("should render a candle rectangle", () => {
    const wrapper = shallow(<Candle {...baseProps}/>);
    const rect = wrapper.find("rect");

    // width = style.width || 0.5 * (width - 2 * padding) / data.length;

    expect(rect.prop("width")).to.eql(2);
    expect(rect.prop("height")).to.eql(20);
    // x = x - width / 2
    expect(rect.prop("x")).to.eql(4);
    expect(rect.prop("close")).to.eql(10);
    // expect(rect.prop("open")).to.eql(10);
    // expect(rect.prop("y")).to.eql(10);
  });

  it("should allow style to override width", () => {
    const props = merge({}, baseProps, {
      style: {
        width: 5
      }
    });

    const wrapper = shallow(<Candle {...props}/>);
    const rect = wrapper.find("rect");

    expect(rect.prop("width")).to.eql(5);
    expect(rect.prop("height")).to.eql(20);
    // x = x - width / 2
    expect(rect.prop("x")).to.eql(2.5);
  });
});<commit_msg>successfully testing new `renderWick` method<commit_after>import React from "react";
import { shallow } from "enzyme";
import Candle from "src/victory-primitives/candle";
import { merge } from "lodash";

describe("victory-primitives/candle", () => {
  const baseProps = {
    data: [
      { x: 1, open: 10, close: 30, high: 50, low: 5, eventKey: 0 },
      { x: 2, open: 40, close: 80, high: 100, low: 10, eventKey: 1 }
    ],
    datum: { x: 1, open: 10, close: 30, high: 50, low: 5, eventKey: 0 },
    x: 5,
    high: 50,
    low: 5,
    close: 30,
    open: 10,
    candleHeight: 20,
    width: 10,
    padding: 1
  };

  it("should render a wick line", () => {
    const wrapper = shallow(<Candle {...baseProps}/>);
    const wicks = wrapper.find("line");
    const values = [
      {
        x1: 5,
        x2: 5,
        y1: 30,
        y2: 5
      }, {
        x1: 5,
        x2: 5,
        y1: 10,
        y2: 50
      }];

    wicks.forEach((wick, i) => {
      expect(wick.prop("x1")).to.eql(values[i].x1);
      expect(wick.prop("x2")).to.eql(values[i].x2);
      expect(wick.prop("y1")).to.eql(values[i].y1);
      expect(wick.prop("y2")).to.eql(values[i].y2);
    });
  });

  it("should render a candle rectangle", () => {
    const wrapper = shallow(<Candle {...baseProps}/>);
    const rect = wrapper.find("rect");

    // width = style.width || 0.5 * (width - 2 * padding) / data.length;

    expect(rect.prop("width")).to.eql(2);
    expect(rect.prop("height")).to.eql(20);
    // x = x - width / 2
    expect(rect.prop("x")).to.eql(4);
    expect(rect.prop("y")).to.eql(10);
  });

  it("should allow style to override width", () => {
    const props = merge({}, baseProps, {
      style: {
        width: 5
      }
    });

    const wrapper = shallow(<Candle {...props}/>);
    const rect = wrapper.find("rect");

    expect(rect.prop("width")).to.eql(5);
    expect(rect.prop("height")).to.eql(20);
    // x = x - width / 2
    expect(rect.prop("x")).to.eql(2.5);
    expect(rect.prop("y")).to.eql(10);
  });
});
{'fraction_non_alphanumeric': 0.21595028482651477, 'fraction_numerical': 0.041170378042465046, 'mean_word_length': 2.4990942028985508, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, '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': '973422', 'n_tokens_mistral': 1599, 'n_tokens_neox': 1446, 'n_words': 312}