UNPKG

flagpole

Version:

Simple and fast DOM integration and REST API testing framework.

41 lines (32 loc) 1.14 kB
import { iResponse, GenericResponse, SimplifiedResponse, ResponseType } from "./response"; import { Scenario } from "./scenario"; import { Node } from "./node"; const css = require('css'); export class CssResponse extends GenericResponse implements iResponse { protected css: any; constructor(scenario: Scenario, url: string, response: SimplifiedResponse) { super(scenario, url, response); this.status().between(200, 299); //this.headers('Content-Type').similarTo('text/css'); this.css = css.parse(this.getBody(), { silent: true }); this.validate(); } public select(path: string): Node { return new Node(this, path, null); } public getType(): ResponseType { return ResponseType.stylesheet; } protected validate() { this.assert( ( this.css.type == 'stylesheet' && this.css.stylesheet && this.css.stylesheet.parsingErrors && this.css.stylesheet.parsingErrors.length === 0 ), 'CSS is valid', 'CSS is not valid' ); } }