{"size": 1145, "ext": "js", "max_stars_repo_path": "tests/es2018.js", "max_stars_repo_name": "inexorabletash/poly2", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/es2018.js", "max_issues_repo_name": "inexorabletash/poly2", "max_issues_repo_issues_event_min_datetime": "2018-06-21T19:39:01.000Z", "max_issues_repo_issues_event_max_datetime": "2018-06-21T19:39:01.000Z", "max_forks_repo_path": "tests/es2018.js", "max_forks_repo_name": "inexorabletash/poly2", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 26.0227272727, "max_line_length": 92, "alphanum_fraction": 0.6366812227}
/*global QUnit,global*/

QUnit.module("ES2018: Promise");

QUnit.test('Promise.prototype.finally', function(assert) {
  assert.ok('finally' in Promise.prototype);
  assert.equal(typeof Promise.prototype.finally, 'function');
  assert.equal(Promise.prototype.finally.length, 1);

  function async(f) {
    var done = assert.async();
    f(done);
  }

  async(function(done) {
    Promise.resolve().finally(function() {
      assert.equal(arguments.length, 0, 'Finally callback gets no args - resolved promise');
      done();
    });
  });

  async(function(done) {
    Promise.reject().finally(function() {
      assert.equal(arguments.length, 0, 'Finally callback gets no args - rejected promise');
      done();
    }).catch(function() {});
  });

  async(function(done) {
    Promise.resolve(2).finally(function() {}).then(function(r) {
      assert.equal(r, 2, 'Finally passes resolution through promise chain');
      done();
    });
  });

  async(function(done) {
    Promise.reject(3).finally(function() {}).catch(function(r) {
      assert.equal(r, 3, 'Finally passes rejection through promise chain');
      done();
    });
  });

});
