{"size": 2010, "ext": "js", "max_stars_repo_path": "test/url_parsing_test.js", "max_stars_repo_name": "GabrielCTroia/fetch-pretender", "max_stars_repo_stars_event_min_datetime": "2016-07-23T22:28:37.000Z", "max_stars_repo_stars_event_max_datetime": "2017-01-16T06:23:33.000Z", "max_issues_repo_path": "test/url_parsing_test.js", "max_issues_repo_name": "GabrielCTroia/fetch-pretender", "max_issues_repo_issues_event_min_datetime": "2018-07-12T19:47:14.000Z", "max_issues_repo_issues_event_max_datetime": "2018-07-12T19:47:14.000Z", "max_forks_repo_path": "test/url_parsing_test.js", "max_forks_repo_name": "GabrielCTroia/fetch-pretender", "max_forks_repo_forks_event_min_datetime": "2019-10-02T20:00:39.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-02T20:00:39.000Z"}
{"max_stars_count": 3, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 36.5454545455, "max_line_length": 117, "alphanum_fraction": 0.6303482587}
var describe = QUnit.module;
var it = QUnit.test;

describe('parseURL', function() {
  var parseURL = Pretender.parseURL;

  function testUrl(url, expectedParts) {
    it('pathname, fullpath, protocol, hash and search are correct', function(assert) {
      var parts = parseURL(url);
      assert.ok(parts, 'Parts exist');

      assert.equal(parts.protocol, expectedParts.protocol,  'protocol should be \"' + expectedParts.protocol + '\"');
      assert.equal(parts.pathname, expectedParts.pathname, 'pathname should be \"' + expectedParts.pathname + '\"');
      assert.equal(parts.host, expectedParts.host, 'hostname is equal to \"' + expectedParts.host + '\"');
      assert.equal(parts.search, expectedParts.search, 'search should be \"' + expectedParts.search + '\"');
      assert.equal(parts.hash, expectedParts.hash, 'hash should be \"' + expectedParts.search + '\"');
      assert.equal(parts.fullpath, expectedParts.fullpath, 'fullpath should be \"' + expectedParts.fullpath + '\"');
    });
  }

  describe('relative HTTP URLs', function() {
    testUrl('/mock/my/request?test=abc#def', {
      protocol: 'http:',
      pathname: '/mock/my/request',
      host: window.location.host,
      search: '?test=abc',
      hash: '#def',
      fullpath: '/mock/my/request?test=abc#def'
    });
  });

  describe('same-origin absolute HTTP URLs', function() {
    testUrl(window.location.protocol + '//' + window.location.host + '/mock/my/request?test=abc#def', {
      protocol: window.location.protocol,
      pathname: '/mock/my/request',
      host: window.location.host,
      search: '?test=abc',
      hash: '#def',
      fullpath: '/mock/my/request?test=abc#def'
    });
  });

  describe('cross-origin absolute HTTP URLs', function() {
    testUrl('https://www.yahoo.com/mock/my/request?test=abc', {
      protocol: 'https:',
      pathname: '/mock/my/request',
      host: 'www.yahoo.com',
      search: '?test=abc',
      hash: '',
      fullpath: '/mock/my/request?test=abc'
    });
  });
});

