How to use exposed method in wpt

Best JavaScript code snippet using wpt

exposed-promise.spec.ts

Source:exposed-promise.spec.ts Github

copy

Full Screen

1import * as chai from 'chai'2import * as chaiAsPromised from 'chai-as-promised'3import 'mocha'4import { ExposedPromise, ExposedPromiseStatus } from '../src/utils/exposed-promise'5process.on('unhandledRejection', (reason, p) => {6 console.log('Unhandled Rejection at: Promise', p, 'reason:', reason)7})8// use chai-as-promised plugin9chai.use(chaiAsPromised)10const expect = chai.expect11const WAIT_TIME = 012const cancelTimeoutAndSettle = (13 timeout: NodeJS.Timeout,14 settleFunction: (result?: any) => void15) => {16 if (timeout) {17 clearTimeout(timeout)18 }19 return settleFunction20}21const getExpectedPromiseOutcome = (22 exposed: ExposedPromise<any, any>,23 expectedStatus: ExposedPromiseStatus24) => {25 const resolvePredicate = expectedStatus === ExposedPromiseStatus.RESOLVED26 const rejectPredicate = expectedStatus === ExposedPromiseStatus.REJECTED27 const finallyPredicate =28 expectedStatus === ExposedPromiseStatus.RESOLVED ||29 expectedStatus === ExposedPromiseStatus.REJECTED30 const promises: Promise<any>[] = []31 promises.push(32 // Resolve33 new Promise((resolve, reject) => {34 exposed.promise35 .then((result) => {36 cancelTimeoutAndSettle(timeout, resolvePredicate ? resolve : reject)(result)37 })38 .catch(() => undefined)39 const timeout = global.setTimeout(() => {40 ;(resolvePredicate ? reject : resolve)()41 }, WAIT_TIME)42 }).catch(() => undefined)43 )44 promises.push(45 // Reject46 new Promise((resolve, reject) => {47 exposed.promise.catch((result) => {48 cancelTimeoutAndSettle(timeout, rejectPredicate ? resolve : reject)(result)49 })50 const timeout = global.setTimeout(() => {51 ;(rejectPredicate ? reject : resolve)()52 }, WAIT_TIME)53 }).catch(() => undefined)54 )55 promises.push(56 // Finally57 new Promise((resolve, reject) => {58 exposed.promise59 .catch(() => undefined)60 .finally(() => {61 cancelTimeoutAndSettle(timeout, finallyPredicate ? resolve : reject)()62 })63 const timeout = global.setTimeout(() => {64 ;(finallyPredicate ? reject : resolve)()65 }, WAIT_TIME)66 }).catch(() => undefined)67 )68 return promises69}70describe(`ExposedPromise`, () => {71 it(`should create an empty ExposedPromise`, async () => {72 const exposed = new ExposedPromise()73 const promises = getExpectedPromiseOutcome(exposed, ExposedPromiseStatus.PENDING)74 expect(exposed instanceof ExposedPromise, 'is instanceof ExposedPromise').to.be.true75 expect(exposed.isPending(), 'isPending').to.be.true76 expect(exposed.isResolved(), 'isResolved').to.be.false77 expect(exposed.isRejected(), 'isRejected').to.be.false78 expect(exposed.isSettled(), 'isSettled').to.be.false79 expect(typeof exposed.promise, 'promise').to.equal('object')80 expect(exposed.promiseResult, 'promiseResult').to.be.undefined81 expect(exposed.promiseError, 'promiseError').to.be.undefined82 expect(exposed.status, 'status').to.equal(ExposedPromiseStatus.PENDING)83 expect(typeof exposed.resolve, 'resolve').to.equal('function')84 expect(typeof exposed.reject, 'reject').to.equal('function')85 expect(await Promise.all(promises)).to.deep.equal([undefined, undefined, undefined])86 })87 it(`should correctly resolve an ExposedPromise`, async () => {88 const exposed = new ExposedPromise()89 const successMessage = 'success message!'90 exposed.resolve(successMessage)91 const promises = getExpectedPromiseOutcome(exposed, ExposedPromiseStatus.RESOLVED)92 expect(exposed instanceof ExposedPromise, 'is instanceof ExposedPromise').to.be.true93 expect(exposed.isPending(), 'isPending').to.be.false94 expect(exposed.isResolved(), 'isResolved').to.be.true95 expect(exposed.isRejected(), 'isRejected').to.be.false96 expect(exposed.isSettled(), 'isSettled').to.be.true97 expect(typeof exposed.promise, 'promise').to.equal('object')98 expect(exposed.promiseResult, 'promiseResult').to.equal(successMessage)99 expect(exposed.promiseError, 'promiseError').to.be.undefined100 expect(exposed.status, 'status').to.equal(ExposedPromiseStatus.RESOLVED)101 expect(typeof exposed.resolve, 'resolve').to.equal('function')102 expect(typeof exposed.reject, 'reject').to.equal('function')103 expect(await Promise.all(promises)).to.deep.equal(['success message!', undefined, undefined])104 })105 it(`should create a resolved ExposedPromise when calling the static resolve`, async () => {106 const exposed = ExposedPromise.resolve(undefined)107 const promises = getExpectedPromiseOutcome(exposed, ExposedPromiseStatus.RESOLVED)108 expect(exposed instanceof ExposedPromise, 'is instanceof ExposedPromise').to.be.true109 expect(exposed.isPending(), 'isPending').to.be.false110 expect(exposed.isResolved(), 'isResolved').to.be.true111 expect(exposed.isRejected(), 'isRejected').to.be.false112 expect(exposed.isSettled(), 'isSettled').to.be.true113 expect(typeof exposed.promise, 'promise').to.equal('object')114 expect(exposed.promiseResult, 'promiseResult').to.be.undefined115 expect(exposed.promiseError, 'promiseError').to.be.undefined116 expect(exposed.status, 'status').to.equal(ExposedPromiseStatus.RESOLVED)117 expect(typeof exposed.resolve, 'resolve').to.equal('function')118 expect(typeof exposed.reject, 'reject').to.equal('function')119 expect(await Promise.all(promises)).to.deep.equal([undefined, undefined, undefined])120 })121 it(`should create a resolved ExposedPromise when calling the static resolve with data`, async () => {122 const successMessage = 'success message!'123 const exposed = ExposedPromise.resolve(successMessage)124 const promises = getExpectedPromiseOutcome(exposed, ExposedPromiseStatus.RESOLVED)125 expect(exposed instanceof ExposedPromise, 'is instanceof ExposedPromise').to.be.true126 expect(exposed.isPending(), 'isPending').to.be.false127 expect(exposed.isResolved(), 'isResolved').to.be.true128 expect(exposed.isRejected(), 'isRejected').to.be.false129 expect(exposed.isSettled(), 'isSettled').to.be.true130 expect(typeof exposed.promise, 'promise').to.equal('object')131 expect(exposed.promiseResult, 'promiseResult').to.equal(successMessage)132 expect(exposed.promiseError, 'promiseError').to.be.undefined133 expect(exposed.status, 'status').to.equal(ExposedPromiseStatus.RESOLVED)134 expect(typeof exposed.resolve, 'resolve').to.equal('function')135 expect(typeof exposed.reject, 'reject').to.equal('function')136 expect(await Promise.all(promises)).to.deep.equal(['success message!', undefined, undefined])137 })138 it(`should not change its state after it has been resolved`, async () => {139 const exposed = new ExposedPromise()140 const successMessage1 = 'success message!'141 const successMessage2 = 'success message!'142 exposed.resolve(successMessage1)143 exposed.resolve(successMessage2)144 const promises = getExpectedPromiseOutcome(exposed, ExposedPromiseStatus.RESOLVED)145 expect(exposed instanceof ExposedPromise, 'is instanceof ExposedPromise').to.be.true146 expect(exposed.isPending(), 'isPending').to.be.false147 expect(exposed.isResolved(), 'isResolved').to.be.true148 expect(exposed.isRejected(), 'isRejected').to.be.false149 expect(exposed.isSettled(), 'isSettled').to.be.true150 expect(typeof exposed.promise, 'promise').to.equal('object')151 expect(exposed.promiseResult, 'promiseResult').to.equal(successMessage1)152 expect(exposed.promiseError, 'promiseError').to.be.undefined153 expect(exposed.status, 'status').to.equal(ExposedPromiseStatus.RESOLVED)154 expect(typeof exposed.resolve, 'resolve').to.equal('function')155 expect(typeof exposed.reject, 'reject').to.equal('function')156 expect(await Promise.all(promises)).to.deep.equal(['success message!', undefined, undefined])157 })158 it(`should not resolve a promise in an ExposedPromise`, async () => {159 const exposed = new ExposedPromise<Promise<string>>()160 const successMessage = 'success message!'161 exposed.resolve(Promise.resolve(successMessage))162 const promises = getExpectedPromiseOutcome(exposed, ExposedPromiseStatus.RESOLVED)163 expect(exposed instanceof ExposedPromise, 'is instanceof ExposedPromise').to.be.true164 expect(exposed.isPending(), 'isPending').to.be.false165 expect(exposed.isResolved(), 'isResolved').to.be.true166 expect(exposed.isRejected(), 'isRejected').to.be.false167 expect(exposed.isSettled(), 'isSettled').to.be.true168 expect(typeof exposed.promise, 'promise').to.equal('object')169 expect(await exposed.promiseResult, 'promiseResult').to.equal(successMessage)170 expect(exposed.promiseError, 'promiseError').to.be.undefined171 expect(exposed.status, 'status').to.equal(ExposedPromiseStatus.RESOLVED)172 expect(typeof exposed.resolve, 'resolve').to.equal('function')173 expect(typeof exposed.reject, 'reject').to.equal('function')174 expect(await Promise.all(promises)).to.deep.equal(['success message!', undefined, undefined])175 })176 it(`should resolve options.result immediately`, async () => {177 const successMessage = 'success message!'178 const exposed = ExposedPromise.resolve(successMessage)179 const promises = getExpectedPromiseOutcome(exposed, ExposedPromiseStatus.RESOLVED)180 expect(exposed instanceof ExposedPromise, 'is instanceof ExposedPromise').to.be.true181 expect(exposed.isPending(), 'isPending').to.be.false182 expect(exposed.isResolved(), 'isResolved').to.be.true183 expect(exposed.isRejected(), 'isRejected').to.be.false184 expect(exposed.isSettled(), 'isSettled').to.be.true185 expect(typeof exposed.promise, 'promise').to.equal('object')186 expect(exposed.promiseResult, 'promiseResult').to.equal(successMessage)187 expect(exposed.promiseError, 'promiseError').to.be.undefined188 expect(exposed.status, 'status').to.equal(ExposedPromiseStatus.RESOLVED)189 expect(typeof exposed.resolve, 'resolve').to.equal('function')190 expect(typeof exposed.reject, 'reject').to.equal('function')191 expect(await Promise.all(promises)).to.deep.equal(['success message!', undefined, undefined])192 })193 it(`should resolve options.result (undefined) immediately`, async () => {194 const successMessage = undefined195 const exposed = ExposedPromise.resolve(successMessage)196 const promises = getExpectedPromiseOutcome(exposed, ExposedPromiseStatus.RESOLVED)197 expect(exposed instanceof ExposedPromise, 'is instanceof ExposedPromise').to.be.true198 expect(exposed.isPending(), 'isPending').to.be.false199 expect(exposed.isResolved(), 'isResolved').to.be.true200 expect(exposed.isRejected(), 'isRejected').to.be.false201 expect(exposed.isSettled(), 'isSettled').to.be.true202 expect(typeof exposed.promise, 'promise').to.equal('object')203 expect(exposed.promiseResult, 'promiseResult').to.equal(successMessage)204 expect(exposed.promiseError, 'promiseError').to.be.undefined205 expect(exposed.status, 'status').to.equal(ExposedPromiseStatus.RESOLVED)206 expect(typeof exposed.resolve, 'resolve').to.equal('function')207 expect(typeof exposed.reject, 'reject').to.equal('function')208 expect(await Promise.all(promises)).to.deep.equal([undefined, undefined, undefined])209 })210 it(`should correctly reject an ExposedPromise`, async () => {211 const exposed = new ExposedPromise()212 exposed.promise.catch(() => undefined) // We need to add a catch here or it will trigger an unhandled rejection error213 const failure = 'failure message!'214 exposed.reject(failure)215 const promises = getExpectedPromiseOutcome(exposed, ExposedPromiseStatus.REJECTED)216 expect(exposed instanceof ExposedPromise, 'is instanceof ExposedPromise').to.be.true217 expect(exposed.isPending(), 'isPending').to.be.false218 expect(exposed.isResolved(), 'isResolved').to.be.false219 expect(exposed.isRejected(), 'isRejected').to.be.true220 expect(exposed.isSettled(), 'isSettled').to.be.true221 expect(typeof exposed.promise, 'promise').to.equal('object')222 expect(exposed.promiseResult, 'promiseResult').to.be.undefined223 expect(exposed.promiseError, 'promiseError').to.equal(failure)224 expect(exposed.status, 'status').to.equal(ExposedPromiseStatus.REJECTED)225 expect(typeof exposed.resolve, 'resolve').to.equal('function')226 expect(typeof exposed.reject, 'reject').to.equal('function')227 expect(await Promise.all(promises)).to.deep.equal([undefined, 'failure message!', undefined])228 })229 it(`should not change its state after it has been rejected`, async () => {230 const exposed = new ExposedPromise()231 exposed.promise.catch(() => undefined) // We need to add a catch here or it will trigger an unhandled rejection error232 const failureMessage1 = 'failure message 1!'233 const failureMessage2 = 'failure message 2!'234 exposed.reject(failureMessage1)235 exposed.reject(failureMessage2)236 const promises = getExpectedPromiseOutcome(exposed, ExposedPromiseStatus.REJECTED)237 expect(exposed instanceof ExposedPromise, 'is instanceof ExposedPromise').to.be.true238 expect(exposed.isPending(), 'isPending').to.be.false239 expect(exposed.isResolved(), 'isResolved').to.be.false240 expect(exposed.isRejected(), 'isRejected').to.be.true241 expect(exposed.isSettled(), 'isSettled').to.be.true242 expect(typeof exposed.promise, 'promise').to.equal('object')243 expect(exposed.promiseResult, 'promiseResult').to.be.undefined244 expect(exposed.promiseError, 'promiseError').to.equal(failureMessage1)245 expect(exposed.status, 'status').to.equal(ExposedPromiseStatus.REJECTED)246 expect(typeof exposed.resolve, 'resolve').to.equal('function')247 expect(typeof exposed.reject, 'reject').to.equal('function')248 expect(await Promise.all(promises)).to.deep.equal([undefined, 'failure message 1!', undefined])249 })250 it(`should reject options.reject immediately`, async () => {251 const failureMessage = 'failure message!'252 const exposed = ExposedPromise.reject<unknown>(failureMessage)253 exposed.promise.catch(() => undefined) // We need to add a catch here or it will trigger an unhandled rejection error254 const promises = getExpectedPromiseOutcome(exposed, ExposedPromiseStatus.REJECTED)255 expect(exposed instanceof ExposedPromise, 'is instanceof ExposedPromise').to.be.true256 expect(exposed.isPending(), 'isPending').to.be.false257 expect(exposed.isResolved(), 'isResolved').to.be.false258 expect(exposed.isRejected(), 'isRejected').to.be.true259 expect(exposed.isSettled(), 'isSettled').to.be.true260 expect(typeof exposed.promise, 'promise').to.equal('object')261 expect(exposed.promiseResult, 'promiseResult').to.be.undefined262 expect(exposed.promiseError, 'promiseError').to.equal(failureMessage)263 expect(exposed.status, 'status').to.equal(ExposedPromiseStatus.REJECTED)264 expect(typeof exposed.resolve, 'resolve').to.equal('function')265 expect(typeof exposed.reject, 'reject').to.equal('function')266 expect(await Promise.all(promises)).to.deep.equal([undefined, 'failure message!', undefined])267 })268 it(`should reject options.reject (undefined) immediately`, async () => {269 const failureMessage = 'failure message!'270 const exposed = ExposedPromise.reject<unknown>(failureMessage)271 exposed.promise.catch(() => undefined) // We need to add a catch here or it will trigger an unhandled rejection error272 const promises = getExpectedPromiseOutcome(exposed, ExposedPromiseStatus.REJECTED)273 expect(exposed instanceof ExposedPromise, 'is instanceof ExposedPromise').to.be.true274 expect(exposed.isPending(), 'isPending').to.be.false275 expect(exposed.isResolved(), 'isResolved').to.be.false276 expect(exposed.isRejected(), 'isRejected').to.be.true277 expect(exposed.isSettled(), 'isSettled').to.be.true278 expect(typeof exposed.promise, 'promise').to.equal('object')279 expect(exposed.promiseResult, 'promiseResult').to.be.undefined280 expect(exposed.promiseError, 'promiseError').to.equal(failureMessage)281 expect(exposed.status, 'status').to.equal(ExposedPromiseStatus.REJECTED)282 expect(typeof exposed.resolve, 'resolve').to.equal('function')283 expect(typeof exposed.reject, 'reject').to.equal('function')284 expect(await Promise.all(promises)).to.deep.equal([undefined, 'failure message!', undefined])285 })...

