{"size": 1535, "ext": "js", "max_stars_repo_path": "test/args.test.js", "max_stars_repo_name": "aliyun/alibabacloud-resourcify-cli", "max_stars_repo_stars_event_min_datetime": "2020-10-10T05:00:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-09T07:57:34.000Z", "max_issues_repo_path": "test/args.test.js", "max_issues_repo_name": "aliyun/alibabacloud-resourcify-cli", "max_issues_repo_issues_event_min_datetime": "2020-10-10T06:26:30.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T06:01:28.000Z", "max_forks_repo_path": "test/args.test.js", "max_forks_repo_name": "aliyun/alibabacloud-resourcify-cli", "max_forks_repo_forks_event_min_datetime": "2020-10-10T06:48:54.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-11T00:54:53.000Z"}
{"max_stars_count": 11, "max_issues_count": 52, "max_forks_count": 6, "avg_line_length": 22.5735294118, "max_line_length": 50, "alphanum_fraction": 0.5146579805}
'use strict';

const assert = require('assert');

const { parse } = require('../lib/args');

describe('args parse', function () {
  it('parse argv should ok', function () {
    let r = parse([]);
    assert.deepStrictEqual(r.argv, []);
    r = parse(['help']);
    assert.deepStrictEqual(r.argv, ['help']);
  });

  it('parse args should ok', function () {
    let r = parse([]);
    assert.deepStrictEqual(r.parsed, new Map());
    r = parse(['--help']);
    assert.deepStrictEqual(r.parsed, new Map([
      ['help']
    ]));
    r = parse(['--akid=akid']);
    assert.deepStrictEqual(r.parsed, new Map([
      ['akid', 'akid']
    ]));

    r = parse(['--aksecret', 'secret']);
    assert.deepStrictEqual(r.parsed, new Map([
      ['aksecret', 'secret']
    ]));

    r = parse(['--aksecret']);
    assert.deepStrictEqual(r.parsed, new Map([
      ['aksecret', undefined]
    ]));
  });

  it('alias should ok', function () {
    let r = parse(['-i'], {});
    assert.deepStrictEqual(r.parsed, new Map([]));
    r = parse(['-i'], {
      interaction: {
        alias: 'i'
      }
    });
    assert.deepStrictEqual(r.parsed, new Map([
      ['interaction', undefined]
    ]));

    r = parse(['-i=test'], {
      interaction: {
        alias: 'i'
      }
    });
    assert.deepStrictEqual(r.parsed, new Map([
      ['interaction', 'test']
    ]));

    r = parse(['-i', 'test'], {
      interaction: {
        alias: 'i'
      }
    });
    assert.deepStrictEqual(r.parsed, new Map([
      ['interaction', 'test']
    ]));
  });
});