{"size": 978, "ext": "js", "max_stars_repo_path": "week_1/jul_14_async_data_passing/test/async_test.js", "max_stars_repo_name": "ercain03/heroku_deployment", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "week_1/jul_14_async_data_passing/test/async_test.js", "max_issues_repo_name": "ercain03/heroku_deployment", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "week_1/jul_14_async_data_passing/test/async_test.js", "max_forks_repo_name": "ercain03/heroku_deployment", "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": 31.5483870968, "max_line_length": 110, "alphanum_fraction": 0.5879345603}
const expect = require('chai').expect;
const fs = require('fs');

const async = require('../lib/async_work');

describe('async reading of files', function() {
  var fileData = [];
  before(function(done) {
    fs.readFile(__dirname + '/one.txt', function(err, data) {
      fileData.push(data.toString());
      fs.readFile(__dirname + '/two.txt', function(err, data) {
        fileData.push(data.toString());
        fs.readFile(__dirname + '/three.txt', function(err, data) {
          fileData.push(data.toString()) ;
          done();
        });
      });
    });
  });

  it('should read the files in order', function(done) {
    async([__dirname + '/one.txt', __dirname + '/two.txt', __dirname + '/three.txt'], function(err, fileArr) {
      expect(err).to.eql(null);
      expect(fileArr[0].toString()).to.eql(fileData[0]);
      expect(fileArr[1].toString()).to.eql(fileData[1]);
      expect(fileArr[2].toString()).to.eql(fileData[2]);
      done();
    });
  });
});