Full Screen

Full Screen

AddExposed.js

Source:AddExposed.js Github

copy

Full Screen

1import React from "react";2import { withRouter } from "react-router-dom";3import HeaderPrivate from "../header/HeaderPrivate";4import FooterPrivate from "../footer/FooterPrivate";5import { connect } from "react-redux";6import styles from "../../css/CreateProject.module.scss";7import { Link } from "react-router-dom";8import { buildUrl } from "../../utils/UrlService";9import SideBar from "../sidebar/SideBar";10class AddExposed extends React.Component {11 constructor(props) {12 super(props);13 this.state = {14 fields: {},15 errors: {},16 threat: {},17 indexProject: 0,18 };19 console.log(this.props.match.params.id);20 }21 //willMount22 async componentWillMount() {23 await this.loadThreat(this.props.match.params.id);24 let idxProject = this.state.threat.project.substring(25 this.state.threat.project.lastIndexOf("/") + 1,26 this.state.threat.project.length27 );28 this.setState({ indexProject: idxProject });29 }30 async loadThreat(id) {31 console.log("loadThreat");32 this.setState({ isLoading: true });33 await fetch(`https://risk-module-api.herokuapp.com/api/v1/threats/${id}`, {34 headers: new Headers({35 Authorization:36 "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE2MTIyOTI2MjMsImV4cCI6MTYxNTg5MjYyMywicm9sZXMiOltdLCJ1c2VybmFtZSI6ImFyY2Vsb3JAcmV6aWxpby5jb20ifQ.GYJOGNlJ-voqBztUVrmOT5AfqeBMq2Dy9Hx0c_XNDfzfEMlZddgqFJrmwVI5xGhzPVD5t9BwZqjdTNaX41_EDQvfkdJwL66nV1na09-qGr0e7Skx9q6TKhdx_-PXX78LW2H0QZLXnIJL7tzoqKhZoDJ3AuLCvIfqMP4ta-wr1PoIE_X6cjGGZqRlK0YO9A912LUKikzc-mHdaEz0WGttdEojEhm5ttvux9naO8-Ld9I7llIk_bP6Bpp5hdfmhvUCDSZoCfvmTeyMsOTtnQHr8JaB1Wln_8L5-1Ia-6S_mE-xenFNT6BHalhFPYwX9GC1mv5slSuaJoKNRvJH-hlFj_vHXZ4xD7ZVoxajBQHMZcMEh24shlKGnT96dfGHnSe2Fo_JjOSkgLvU-UsPI4FrMbHWg753a72I7YP7s0tryFCPPtjI7UdtUcFCk8ow4Z71BBk9NT7LqshXjNoxikz2R5HOVgHMO2YpS_y8b_7vgiN553xPZ3nMFB58AZ3o9by8LR7UxA9dMsOrFURjttn3LVQI-__dClFW9YdtXicB0tNLR6ITV73JSQVtSs4qRPMU8Ds6jyOu7IiBwqIdosxUls8ZdMXq0q_9EjmIe-dSpIMW75wqglPkv2EhZowo_GMdI37_pGxubGXlPAVs4yUMUihFfb9sN6C1kWMPi0suHYs",37 }),38 })39 .then((response) => response.json())40 .then((data) => {41 this.setState({42 threat: data,43 });44 });45 console.log(this.state.threat);46 }47 handleValidation() {48 let fields = this.state.fields;49 let errors = {};50 let formIsValid = true;51 if (!fields["exposedName"]) {52 formIsValid = false;53 errors["exposedName"] = "Exposed name cannot be empty";54 }55 if (!fields["exposedDescription"]) {56 formIsValid = false;57 errors["exposedDescription"] = "Exposed Description cannot be empty";58 }59 if (!fields["exposedType"]) {60 formIsValid = false;61 errors["exposedType"] = "Exposed type cannot be empty";62 }63 if (!fields["exposedImportance"]) {64 formIsValid = false;65 errors["exposedImportance"] = "Exposed importance cannot be empty";66 }67 if (!fields["exposedLocation"]) {68 formIsValid = false;69 errors["exposedLocation"] = "Exposed location cannot be empty";70 }71 if (!fields["exposedRecovery"]) {72 formIsValid = false;73 errors["exposedRecovery"] = "Exposed recovery time cannot be empty";74 }75 if (!fields["exposedDown"]) {76 formIsValid = false;77 errors["exposedDown"] = "Exposed down time cannot be empty";78 }79 this.setState({ errors: errors });80 return formIsValid;81 }82 submitForm(e) {83 console.log("submitSite");84 if (this.handleValidation()) {85 this.addNewExposed();86 this.props.history.push(`/threats/edit/${this.props.match.params.id}`);87 } else {88 console.log("novalido");89 e.preventDefault();90 }91 }92 handleChange(field, e) {93 let fields = this.state.fields;94 fields[field] = e.target.value;95 this.setState({ fields });96 }97 addNewExposed() {98 console.log("addNewExposed");99 const requestOptions = {100 method: "POST",101 headers: {102 Authorization:103 "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE2MTIyOTI2MjMsImV4cCI6MTYxNTg5MjYyMywicm9sZXMiOltdLCJ1c2VybmFtZSI6ImFyY2Vsb3JAcmV6aWxpby5jb20ifQ.GYJOGNlJ-voqBztUVrmOT5AfqeBMq2Dy9Hx0c_XNDfzfEMlZddgqFJrmwVI5xGhzPVD5t9BwZqjdTNaX41_EDQvfkdJwL66nV1na09-qGr0e7Skx9q6TKhdx_-PXX78LW2H0QZLXnIJL7tzoqKhZoDJ3AuLCvIfqMP4ta-wr1PoIE_X6cjGGZqRlK0YO9A912LUKikzc-mHdaEz0WGttdEojEhm5ttvux9naO8-Ld9I7llIk_bP6Bpp5hdfmhvUCDSZoCfvmTeyMsOTtnQHr8JaB1Wln_8L5-1Ia-6S_mE-xenFNT6BHalhFPYwX9GC1mv5slSuaJoKNRvJH-hlFj_vHXZ4xD7ZVoxajBQHMZcMEh24shlKGnT96dfGHnSe2Fo_JjOSkgLvU-UsPI4FrMbHWg753a72I7YP7s0tryFCPPtjI7UdtUcFCk8ow4Z71BBk9NT7LqshXjNoxikz2R5HOVgHMO2YpS_y8b_7vgiN553xPZ3nMFB58AZ3o9by8LR7UxA9dMsOrFURjttn3LVQI-__dClFW9YdtXicB0tNLR6ITV73JSQVtSs4qRPMU8Ds6jyOu7IiBwqIdosxUls8ZdMXq0q_9EjmIe-dSpIMW75wqglPkv2EhZowo_GMdI37_pGxubGXlPAVs4yUMUihFfb9sN6C1kWMPi0suHYs",104 "Content-Type": "application/json",105 },106 body: JSON.stringify({107 name: this.state.fields["exposedName"],108 description: this.state.fields["exposedDescription"],109 type: this.state.fields["exposedType"],110 importance: this.state.fields["exposedImportance"],111 location: this.state.fields["exposedLocation"],112 recoveryTime: parseInt(this.state.fields["exposedRecovery"]),113 downTime: parseInt(this.state.fields["exposedDown"]),114 threat: "/api/v1/threats/" + this.props.match.params.id,115 project: "/api/v1/projects/" + this.state.indexProject,116 }),117 };118 console.log(requestOptions);119 fetch(120 "https://risk-module-api.herokuapp.com/api/v1/exposed_elements",121 requestOptions122 )123 .then((response) => {124 const data = response.json();125 })126 .catch((error) => {127 console.error("Error!");128 });129 }130 render() {131 const that = this;132 return (133 <>134 <HeaderPrivate auth={that.props.auth} />135 <div class="h-screen">136 <div className={styles.menuRezilio}>137 <div class="d-flex flex-col justify-center items-center mx-4 mt-3 ">138 <SideBar139 auth={that.props.auth}140 idPage={this.props.match.params.id}141 />142 <div className={styles.fixMenu}>143 <div className={styles.createproject}>144 <div class="container-lg pt-4">145 <form onSubmit={this.submitForm.bind(this)}>146 <div class="d-flex justify-content-between">147 <h4 class="mb-4" className={styles.titleheader}>148 Exposed test #1 - Exposed Settings149 </h4>150 <Link151 to={buildUrl(152 "LIST_EXPOSED",153 this.props.match.params.id154 )}155 >156 <button class="btn btn-light ml-4 px-4" type="submit">157 Cancel158 </button>159 </Link>160 </div>161 {/* EXPOSED NAME */}162 <div class="mb-4 mt-3">163 <label for="exposedName" class="form-label">164 Exposed Name165 </label>166 <div class="">167 <input168 type="text"169 class="col-6"170 id="exposedName"171 onChange={this.handleChange.bind(172 this,173 "exposedName"174 )}175 value={this.state.fields["exposedName"]}176 />177 </div>178 <div>179 <span style={{ color: "red" }}>180 {this.state.errors["exposedName"]}181 </span>182 </div>183 </div>184 {/* EXPOSED DESCRIPTION */}185 <div class="mb-4 mt-3">186 <label for="exposedDescription" class="form-label">187 Exposed Description188 </label>189 <div class="">190 <input191 type="text"192 class="col-6"193 id="exposedDescription"194 onChange={this.handleChange.bind(195 this,196 "exposedDescription"197 )}198 value={this.state.fields["exposedDescription"]}199 />200 </div>201 <div>202 <span style={{ color: "red" }}>203 {this.state.errors["exposedDescription"]}204 </span>205 </div>206 </div>207 {/* EXPOSED TYPE */}208 <div class="mb-4 mt-3">209 <label for="exposedType" class="form-label">210 Exposed Type211 </label>212 <div class="">213 <input214 type="text"215 class="col-6"216 id="exposedType"217 onChange={this.handleChange.bind(218 this,219 "exposedType"220 )}221 value={this.state.fields["exposedType"]}222 />223 </div>224 <div>225 <span style={{ color: "red" }}>226 {this.state.errors["exposedType"]}227 </span>228 </div>229 </div>230 {/* EXPOSED IMPORTANCE */}231 <div class="mb-4 mt-3">232 <label for="exposedImportance" class="form-label">233 Exposed Importance234 </label>235 <div class="">236 <input237 type="text"238 class="col-6"239 id="exposedImportance"240 onChange={this.handleChange.bind(241 this,242 "exposedImportance"243 )}244 value={this.state.fields["exposedImportance"]}245 />246 </div>247 <div>248 <span style={{ color: "red" }}>249 {this.state.errors["exposedImportance"]}250 </span>251 </div>252 </div>253 {/* EXPOSED LOCATION */}254 <div class="mb-4 mt-3">255 <label for="exposedLocation" class="form-label">256 Exposed Location257 </label>258 <div class="">259 <input260 type="text"261 class="col-6"262 id="exposedLocation"263 onChange={this.handleChange.bind(264 this,265 "exposedLocation"266 )}267 value={this.state.fields["exposedLocation"]}268 />269 </div>270 <div>271 <span style={{ color: "red" }}>272 {this.state.errors["exposedLocation"]}273 </span>274 </div>275 </div>276 {/* EXPOSED RECOVERY */}277 <div class="mb-4 mt-3">278 <label for="exposedRecovery" class="form-label">279 Exposed Recovery Time280 </label>281 <div class="">282 <input283 type="number"284 class="col-6"285 id="exposedRecovery"286 onChange={this.handleChange.bind(287 this,288 "exposedRecovery"289 )}290 value={this.state.fields["exposedRecovery"]}291 />292 </div>293 <div>294 <span style={{ color: "red" }}>295 {this.state.errors["exposedRecovery"]}296 </span>297 </div>298 </div>299 {/* EXPOSED DOWN */}300 <div class="mb-4 mt-3">301 <label for="exposedDown" class="form-label">302 Exposed Down Time303 </label>304 <div class="">305 <input306 type="number"307 class="col-6"308 id="exposedDown"309 onChange={this.handleChange.bind(310 this,311 "exposedDown"312 )}313 value={this.state.fields["exposedDown"]}314 />315 </div>316 <div>317 <span style={{ color: "red" }}>318 {this.state.errors["exposedDown"]}319 </span>320 </div>321 </div>322 <br />323 <br />324 <button325 class="btn btn-primary ml-4 px-4"326 type="submit"327 className={styles.submitbutton}328 >329 Save330 </button>331 <br />332 <br />333 </form>334 </div>335 </div>336 </div>337 </div>338 </div>339 </div>340 <FooterPrivate />341 </>342 );343 }344}345function mapStateToProps(state) {346 return {347 profile: state.auth.profile,348 };349}...

Full Screen

Full Screen

entity_browser.view.js

Source:entity_browser.view.js Github

copy

Full Screen

1/**2 * @file entity_browser.view.js3 *4 * Defines the behavior of the entity browser's view widget.5 */6(function ($, Drupal, drupalSettings) {7 'use strict';8 /**9 * Registers behaviours related to view widget.10 */11 Drupal.behaviors.entityBrowserView = {12 attach: function (context) {13 // Add the AJAX to exposed forms.14 // We do this as the selector in core/modules/views/js/ajax_view.js15 // assumes that the form the exposed filters reside in has a16 // views-related ID, which ours does not.17 var views_instance = Drupal.views.instances[Object.keys(Drupal.views.instances)[0]];18 if (views_instance) {19 // Initialize the exposed form AJAX.20 views_instance.$exposed_form = $('div#views-exposed-form-' + views_instance.settings.view_name.replace(/_/g, '-') + '-' + views_instance.settings.view_display_id.replace(/_/g, '-'));21 views_instance.$exposed_form.once('exposed-form').each(jQuery.proxy(views_instance.attachExposedFormAjax, views_instance));22 // The form values form_id, form_token, and form_build_id will break23 // the exposed form. Remove them by splicing the end of form_values.24 if (views_instance.exposedFormAjax && views_instance.exposedFormAjax.length > 0) {25 var ajax = views_instance.exposedFormAjax[0];26 ajax.options.beforeSubmit = function (form_values, element_settings, options) {27 form_values = form_values.splice(form_values.length - 3, 3);28 ajax.ajaxing = true;29 return ajax.beforeSubmit(form_values, element_settings, options);30 };31 }32 // Handle Enter key press in the views exposed form text fields: ensure33 // that the correct button is used for the views exposed form submit.34 // The default browser behavior for the Enter key press is to click the35 // first found button. But there can be other buttons in the form, for36 // example, ones added by the Tabs widget selector plugin.37 views_instance.$exposed_form.once('submit-by-enter-key').find('input[type="text"]').each(function () {38 $(this).on('keypress', function (event) {39 if (event.keyCode == 13) {40 event.preventDefault();41 views_instance.$exposed_form.find('input[type="submit"]').first().click();42 }43 });44 });45 }46 }47 };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.getLocations(function(err, locations) {3 console.log(locations);4});5var wpt = require('wpt');6wpt.getLocations(function(err, locations) {7 console.log(locations);8});9var wpt = require('wpt');10wpt.getLocations(function(err, locations) {11 console.log(locations);12});13var wpt = require('wpt');14wpt.getLocations(function(err, locations) {15 console.log(locations);16});17var wpt = require('wpt');18wpt.getLocations(function(err, locations) {19 console.log(locations);20});21var wpt = require('wpt');22wpt.getLocations(function(err, locations) {23 console.log(locations);24});25var wpt = require('wpt');26wpt.getLocations(function(err, locations) {27 console.log(locations);28});29var wpt = require('wpt');30wpt.getLocations(function(err, locations) {31 console.log(locations);32});33var wpt = require('wpt');34wpt.getLocations(function(err, locations) {35 console.log(locations);36});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.getLocations(function(err, data) {3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2 console.log(result);3});4var wpt = require('webpagetest');5var wpt = new WebPageTest('www.webpagetest.org', 'A.8d8a9a9f3c9b3d3b8a3f0f6b1a6a2a2d');6exports.test = function(url, callback) {7 wpt.runTest(url, function(err, data) {8 if (err) {9 console.log(err);10 } else {11 callback(data);12 }13 });14};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2 if (err) {3 console.log(err);4 } else {5 console.log(data);6 }7});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful