UNPKG

flagpole

Version:

Simple and fast DOM integration, headless or headful browser, and REST API testing framework.

64 lines 2.66 kB
"use strict"; 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.ImageResponse = void 0; const response_1 = require("../response"); const url_1 = require("url"); const value_1 = require("../value"); const helpers_1 = require("../helpers"); const value_promise_1 = require("../value-promise"); class ImageResponse extends response_1.ProtoResponse { constructor() { super(...arguments); this.imageProperties = { width: 0, height: 0, type: "", mime: "", length: 0, url: "", }; } get length() { return helpers_1.wrapAsValue(this.context, this.imageProperties.length, "Image Size"); } get url() { return helpers_1.wrapAsValue(this.context, this.imageProperties.url, "URL of Image"); } get path() { return helpers_1.wrapAsValue(this.context, new url_1.URL(this.imageProperties.url).pathname, "URL Path of Image"); } init(httpResponse) { super.init(httpResponse); this.imageProperties = httpResponse.jsonBody; this.context .assert("MIME Type matches expected value for an image", this.imageProperties.mime) .startsWith("image/"); } eval() { return __awaiter(this, void 0, void 0, function* () { throw "This type of scenario does not suport eval."; }); } find(propertyName) { return value_promise_1.ValuePromise.wrap(new value_1.Value(typeof this.imageProperties[propertyName] !== "undefined" ? this.imageProperties[propertyName] : null, this.context, `${propertyName} of Image`)); } findAll(propertyName) { return __awaiter(this, void 0, void 0, function* () { const value = yield this.find(propertyName); return value.isNull() ? [] : [value]; }); } } exports.ImageResponse = ImageResponse; //# sourceMappingURL=image-response.js.map