"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.jsoniblePromise = jsoniblePromise;
exports.default = void 0;

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));

// used for testing fetch calls that expect a
// promise returned by jsonify
function jsoniblePromise(resolutionValue) {
  var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
  var resolvePromise = new Promise(function (resolve, reject) {
    resolve(resolutionValue);
  });
  return {
    status: options.status || 200,
    headers: {
      get: function get(attr) {
        return (0, _objectSpread2.default)({
          'Content-Type': options.contentType || 'application/json; charset=utf-8'
        }, options.headers || {})[attr];
      }
    },
    json: function json() {
      return resolvePromise;
    }
  };
}

var _default = function _default(res) {
  return res.json();
};

exports.default = _default;