{"size": 1397, "ext": "js", "max_stars_repo_path": "packages/aice/__tests__/streamTransformers/ner.test.js", "max_stars_repo_name": "Opla/aice.js", "max_stars_repo_stars_event_min_datetime": "2019-08-01T07:45:09.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-02T10:52:13.000Z", "max_issues_repo_path": "packages/aice/__tests__/streamTransformers/ner.test.js", "max_issues_repo_name": "Opla/aice.js", "max_issues_repo_issues_event_min_datetime": "2019-08-01T07:44:54.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-01T19:43:35.000Z", "max_forks_repo_path": "packages/aice/__tests__/streamTransformers/ner.test.js", "max_forks_repo_name": "Opla/aice.js", "max_forks_repo_forks_event_min_datetime": "2019-09-25T13:28:06.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-19T14:34:13.000Z"}
{"max_stars_count": 2, "max_issues_count": 101, "max_forks_count": 2, "avg_line_length": 34.0731707317, "max_line_length": 97, "alphanum_fraction": 0.6478167502}
/**
 * Copyright (c) 2015-present, CWB SAS
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
import chai from 'chai';
import { NamedEntity, EnumEntity, RegExpEntity } from '../../src/streamTransformers';

const { expect } = chai;

describe('Named/EnumEntity', () => {
  it('EnumEntity should throw err if no enumeration is passed', () => {
    expect(() => new EnumEntity({})).to.throw('Invalid Entity constructor - Missing enum');
  });

  it('RegExpEntity should throw err if no regex provided', () => {
    expect(() => new RegExpEntity({})).to.throw('Invalid Entity constructor - Missing regex');
  });

  it('NamedEntity should throw err if no name provided', () => {
    expect(() => new NamedEntity({})).to.throw('Invalid Entity constructor - name are required');
  });

  it('NamedEntity should add parameters ', () => {
    const ne = new NamedEntity({ name: 'testentity' });
    const param = { var1: 'value1' };
    ne.addParameter(param);

    expect(ne.getParameter('var1')).to.equal(param.var1);
    ne.addParameter(param);
    expect(ne.parameters.length).to.equal(1);
  });

  it('should not call extract on NamedEntity', () => {
    expect(() => new NamedEntity({ name: 'test' }).extract()).to.throw(
      'Invalid NamedEntity extraction - Should be implemented in child class',
    );
  });
});
