{"size": 1433, "ext": "js", "max_stars_repo_path": "test/unit/question/session/index-test.js", "max_stars_repo_name": "jgraham-amplify/pie-cli", "max_stars_repo_stars_event_min_datetime": "2017-03-06T14:44:45.000Z", "max_stars_repo_stars_event_max_datetime": "2017-03-06T14:44:45.000Z", "max_issues_repo_path": "test/unit/question/session/index-test.js", "max_issues_repo_name": "jgraham-amplify/pie-cli", "max_issues_repo_issues_event_min_datetime": "2016-09-30T17:46:27.000Z", "max_issues_repo_issues_event_max_datetime": "2018-02-20T18:27:43.000Z", "max_forks_repo_path": "test/unit/question/session/index-test.js", "max_forks_repo_name": "PieLabs/pie-cli", "max_forks_repo_forks_event_min_datetime": "2020-10-31T11:43:07.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-31T15:46:25.000Z"}
{"max_stars_count": 1, "max_issues_count": 109, "max_forks_count": 2, "avg_line_length": 21.7121212121, "max_line_length": 78, "alphanum_fraction": 0.5401256106}
import { assert, match, spy, stub } from 'sinon';

import { expect } from 'chai';
import proxyquire from 'proxyquire';

describe('session', () => {

  let mod, deps, FileNames, filenamesInstance;

  beforeEach(() => {
    filenamesInstance = {
      resolveSession: stub().returns('session.json')
    };

    FileNames = {
      build: stub().returns(filenamesInstance)
    };

    deps = {
      '../config': {
        FileNames: FileNames
      },
      '../config/types': {
        fromPath: stub().returns([])
      },
      'fs-extra': {
        existsSync: stub().returns(false)
      }
    };

    mod = proxyquire('../../../../lib/question/session', deps);

  })

  describe('build', () => {

    beforeEach(() => {
      mod.Session.build('dir', { args: true });
    });

    it('calls Filenames.build', () => {
      assert.calledWith(FileNames.build, { args: true });
    });

    it('calls resolveSession', () => {
      assert.calledWith(filenamesInstance.resolveSession, 'dir');
    });

    it('calls existsSync', () => {
      assert.calledWith(filenamesInstance.resolveSession, 'dir');
    });
  });

  describe('reload', () => {
    let s;
    beforeEach(() => {
      s = new mod.Session('dir/session.json');
      deps['fs-extra'].existsSync.returns(true);
      s.reload();
    });

    it('calls fromPath', () => {
      assert.calledWith(deps['../config/types'].fromPath, 'dir/session.json');
    });
  });
});