{"size": 1243, "ext": "js", "max_stars_repo_path": "test/index.js", "max_stars_repo_name": "rogeriopvl/is-outdated", "max_stars_repo_stars_event_min_datetime": "2015-07-28T03:27:11.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-24T11:47:55.000Z", "max_issues_repo_path": "test/index.js", "max_issues_repo_name": "rogeriopvl/is-outdated", "max_issues_repo_issues_event_min_datetime": "2015-12-09T18:59:03.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-24T09:29:19.000Z", "max_forks_repo_path": "test/index.js", "max_forks_repo_name": "rogeriopvl/is-outdated", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 4, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 25.8958333333, "max_line_length": 102, "alphanum_fraction": 0.6403861625}
var test = require('tape');
var mockery = require('mockery');

// Mock the latest-version module
var latestVersionMock = function (name, cb) {
  if (name === 'fakepackage') {
    return cb(new Error('Not found'));
  }
  return cb(null, '2.0.0');
};

mockery.enable({ warnOnUnregistered: false });
mockery.registerMock('latest-version', latestVersionMock);

var isOutdated = require('../');

test('is-outdated exists as a function', function (t) {
  t.equal(typeof isOutdated, 'function');
  t.end();
});

test('given a package name and inferior version should return and object with version', function (t) {
  t.plan(4);
  isOutdated('mypackage', '1.0.0', function (err, data) {
    t.error(err);
    t.ok(data);
    t.equal(typeof data, 'object');
    t.deepEqual(data, { version: '2.0.0' });
  });
});

test('given a package name and equal or superior version should return false', function (t) {
  t.plan(2);
  isOutdated('mypackage', '3.0.0', function (err, data) {
    t.error(err);
    t.notOk(data);
  });
});

test('given an inexistent package passes error to callback', function (t) {
  t.plan(3);
  isOutdated('fakepackage', '1.0.0', function (err, data) {
    t.ok(err);
    t.ok(err instanceof Error);
    t.notOk(data);
  });
});
