<commit_before>const assert = require('assert');
const Mebo = require('../src');
const testutils = require('../testutils');

const Reader = Mebo.Reader;
const Session = Mebo.Session;


describe('Reader:', () => {

  class CustomReader extends Reader{
    constructor(action){
      super(action);

      this.setOption('defaultOption', 'test');
    }

    async _perform(inputList){
      const result = {};

      for (const input of inputList){
        result[input.name()] = input.value();
      }

      return result;
    }
  }

  it('Should test custom options defined to the writer', () => {

    const action = new testutils.Actions.Shared.PlainObjectResult();
    action.setSession(new Session());

    const reader = new CustomReader(action);
    reader.setOption('defaultOption', 'test');
    assert.equal(reader.option('defaultOption'), 'test');
  });

  it('Should parse the action input values', () => {
    return (async () => {

      const action = new testutils.Actions.Shared.PlainObjectResult();
      action.setSession(new Session());

      action.input('a').setValue('text');
      action.input('b').setValue(20);

      const reader = new CustomReader(action);
      const inputValues = await reader.inputValues();

      // testing the result of the action
      assert.equal(inputValues.a, action.input('a').value());<commit_msg>fixed description of the test and implementation<commit_after>const assert = require('assert');
const Mebo = require('../src');
const testutils = require('../testutils');

const Reader = Mebo.Reader;
const Session = Mebo.Session;


describe('Reader:', () => {

  class CustomReader extends Reader{
    constructor(action){
      super(action);

      this.setOption('defaultOption', 'test');
    }

    async _perform(inputList){
      const result = {};

      for (const input of inputList){
        result[input.name()] = input.value();
      }

      return result;
    }
  }

  it('Should test custom options defined to the reader', () => {

    const action = new testutils.Actions.Shared.PlainObjectResult();
    action.setSession(new Session());

    const reader = new CustomReader(action);
    reader.setOption('defaultOption2', 10);
    assert.equal(reader.option('defaultOption'), 'test');
    assert.equal(reader.option('defaultOption2'), 10);
  });

  it('Should parse the action input values', () => {
    return (async () => {

      const action = new testutils.Actions.Shared.PlainObjectResult();
      action.setSession(new Session());

      action.input('a').setValue('text');
      action.input('b').setValue(20);

      const reader = new CustomReader(action);
      const inputValues = await reader.inputValues();

      // testing the result of the action
      assert.equal(inputValues.a, action.input('a').value());
{'fraction_non_alphanumeric': 0.15087593850554165, 'fraction_numerical': 0.003575259206292456, 'mean_word_length': 3.378716744913928, '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': '1015070', 'n_tokens_mistral': 799, 'n_tokens_neox': 764, 'n_words': 189}