<commit_before>import { PluginConfig } from '../dist';
import { App, BaseComponent, ComponentDeclaration } from '../src';
import { Component } from '../src/plugins/handler/decorators/Component';
import { MetadataStorage } from '../src/plugins/handler/metadata/MetadataStorage';
import { EmptyComponent, ExampleComponent, ExampleComponentPlugin } from './utilities';

// TODO implement more tests
describe('registering components', () => {
  let app: App;
  const metadataStorage = MetadataStorage.getInstance();
  beforeEach(() => {
    app = new App();
    metadataStorage.clearAll();
  });

  test('via BaseComponent-constructor and undecorated component', () => {
    app.useComponents(EmptyComponent);
    expect(app.components).toEqual({
      EmptyComponent: { target: EmptyComponent },
    });
  });

  describe('via ComponentPlugin', () => {
    test('no config passed', () => {
      app.use(new ExampleComponentPlugin());
      expect(app.components).toEqual({
        ExampleComponent: { target: ExampleComponent },
      });
    });

    test('config passed', () => {
      app.use(new ExampleComponentPlugin({ component: { text: 'edited' } }));
      expect(app.components).toEqual({
        ExampleComponent: { target: ExampleComponent, options: { config: { text: 'edited' } } },
      });
    });
  });

  describe('via ComponentDeclaration', () => {
    test('no options passed', () => {
      app.useComponents(new ComponentDeclaration(ExampleComponent));
      expect(app.components).toEqual({
        ExampleComponent: { target: ExampleComponent },
      });
    });

    test('options with config passed', () => {
      app.useComponents(<commit_msg>:white_check_mark: Update tests<commit_after>import { App, BaseComponent, ComponentDeclaration, PluginConfig } from '../src';
import { Component } from '../src/plugins/handler/decorators/Component';
import { MetadataStorage } from '../src/plugins/handler/metadata/MetadataStorage';
import { EmptyComponent, ExampleComponent, ExampleComponentPlugin } from './utilities';

// TODO implement more tests
describe('registering components', () => {
  let app: App;
  const metadataStorage = MetadataStorage.getInstance();
  beforeEach(() => {
    app = new App();
    metadataStorage.clearAll();
  });

  test('via BaseComponent-constructor and undecorated component', () => {
    app.useComponents(EmptyComponent);
    expect(app.components).toEqual({
      EmptyComponent: { target: EmptyComponent },
    });
  });

  describe('via ComponentPlugin', () => {
    test('no config passed', () => {
      app.use(new ExampleComponentPlugin());
      expect(app.components).toEqual({
        ExampleComponent: { target: ExampleComponent },
      });
    });

    test('config passed', () => {
      app.use(new ExampleComponentPlugin({ component: { text: 'edited' } }));
      expect(app.components).toEqual({
        ExampleComponent: { target: ExampleComponent, options: { config: { text: 'edited' } } },
      });
    });
  });

  describe('via ComponentDeclaration-instance', () => {
    test('no options passed', () => {
      app.useComponents(new ComponentDeclaration(ExampleComponent));
      expect(app.components).toEqual({
        ExampleComponent: { target: ExampleComponent },
      });
    });

    test('options with config passed', () => {
      app.useComponents(
        new ComponentDeclaration(ExampleComponent, {
          config: {
            text: 'edited',
          },
        }),
      );
      expect(app.components).toEqual({
        ExampleComponent: { target: ExampleComponent, options: { config: { text: 'edited' } } },
      });
    });

    test('options with components passed', () => {
      app.useComponents(
        new ComponentDeclaration(ExampleComponent, { components: [EmptyComponent] }),
      );
      expect(app.components).toEqual({
        ExampleComponent: {
          target: ExampleComponent,
          options: { components: [EmptyComponent] },
        },
      });
    });
  });

  describe('via ComponentDeclaration-object', () => {
    test('no options passed', () => {
      app.useComponents({ component: ExampleComponent });
      expect(app.components).toEqual({
        ExampleComponent: { target: ExampleComponent },
      });
    });

    test('options with config passed', () => {
      app.useComponents(
{'fraction_non_alphanumeric': 0.1558891454965358, 'fraction_numerical': 0.0, 'mean_word_length': 3.2754195459032576, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '4531833', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1097, 'n_words': 230}