<commit_before>import chai, { expect } from 'chai';
import dirtyChai from 'dirty-chai';

import * as Node from '../src/node';
import * as CONST from '../src/constants';

import * as Helper from './helpers';

chai.use(dirtyChai);

describe('Node', () => {
  const checkNodeObject = (node) => {
    expect(node).to.be.an('object');
    expect(node).have.property('id');
    expect(node).to.have.property('position');
    expect(node).to.have.property('type');
  };

  // constructors
  describe('createNode', () => {
    it('should return Either.Right with node', () => {
      const newNode = Node.createNode({ x: 100, y: 100 }, '@/test');
      Helper.expectEither(
        checkNodeObject,
        newNode
      );
    });
  });
  describe('duplicateNode', () => {
    const node = {
      id: 'test',
      position: { x: 0, y: 0 },
      type: '@/test',
    };
    const newNode = Node.duplicateNode(node);

    it('should return the node object', () => {
      checkNodeObject(newNode);
    });
    it('should return node object with same properties but new id', () => {
      expect(newNode.id).not.equals(node.id);
      expect(newNode.position).deep.equal(node.position);
      expect(newNode.type).deep.equal(node.type);
    });
    it('should return not the same object', () => {
      expect(newNode).not.equals(node);
    });
  });
  // properties
  describe('getNodeId', () => {
    it('should return id string for Node object', () => {
      expect(Node.getNodeId({ id: '@/test' }))
        .to.be.equal('@/test');
    });
    it('should return id string for string', () => {
      expect(Node.getNodeId('@/test'))
        .to.be.equal('@/test');
    });
  });
  describe('getNodeType', () => {
    it('should return type', () => {
      expect(Node.getNodeType({ type: '@/test' }))<commit_msg>test(xod-project): add one more test for node.js<commit_after>import chai, { expect } from 'chai';
import dirtyChai from 'dirty-chai';

import * as Node from '../src/node';
import * as CONST from '../src/constants';

import * as Helper from './helpers';

chai.use(dirtyChai);

describe('Node', () => {
  const checkNodeObject = (node) => {
    expect(node).to.be.an('object');
    expect(node).have.property('id');
    expect(node).to.have.property('position');
    expect(node).to.have.property('type');
  };

  // constructors
  describe('createNode', () => {
    it('should return Either.Right with node', () => {
      const newNode = Node.createNode({ x: 100, y: 100 }, '@/test');
      Helper.expectEither(
        checkNodeObject,
        newNode
      );
    });
  });
  describe('duplicateNode', () => {
    const node = {
      id: 'test',
      position: { x: 0, y: 0 },
      type: '@/test',
    };
    const newNode = Node.duplicateNode(node);

    it('should return the node object', () => {
      checkNodeObject(newNode);
    });
    it('should return node object with same properties but new id', () => {
      expect(newNode.id).not.equals(node.id);
      expect(newNode.position).deep.equal(node.position);
      expect(newNode.type).deep.equal(node.type);
    });
    it('should return copy of node always with new id', () => {
      const newNode1 = Node.duplicateNode(node);
      const newNode2 = Node.duplicateNode(node);
      const newNode3 = Node.duplicateNode(node);
      const newNode4 = Node.duplicateNode(node);

      expect(newNode1.id).not.equals(newNode2.id);
      expect(newNode2.id).not.equals(newNode3.id);
      expect(newNode3.id).not.equals(newNode4.id);
    });
    it('should return not the same object', () => {
      expect(newNode).not.equals(node);
    });
  });
  // properties
  describe('getNodeId', () => {
    it('should return id string for Node object', () => {
      expect(Node.getNodeId({ id: '@/test' }))
        .to.be.equal('@/test');
    });
    it('should return id string for string', () => {
      expect(Node.getNodeId('@/test'))
        .to.be.equal('@/test');
    });
  });
  describe('getNodeType', () => {
    it('should return type', () => {
      expect(Node.getNodeType({ type: '@/test' }))
{'fraction_non_alphanumeric': 0.19356423483173668, 'fraction_numerical': 0.006386637189879637, 'mean_word_length': 2.8780952380952383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, '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': '4369297', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1314, 'n_words': 270}