<commit_before>import { getCoordinate } from '../../../../src/dependents';
import Element from '../../../../src/geometry/element/index';
import SchemaShapeFactory from '../../../../src/geometry/shape/schema';
import Theme from '../../../../src/theme/antv';
import { createCanvas, createDiv, removeDom } from '../../../util/dom';

const Rect = getCoordinate('rect');

describe('Schema shapes', () => {
  const div = createDiv();
  const canvas = createCanvas({
    container: div,
    width: 500,
    height: 500,
  });
  const rectCoord = new Rect({
    start: { x: 0, y: 500 },
    end: { x: 500, y: 0 },
  });
  SchemaShapeFactory.coordinate = rectCoord;
  SchemaShapeFactory.theme = Theme.geometries.schema;

  const element = new Element({
    shapeFactory: SchemaShapeFactory,
    container: canvas.addGroup(),
    theme: Theme.geometries.schema,
  });

  it('defaultShapeType', () => {
    expect(SchemaShapeFactory.defaultShapeType).toBe('');
  });

  describe('box', () => {
    it('only x, getShapePoints && drawShape & updateShape', () => {
      const type = 'box';
      const points = SchemaShapeFactory.getShapePoints(type, {
        x: 0.88,
        y0: 0,
        size: 0.5,
      });
      expect(points.length).toBe(14);
      expect(points[0].y).toBe(0.25);
      expect(points[1].y).toBe(0.75);
      expect(points[2].y).toBe(0.5);
      expect(points[3].y).toBe(0.5);

      const shape = SchemaShapeFactory.drawShape(
        type,
        {
          x: 100,
          y: 100,
          points,
          color: 'red',
          defaultStyle: {
            ...Theme.geometries.schema.box.default,
          },
        },<commit_msg>test: schema box shape 添加 y 为 null 的测试用例<commit_after>import { getCoordinate } from '../../../../src/dependents';
import Element from '../../../../src/geometry/element/index';
import SchemaShapeFactory from '../../../../src/geometry/shape/schema';
import Theme from '../../../../src/theme/antv';
import { createCanvas, createDiv, removeDom } from '../../../util/dom';

const Rect = getCoordinate('rect');

describe('Schema shapes', () => {
  const div = createDiv();
  const canvas = createCanvas({
    container: div,
    width: 500,
    height: 500,
  });
  const rectCoord = new Rect({
    start: { x: 0, y: 500 },
    end: { x: 500, y: 0 },
  });
  SchemaShapeFactory.coordinate = rectCoord;
  SchemaShapeFactory.theme = Theme.geometries.schema;

  const element = new Element({
    shapeFactory: SchemaShapeFactory,
    container: canvas.addGroup(),
    theme: Theme.geometries.schema,
  });

  it('defaultShapeType', () => {
    expect(SchemaShapeFactory.defaultShapeType).toBe('');
  });

  describe('box', () => {
    it('only x, getShapePoints && drawShape & updateShape', () => {
      const type = 'box';
      const points1 = SchemaShapeFactory.getShapePoints(type, {
        x: 0.88,
        y0: 0,
        size: 0.5,
      });
      expect(points1.length).toBe(14);
      expect(points1[0].y).toBe(0.25);
      expect(points1[1].y).toBe(0.75);
      expect(points1[2].y).toBe(0.5);
      expect(points1[3].y).toBe(0.5);

      const points = SchemaShapeFactory.getShapePoints(type, {
        x: 0.88,
        y: null,
        size: 0.5,
      });
      expect(points.length).toBe(14);
      expect(points[0].y).toBe(0.25);
      expect(points[1].y).toBe(0.75);
      expect(points[2].y).toBe(0.5);
      expect(points[3].y).toBe(0.5);

      const shape = SchemaShapeFactory.drawShape(
        type,
        {
          x: 100,
          y: 100,
          points,
          color: 'red',
          defaultStyle: {
            ...Theme.geometries.schema.box.default,
          },
        },
{'fraction_non_alphanumeric': 0.18425369054127938, 'fraction_numerical': 0.03089119737561509, 'mean_word_length': 2.350732600732601, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6633781', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1155, 'n_words': 232}