{"size": 1659, "ext": "js", "max_stars_repo_path": "test/resolver/vehicle/carEngineResolverTest.js", "max_stars_repo_name": "vehicle-history/npm-vehicle-history-model", "max_stars_repo_stars_event_min_datetime": "2015-12-11T08:02:18.000Z", "max_stars_repo_stars_event_max_datetime": "2017-02-05T17:20:19.000Z", "max_issues_repo_path": "test/resolver/vehicle/carEngineResolverTest.js", "max_issues_repo_name": "vehicle-history/npm-vehicle-history-model", "max_issues_repo_issues_event_min_datetime": "2015-01-14T19:25:53.000Z", "max_issues_repo_issues_event_max_datetime": "2016-11-06T17:01:48.000Z", "max_forks_repo_path": "test/resolver/vehicle/carEngineResolverTest.js", "max_forks_repo_name": "vehicle-history/npm-vehicle-history-model", "max_forks_repo_forks_event_min_datetime": "2015-07-12T17:02:41.000Z", "max_forks_repo_forks_event_max_datetime": "2015-10-18T16:58:13.000Z"}
{"max_stars_count": 2, "max_issues_count": 30, "max_forks_count": 2, "avg_line_length": 23.7, "max_line_length": 85, "alphanum_fraction": 0.6021699819}
const options = require('config');
const carEngineResolver = require('../../../lib/resolver/vehicle/carEngineResolver');
const chai = require('chai');
const should = chai.should();
const expect = chai.expect;

describe('car engine resolver test', () => {

  it('should return valid cc and fuel type', done => {

    const map = {
      'engine.cc': 1398,
      'engine.fuel': 'petrol'
    };

    carEngineResolver.resolve(map, options);

    should.exist(map['engine.cc']);
    map['engine.cc'].should.equal(1398);
    should.exist(map['engine.fuel']);
    map['engine.fuel'].should.equal('PETROL');
    done();
  });

  it('should return null for all null values', done => {

    const map = {
      'engine.cc': null,
      'engine.fuel': null
    };

    carEngineResolver.resolve(map, options);
    expect(map['engine.cc']).to.be.null;
    should.exist(map['engine.fuel']);
    map['engine.fuel'].should.equal('OTHER');
    done();
  });

  it('should return object with some null values', done => {

    const map = {
      'engine.cc': '1398 cm³',
      'engine.fuel': null
    };

    carEngineResolver.resolve(map, options);

    should.exist(map['engine.cc']);
    map['engine.cc'].should.equal(1398);
    should.exist(map['engine.fuel']);
    map['engine.fuel'].should.equal('OTHER');

    done();
  });

  it('should return default fuel type for unknown value', done => {

    const map = {
      'engine.cc': null,
      'engine.fuel': 'unknown'
    };

    carEngineResolver.resolve(map, options);
    expect(map['engine.cc']).to.be.null;
    should.exist(map['engine.fuel']);
    map['engine.fuel'].should.equal('OTHER');
    done();
  });

});