flagpole
Version:
Simple and fast DOM integration, headless or headful browser, and REST API testing framework.
44 lines • 1.75 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.JsonResponse = void 0;
const response_1 = require("../response");
const jpath_1 = require("./jpath");
class JsonResponse extends response_1.ProtoResponse {
constructor() {
super(...arguments);
this.find = (path) => jpath_1.jpathFind(this, path);
this.findAll = (path) => jpath_1.jpathFindAll(this, path);
}
get responseTypeName() {
return "JSON";
}
get responseType() {
return "json";
}
init(httpResponse) {
super.init(httpResponse);
this.jsonDoc = new jpath_1.JsonDoc(this.jsonBody.$);
this.context
.assert("JSON is valid", this.jsonBody.$)
.type.not.equals("null");
}
getRoot() {
return this.jsonBody.$;
}
eval() {
return __awaiter(this, void 0, void 0, function* () {
throw "This type of scenario does not suport eval.";
});
}
}
exports.JsonResponse = JsonResponse;
//# sourceMappingURL=jsonresponse.js.map