{"size": 878, "ext": "js", "max_stars_repo_path": "test/testDriver.js", "max_stars_repo_name": "creatorrr/log-driver", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/testDriver.js", "max_issues_repo_name": "creatorrr/log-driver", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/testDriver.js", "max_forks_repo_name": "creatorrr/log-driver", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.1052631579, "max_line_length": 95, "alphanum_fraction": 0.6241457859}
import through2 from "through2";

import Logger from "../src/logger";
import Driver from "../src/driver";

let
  loggerName = "rorschach",
  {createDriver} = Logger,
  logger = new Logger(loggerName);

export default function testDriver ({expect, doesNotThrow, equal, done}) {
  // 2 assertions total
  expect(2);

  let
    driver = createDriver("test", (msgs, {name}) => `${ name } says ${ msgs+'' }`),

    testMessage = "the end is nigh",
    testStream = through2.obj(function (chunk, enc, callback) {
      // Check if chunk matches processed message
      equal(chunk, `${ loggerName } says ${ testMessage }`, "message not processed correctly");

      // All tests done
      done();
    });

  doesNotThrow(() => {
    // Add test stream to logger
    logger
      .pipe(driver)
      .pipe(testStream);

    // Call log function
    logger.info(testMessage);
  });
}

