{"size": 535, "ext": "js", "max_stars_repo_path": "test/add.js", "max_stars_repo_name": "jchamb/upcast", "max_stars_repo_stars_event_min_datetime": "2018-02-05T08:40:54.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-13T01:54:41.000Z", "max_issues_repo_path": "test/add.js", "max_issues_repo_name": "jchamb/upcast", "max_issues_repo_issues_event_min_datetime": "2017-10-17T14:35:00.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-15T04:07:12.000Z", "max_forks_repo_path": "test/add.js", "max_forks_repo_name": "jchamb/upcast", "max_forks_repo_forks_event_min_datetime": "2018-04-09T01:48:19.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-29T07:57:39.000Z"}
{"max_stars_count": 40, "max_issues_count": 30, "max_forks_count": 4, "avg_line_length": 26.75, "max_line_length": 73, "alphanum_fraction": 0.5943925234}
import test from 'ava';
import Upcast from '../main';

test('should be a function', t => {
    t.true(typeof Upcast.add === 'function');
});

test('should convert to date with correct types', t => {
    Upcast.add('date', v => new Date(v));

    t.true(typeof Upcast.cast.date === 'function');
    t.deepEqual(Upcast.to('1988-11-05', 'date'), new Date('1988-11-05'));
});

test('should throw when called with a non-handler method', t => {
    t.throws(() => {
        Upcast.add('fo', 'bar');
    }, /invalid argument: handler/i);
});
