How to use createContext method in wpt

Best JavaScript code snippet using wpt

createActionExecutor.spec.js

Source:createActionExecutor.spec.js Github

copy

Full Screen

1const expect = require('chai').expect2const sinon = require('sinon')3const Bluebird = require('bluebird')4const ActionStatus = require('../../src/constants').ActionStatus5const ImmediateResult = require('../../src/ImmediateResult')6const createActionExecutor = require('../../src/internal/createActionExecutor')7const ServiceActionNotFoundError = require('../../src/ServiceError/ServiceActionNotFoundError')8const waitTick = () => new Promise(resolve => setTimeout(resolve))9const waitTickBluebird = () => new Bluebird(resolve => setTimeout(resolve))10describe('core', () => {11 describe('createActionExecutor', () => {12 it('should throw error without required options', () => {13 expect(() => createActionExecutor({})).to.throw()14 expect(() => createActionExecutor({ createContext: () => ({}) })).to.throw()15 })16 it('should create a function', () => {17 const fn = createActionExecutor({18 createContext: () => ({}),19 execute: () => true20 })21 expect(typeof fn).to.equal('function')22 })23 it('should return a valid promise', async () => {24 const fn = createActionExecutor({25 createContext: () => ({}),26 execute: () => 'blabla'27 })28 const result = fn()29 expect(typeof result.then).to.equal('function')30 const resolvedResult = await result31 expect(resolvedResult).to.equal('blabla')32 })33 it('should pass execution data for context function', async () => {34 const createContext = sinon.fake.returns({})35 const fn = createActionExecutor({36 createContext: createContext,37 execute: () => true38 })39 await fn('some-name', { par: 'ams', papa: 'dams' }, { some: 'meta', data: null })40 expect(createContext.called).to.equal(true)41 expect(createContext.calledWith(42 'some-name',43 { par: 'ams', papa: 'dams' },44 { some: 'meta', data: null }45 )).to.equal(true)46 })47 it('should pass context to executor', async () => {48 const ctx = { a: 10, b: 20, c: 30 }49 const executor = sinon.fake.returns(true)50 const fn = createActionExecutor({51 createContext: () => ctx,52 execute: executor53 })54 await fn()55 expect(executor.called).to.equal(true)56 expect(executor.calledWith(ctx)).to.equal(true)57 })58 it('should pass context to each function down', async () => {59 const ctx = { a: 10, b: 20, c: 30 }60 const processor = sinon.fake.returns(null)61 const preExecutor = sinon.fake.returns(null)62 const executor = sinon.fake.returns(null)63 const finalizer = sinon.fake.returns(null)64 const resultProcessor = sinon.fake.returns(null)65 const fn = createActionExecutor({66 createContext: () => ctx,67 process: processor,68 preExecute: preExecutor,69 execute: executor,70 processResult: resultProcessor,71 finalizeContext: finalizer72 })73 await fn()74 expect(processor.called).to.equal(true)75 expect(processor.calledWith(ctx)).to.equal(true)76 expect(preExecutor.called).to.equal(true)77 expect(preExecutor.calledWith(ctx)).to.equal(true)78 expect(executor.called).to.equal(true)79 expect(executor.calledWith(ctx)).to.equal(true)80 expect(finalizer.called).to.equal(true)81 expect(finalizer.calledWith(ctx, null)).to.equal(true)82 expect(resultProcessor.called).to.equal(true)83 expect(resultProcessor.calledWith(null, ctx)).to.equal(true)84 })85 it('should properly execute function', async () => {86 const fn = createActionExecutor({87 createContext: (name, params) => ({ name, params }),88 execute: (ctx) => ctx.params.a + ctx.params.b89 })90 const result = await fn('bla', { a: 10, b: 20 })91 expect(result).to.equal(30)92 })93 it('should allow mutating context', async () => {94 const createContext = (name, params) => ({95 name: name,96 params: {97 a: params.a * 5,98 b: params.b * 599 }100 })101 const mutateContext = ctx => {102 ctx.params.a *= 2103 ctx.params.b *= 3104 }105 const fn = createActionExecutor({106 createContext: createContext,107 process: mutateContext,108 preExecute: mutateContext,109 execute: (ctx) => ctx.params.a + ctx.params.b110 })111 const result = await fn('bla', { a: 10, b: 20 })112 expect(result).to.equal(1100)113 })114 it('should allow processing result', async () => {115 const createContext = (name, params) => ({116 name: name,117 params: params118 })119 const fn = createActionExecutor({120 createContext: createContext,121 execute: (ctx) => ctx.params.a + ctx.params.b,122 processResult: (value, ctx) => `${value} ${ctx.name}`123 })124 const result = await fn('apples', { a: 10, b: 20 })125 expect(result).to.equal('30 apples')126 })127 it('should handle asynchronous paths', async () => {128 const createContext = (name, params) => ({129 name: name,130 params: params131 })132 const mutateContextAsynchronously = ctx => {133 return new Promise((resolve) => setTimeout(() => {134 ctx.params.a *= 2135 ctx.params.b *= 3136 resolve()137 }))138 }139 const fn = createActionExecutor({140 createContext: createContext,141 process: mutateContextAsynchronously,142 preExecute: mutateContextAsynchronously,143 execute: (ctx) => ctx.params.a + ctx.params.b144 })145 const result = await fn('bla', { a: 10, b: 20 })146 expect(result).to.equal(220)147 })148 it('should allow only selected methods', async () => {149 const isActionSupported = name => name === 'allowedName'150 const createContext = (name, params) => ({ name: name, params: params })151 const fn = createActionExecutor({152 isActionSupported: isActionSupported,153 createContext: createContext,154 execute: (ctx) => ctx.params.a + ctx.params.b155 })156 const success = sinon.fake()157 const failure = sinon.fake()158 await fn('bla', { a: 10, b: 20 })159 .then(success, failure)160 .catch(() => {})161 expect(success.called).to.equal(false)162 expect(failure.called).to.equal(true)163 expect(failure.lastArg instanceof ServiceActionNotFoundError).to.equal(true)164 const success2 = sinon.fake()165 const failure2 = sinon.fake()166 await fn('allowedName', { a: 10, b: 20 })167 .then(success2, failure2)168 .catch(() => {})169 expect(success2.called).to.equal(true)170 expect(failure2.called).to.equal(false)171 expect(success2.lastArg).to.equal(30)172 })173 it('should emit events on each step of action execution (success)', async () => {174 const context = { a: 10, b: 20 }175 const createContext = () => context176 const events = []177 const onActionStateChange = (state, context, value) => events.push({178 state: state,179 context: context,180 value: value181 })182 const fn = createActionExecutor({183 createContext: createContext,184 onActionStateChange: onActionStateChange,185 execute: (ctx) => ctx.a + ctx.b186 })187 await fn('bla')188 expect(events).to.deep.equal([189 { state: ActionStatus.CREATED, context: context, value: undefined },190 { state: ActionStatus.READY, context: context, value: undefined },191 { state: ActionStatus.EXECUTION, context: context, value: undefined },192 { state: ActionStatus.SUCCESS, context: context, value: 30 }193 ])194 })195 it('should emit events on each step of action execution (unknown action)', async () => {196 const context = { a: 10, b: 20 }197 const createContext = () => context198 const isActionSupported = name => name === 'allowedName'199 const events = []200 const onActionStateChange = (state, context, value) => events.push({201 state: state,202 context: context,203 value: value204 })205 const fn = createActionExecutor({206 isActionSupported: isActionSupported,207 createContext: createContext,208 onActionStateChange: onActionStateChange,209 execute: (ctx) => ctx.a + ctx.b210 })211 await fn('bla').catch(() => {})212 expect(events).to.deep.equal([213 { state: ActionStatus.CREATED, context: context, value: undefined },214 { state: ActionStatus.UNKNOWN, context: context, value: undefined }215 ])216 })217 it('should emit events on each step of action execution (failure)', async () => {218 const context = { a: 10, b: 20 }219 const createContext = () => context220 const events = []221 const onActionStateChange = (state, context, value) => events.push({222 state: state,223 context: context,224 value: value225 })226 const fn = createActionExecutor({227 createContext: createContext,228 onActionStateChange: onActionStateChange,229 execute: (ctx) => ctx.unknownProperty.a + ctx.b230 })231 await fn('bla').catch(() => {})232 expect(events.length).to.equal(4)233 expect(events[3].value instanceof TypeError).to.equal(true)234 expect(events).to.deep.equal([235 { state: ActionStatus.CREATED, context: context, value: undefined },236 { state: ActionStatus.READY, context: context, value: undefined },237 { state: ActionStatus.EXECUTION, context: context, value: undefined },238 { state: ActionStatus.ERROR, context: context, value: events[3].value }239 ])240 })241 it('should emit events on each step of action execution (faster failure)', async () => {242 const context = { a: 10, b: 20 }243 const createContext = () => context244 const events = []245 const onActionStateChange = (state, context, value) => events.push({246 state: state,247 context: context,248 value: value249 })250 const fn1 = createActionExecutor({251 createContext: createContext,252 onActionStateChange: onActionStateChange,253 process: (ctx) => ctx.unknownProperty.a + ctx.b,254 execute: (ctx) => ctx.a + ctx.b255 })256 await fn1('bla').catch(() => {})257 expect(events.length).to.equal(2)258 expect(events[1].value instanceof TypeError).to.equal(true)259 expect(events).to.deep.equal([260 { state: ActionStatus.CREATED, context: context, value: undefined },261 { state: ActionStatus.ERROR, context: context, value: events[1].value }262 ])263 const fn2 = createActionExecutor({264 createContext: createContext,265 onActionStateChange: onActionStateChange,266 preExecute: (ctx) => ctx.unknownProperty.a + ctx.b,267 execute: (ctx) => ctx.a + ctx.b268 })269 events.splice(0, events.length)270 await fn2('bla').catch(() => {})271 expect(events.length).to.equal(3)272 expect(events[2].value instanceof TypeError).to.equal(true)273 expect(events).to.deep.equal([274 { state: ActionStatus.CREATED, context: context, value: undefined },275 { state: ActionStatus.READY, context: context, value: undefined },276 { state: ActionStatus.ERROR, context: context, value: events[2].value }277 ])278 })279 it('should return result before action execution', async () => {280 const context = { a: 10, b: 20 }281 const createContext = () => context282 const events = []283 const onActionStateChange = (state, context, value) => events.push({284 state: state,285 context: context,286 value: value287 })288 const fn = createActionExecutor({289 createContext: createContext,290 onActionStateChange: onActionStateChange,291 process: () => { throw new ImmediateResult('something') },292 execute: (ctx) => ctx.a + ctx.b293 })294 const result1 = await fn('bla')295 expect(result1).to.equal('something')296 expect(events.length).to.equal(2)297 expect(events).to.deep.equal([298 { state: ActionStatus.CREATED, context: context, value: undefined },299 { state: ActionStatus.SUCCESS, context: context, value: 'something' }300 ])301 const asyncFn = createActionExecutor({302 createContext: createContext,303 onActionStateChange: onActionStateChange,304 preExecute: waitTick,305 process: () => { throw new ImmediateResult('something') },306 execute: (ctx) => ctx.a + ctx.b307 })308 events.splice(0, events.length)309 const result2 = await asyncFn('bla')310 expect(result2).to.equal('something')311 expect(events.length).to.equal(2)312 expect(events).to.deep.equal([313 { state: ActionStatus.CREATED, context: context, value: undefined },314 { state: ActionStatus.SUCCESS, context: context, value: 'something' }315 ])316 })317 it('should process immediate result', async () => {318 const context = { a: 10, b: 20 }319 const createContext = () => context320 const events = []321 const onActionStateChange = (state, context, value) => events.push({322 state: state,323 context: context,324 value: value325 })326 const fn = createActionExecutor({327 createContext: createContext,328 onActionStateChange: onActionStateChange,329 process: () => { throw new ImmediateResult('something') },330 processResult: (result) => `${result} there`,331 execute: (ctx) => ctx.a + ctx.b332 })333 const result = await fn('bla')334 expect(result).to.equal('something there')335 expect(events.length).to.equal(2)336 expect(events).to.deep.equal([337 { state: ActionStatus.CREATED, context: context, value: undefined },338 { state: ActionStatus.SUCCESS, context: context, value: 'something there' }339 ])340 })341 it('should choose proper Promise implementation', async () => {342 const context = { a: 10, b: 20 }343 const createContext = () => context344 const fn = createActionExecutor({345 Promise: Bluebird,346 createContext: createContext,347 processResult: (result) => `${result} there`,348 execute: (ctx) => ctx.a + ctx.b349 })350 const promise1 = fn('bla')351 await promise1352 expect(promise1 instanceof Bluebird).to.equal(true)353 const asyncFn = createActionExecutor({354 Promise: Bluebird,355 createContext: createContext,356 preExecute: waitTick,357 execute: (ctx) => ctx.a + ctx.b358 })359 const promise2 = asyncFn('bla')360 await promise2361 expect(promise2 instanceof Bluebird).to.equal(true)362 })363 it('could reuse Promise implementation sent inside', async () => {364 const context = { a: 10, b: 20 }365 const createContext = () => context366 const fn1 = createActionExecutor({367 ensurePromiseImplementation: false,368 Promise: Bluebird,369 preExecute: waitTick, // it will use native Promise370 createContext: createContext,371 execute: (ctx) => ctx.a + ctx.b372 })373 const promise1 = fn1('bla')374 await promise1375 expect(promise1 instanceof Promise).to.equal(true)376 const fn2 = createActionExecutor({377 ensurePromiseImplementation: false,378 Promise: Promise,379 preExecute: waitTickBluebird, // it will use Bluebird promises380 createContext: createContext,381 execute: (ctx) => ctx.a + ctx.b382 })383 const promise2 = fn2('bla')384 await promise2385 expect(promise2 instanceof Bluebird).to.equal(true)386 })387 it('should attach context to promise (success)', async () => {388 const context = { a: 10, b: 20 }389 const createContext = () => context390 const fn = createActionExecutor({391 createContext: createContext,392 execute: (ctx) => ctx.a + ctx.b393 })394 const promise = fn('bla')395 expect(promise.context).to.equal(context)396 await promise397 expect(promise.context).to.equal(context)398 })399 it('should not attach context to promise (success)', async () => {400 const context = { a: 10, b: 20 }401 const createContext = () => context402 const fn = createActionExecutor({403 includeContext: false,404 createContext: createContext,405 execute: (ctx) => ctx.a + ctx.b406 })407 const promise = fn('bla')408 expect(promise.context).to.equal(undefined)409 await promise410 expect(promise.context).to.equal(undefined)411 })412 it('should attach context to promise (unknown action)', async () => {413 const context = { a: 10, b: 20 }414 const createContext = () => context415 const isActionSupported = () => false416 const fn = createActionExecutor({417 isActionSupported: isActionSupported,418 createContext: createContext,419 execute: (ctx) => ctx.a + ctx.b420 })421 const promise = fn('bla')422 promise.catch(() => {})423 expect(promise.context).to.equal(context)424 await promise.catch(() => {})425 expect(promise.context).to.equal(context)426 })427 it('should not attach context to promise (unknown action)', async () => {428 const context = { a: 10, b: 20 }429 const createContext = () => context430 const isActionSupported = () => false431 const fn = createActionExecutor({432 includeContext: false,433 isActionSupported: isActionSupported,434 createContext: createContext,435 execute: (ctx) => ctx.a + ctx.b436 })437 const promise = fn('bla')438 promise.catch(() => {})439 expect(promise.context).to.equal(undefined)440 await promise.catch(() => {})441 expect(promise.context).to.equal(undefined)442 })443 it('should attach context to promise (failure)', async () => {444 const context = { a: 10, b: 20 }445 const createContext = () => context446 const fn = createActionExecutor({447 createContext: createContext,448 preExecute: () => { throw new Error() },449 execute: (ctx) => ctx.a + ctx.b450 })451 const promise = fn('bla')452 promise.catch(() => {})453 expect(promise.context).to.equal(context)454 await promise.catch(() => {})455 expect(promise.context).to.equal(context)456 })457 it('should not attach context to promise (failure)', async () => {458 const context = { a: 10, b: 20 }459 const createContext = () => context460 const fn = createActionExecutor({461 includeContext: false,462 createContext: createContext,463 preExecute: () => { throw new Error() },464 execute: (ctx) => ctx.a + ctx.b465 })466 const promise = fn('bla')467 promise.catch(() => {})468 expect(promise.context).to.equal(undefined)469 await promise.catch(() => {})470 expect(promise.context).to.equal(undefined)471 })472 it('should ignore uncaught error (within emitting events)', async () => {473 const context = { a: 10, b: 20 }474 const createContext = () => context475 const fn = createActionExecutor({476 includeContext: false,477 createContext: createContext,478 onActionStateChange: () => { throw new Error('Meh.') },479 execute: (ctx) => ctx.a + ctx.b480 })481 const result = await fn('bla')482 expect(result).to.equal(30)483 })484 it('should handle uncaught error (within emitting events)', async () => {485 const context = { a: 10, b: 20 }486 const createContext = () => context487 const onUncaughtError = sinon.fake()488 const fn = createActionExecutor({489 includeContext: false,490 createContext: createContext,491 onActionStateChange: () => { throw new Error('Meh.') },492 onUncaughtError: onUncaughtError,493 execute: (ctx) => ctx.a + ctx.b494 })495 const result = await fn('bla')496 expect(result).to.equal(30)497 expect(onUncaughtError.called).to.equal(true)498 expect(onUncaughtError.lastArg instanceof Error).to.equal(true)499 expect(onUncaughtError.lastArg.message).to.equal('Meh.')500 })501 })...

Full Screen

Full Screen

lisp.test.js

Source:lisp.test.js Github

copy

Full Screen

...11 console.log.mockRestore();12});13describe('evaluateExpression', () => {14 it('evaluates atoms', () => {15 expect(evaluateExpression(1, createContext())).toBe(1);16 expect(evaluateExpression(-101, createContext())).toBe(-101);17 expect(evaluateExpression(123.456, createContext())).toBe(123.456);18 expect(evaluateExpression(true, createContext())).toBe(true);19 expect(evaluateExpression(null, createContext())).toBe(null);20 });21 it('adds two numbers together', () => {22 expect(evaluateExpression(['+', 1, 2], createContext())).toBe(3);23 expect(evaluateExpression(['+', 0, 0], createContext())).toBe(0);24 expect(evaluateExpression(['+', 2.5, 8.6], createContext())).toBe(11.1);25 expect(evaluateExpression(['+', 2, -6], createContext())).toBe(-4);26 });27 it('adds lists of numbers together', () => {28 expect(evaluateExpression(['+', 1, 2, 3, 4], createContext())).toBe(10);29 expect(evaluateExpression(['+', 5], createContext())).toBe(5);30 expect(31 evaluateExpression(32 ['+', 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],33 createContext(),34 ),35 ).toBe(0);36 });37 it('subtracts numbers', () => {38 expect(evaluateExpression(['-', 10, 2], createContext())).toBe(8);39 expect(evaluateExpression(['-', 10, -2], createContext())).toBe(12);40 expect(evaluateExpression(['-', 10, 2, 3, 2], createContext())).toBe(3);41 });42 it('multiplies numbers', () => {43 expect(evaluateExpression(['*', 10, 2], createContext())).toBe(20);44 expect(evaluateExpression(['*', 10, -2], createContext())).toBe(-20);45 expect(evaluateExpression(['*', 10, 2, 2], createContext())).toBe(40);46 });47 it('divides numbers', () => {48 expect(evaluateExpression(['/', 10, 2], createContext())).toBe(5);49 expect(evaluateExpression(['/', 10, -2], createContext())).toBe(-5);50 expect(evaluateExpression(['/', 10, 2, 2], createContext())).toBe(2.5);51 });52 it('evaluates nested expressions', () => {53 expect(54 evaluateExpression(['+', ['+', 1, 2], ['+', 3, 4]], createContext()),55 ).toBe(10);56 expect(57 evaluateExpression(58 ['*', ['+', 1, 2, 3, 4], ['-', 10, 4]],59 createContext(),60 ),61 ).toBe(60);62 expect(63 evaluateExpression(64 ['*', ['+', 10, ['/', 100, 10]], ['-', ['+', 10, 5], 5]],65 createContext(),66 ),67 ).toBe(200);68 });69 describe('print', () => {70 it('calls console.log', () => {71 evaluateExpression(['print', 123], createContext());72 expect(console.log).toHaveBeenCalledTimes(1);73 expect(console.log).toHaveBeenLastCalledWith(123);74 });75 it('can be called with several arguments', () => {76 evaluateExpression(['print', 1, 2, 3], createContext());77 expect(console.log).toHaveBeenCalledTimes(1);78 expect(console.log).toHaveBeenLastCalledWith(1, 2, 3);79 });80 it('evaluates nested arguments', () => {81 evaluateExpression(['print', ['+', 5, ['*', 12, 5]]], createContext());82 expect(console.log).toHaveBeenCalledTimes(1);83 expect(console.log).toHaveBeenLastCalledWith(65);84 });85 it('returns undefined', () => {86 expect(evaluateExpression(['print', 0], createContext())).toBe(undefined);87 });88 });89 describe('if', () => {90 it('returns the correct branch based on a condition', () => {91 const expr1 = ['if', true, ['+', 0, 1], ['*', 10, 2]];92 expect(evaluateExpression(expr1, createContext())).toBe(1);93 const expr2 = ['if', false, ['+', 0, 1], ['*', 10, 2]];94 expect(evaluateExpression(expr2, createContext())).toBe(20);95 });96 it('evaluates the condition as an expression', () => {97 expect(98 evaluateExpression(['if', ['+', 1, 1], 1, 2], createContext()),99 ).toBe(1);100 expect(101 evaluateExpression(['if', ['+', 1, -1], 1, 2], createContext()),102 ).toBe(2);103 });104 it('only evaluates one branch', () => {105 evaluateExpression(106 ['if', true, ['print', 1], ['print', 2]],107 createContext(),108 );109 expect(console.log).toHaveBeenCalledTimes(1);110 expect(console.log).toHaveBeenLastCalledWith(1);111 evaluateExpression(112 ['if', false, ['print', 1], ['print', 2]],113 createContext(),114 );115 expect(console.log).toHaveBeenCalledTimes(2);116 expect(console.log).toHaveBeenLastCalledWith(2);117 });118 it('returns undefined if condition is not met with no else-branch', () => {119 expect(evaluateExpression(['if', false, 1], createContext())).toBe(120 undefined,121 );122 });123 });124});125describe('evaluateProgram', () => {126 it('evaluates a sequence of expressions', () => {127 evaluateProgram(128 [129 ['print', ['+', 2, 2]],130 ['if', true, ['print', 1], ['print', 2]],131 ['print', 123, 456, 789],132 ],133 createContext(),134 );135 expect(console.log.mock.calls).toEqual([[4], [1], [123, 456, 789]]);136 });137});138describe('createContext', () => {139 it('retrieves defined variables', () => {140 const context = createContext();141 context.define('x', 13);142 context.define('myAge', 25);143 expect(context.get('x')).toBe(13);144 expect(context.get('myAge')).toBe(25);145 });146 it('overwrites pre-defined variables', () => {147 const context = createContext();148 context.define('x', 13);149 expect(context.get('x')).toBe(13);150 context.define('x', 26);151 expect(context.get('x')).toBe(26);152 });153 it('throws an error when a variable is not defined', () => {154 const context = createContext();155 expect(() => context.get('x')).toThrowError('x is not defined');156 });...

Full Screen

Full Screen

contexts.js

Source:contexts.js Github

copy

Full Screen

1import { createContext } from 'react'2//for app.js3export const BrightThemeContext = createContext(false)4export const FirstnameContext = createContext({ firstname: null, setFirstname: _ => {} })5export const UserIdContext = createContext(null)6export const IsAuthContext = createContext(false)7export const UnseenMsgsContext = createContext({ set: _ => {}, messages: 0 })8export const IncomingReqsContext = createContext({ set: _ => {}, requests: 0 })9export const LogoutHandlerContext = createContext(_ => {})10export const LoginHandlerContext = createContext(_ => {})11export const AcceptEmailContext = createContext(_ => {})12export const ToggleThemeContext = createContext(_ => {}) 13export const SignalContext = createContext(null)14export const SetTodoToDeleteContext = createContext(_ => {})15export const YourTodoContext = createContext(null)16export const CloseModalContext = createContext(_ => {})17export const SetNewTodoContext = createContext(_ => {})18export const TodoStatsContext = createContext({})19export const SetTodoToUpdateContext = createContext({})20export const TodoToUpdateContext = createContext({value : {}, unset: _ => {}})21export const OpenModalContext = createContext(_ => {})22export const PassTodoDataContext = createContext(_ => {})23export const TodoDataContext = createContext({})24export const UserDataContext = createContext({})25export const EditUserContext = createContext('')26export const SetEditUserContext = createContext({ value: '', set: _ => {} })27export const SetUpdatedUserContext = createContext(_ => {})28export const ViewUserStatsContext = createContext({ value: '', set: _ => {} })29export const SetItemToDeleteContext = createContext(_ => {})30export const DecreaseUserStatsContext = createContext(_ => {})31export const IncreaseUserStatsContext = createContext(_ => {})32export const UnfollowUserContext = createContext(_ => {})33export const SetBlockingUserContext = createContext(_ => {})34export const FollowControlsContext = createContext(null)35export const ConversationsContext = createContext({ convs: [], total: null })36export const LoadingContext = createContext(false)37export const PageContext = createContext({ page: 1, setPage: _ => {} })38export const HasNextPageContext = createContext({ has: false, set: _ => {} })39export const SetConvToDeleteContext = createContext(_ => {})40export const SetConvToEditContext = createContext(_ => {})41export const SetConvToAddContext = createContext(_ => {})42export const CurrentlyOpenedConvContext = createContext({ value: null, set: _ => {}})43export const QuitHandlerContext = createContext(_ => {})44export const ReceiverContext = createContext('')45export const SetMessageContext = createContext({})46export const SetMessageToEditLocallyContext = createContext({ value: null, set: _ => {} })47//export...

Full Screen

Full Screen

ContextFile.js

Source:ContextFile.js Github

copy

Full Screen

1import { createContext } from "react";2export const UserLatContext = createContext();3export const UserLngContext = createContext();4export const FormRequestContext = createContext();5const UserContext = createContext();6export default UserContext;7export const AllRequestContext = createContext();8export const FirstNameContext = createContext();9export const UserIdContext = createContext();10export const RequestOwnerContext = createContext();11export const AllVolunteerContext = createContext();12export const RequestIdContext = createContext();13export const ReqOwnerFirstNameContext = createContext();14export const ChatContext = createContext();15export const AllMessagesContext = createContext();16export const AllRoomContext = createContext();17export const SelectedRoomContext = createContext();18export const SelectedChatContext = createContext();19export const SelectedReqDescContext = createContext();20export const SelectedRequestContext = createContext();21export const ChatRoomIdContext = createContext();22export const AllUserIdContext = createContext();23export const RequestOwnerIdContext = createContext();24export const CurrentRoomContext = createContext();25export const UserClickedRequest = createContext();26export const SameUserClickCount = createContext();27export const PannedMapContext = createContext()28export const RequestFormContext = createContext();29export const CurrentVolunteerContext = createContext();30export const DeactivateContext = createContext();31export const RepublishRequestContext = createContext();32export const RoomToRepublishContext = createContext()33export const RepublishingContext = createContext()34// for chat 35export const CurrentUserContext = createContext();36export const RoomDataContext = createContext();37export const HelperTextContext = createContext();...

Full Screen

Full Screen

contextObjects.js

Source:contextObjects.js Github

copy

Full Screen

1import React from 'react'2// INITIALIZATION OF CONTEXT OBJECTS - FOR HEADERS3export const CurrentUser = React.createContext({});4export const LoginBarToggle = React.createContext('');5export const StoreIdContext = React.createContext('');6export const StoreAddressContext = React.createContext('');7export const StorePhoneContext = React.createContext('');8export const StoreHoursContext = React.createContext('');9export const StoreExchangePolicyContext = React.createContext('');10export const InstagramContext = React.createContext('');11// INITIALIZATION OF CONTEXT OBJECTS - FOR PRICES12export const ChildrensPriceContext = React.createContext('');13export const HardcoverPriceContext = React.createContext('');14export const SoftcoverPriceContext = React.createContext('');15export const AlbumsPriceContext = React.createContext('');16export const CdsPriceContext = React.createContext('');17export const DvdsPriceContext = React.createContext('');18export const SetsPriceContext = React.createContext('');...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import { createContext } from 'react';2export const AuthUserContext = createContext();3export const ContentContext = createContext();4export const CategoryContext = createContext();5export const FirebaseContext = createContext();6export const OptFormEmailContext = createContext();7export const ProfileContext = createContext();8export const ProfileListContext = createContext();9export const SetAuthUserContext = createContext();10export const SetCategoryContext = createContext();11export const SetContentContext = createContext();12export const SetOptFormEmailContext = createContext();13export const SetProfileContext = createContext();14export const SetProfileListContext = createContext();15export const SetTermContext = createContext();...

Full Screen

Full Screen

context.js

Source:context.js Github

copy

Full Screen

1import React from 'react';2export const AuthContext = React.createContext();3// export const DataContext = React.createContext();4export const CommandContext = React.createContext();5export const ShowDataOpen = React.createContext();6export const DataStatusContext = React.createContext();7export const ImpContext = React.createContext();8export const BoundAddress = React.createContext();9export const Loading = React.createContext();10export const PairedDs = React.createContext();11export const FoundDs = React.createContext();12export const BleOpend = React.createContext();13export const Name = React.createContext();...

Full Screen

Full Screen

state.js

Source:state.js Github

copy

Full Screen

1import { createContext } from "react";2export const DeleteFunc = createContext();3export const EditTask = createContext();4export const AddNewTask = createContext();5export const ArrForList = createContext();6export const NewInput = createContext();7export const NewUpdate = createContext();8export const NewDoneLine = createContext();9export const ContextImportant = createContext();10export const UpdateLine = createContext();11export const DoneOnly = createContext();12export const CansleObject = createContext();13export const ArrNew = createContext();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var context = wpt.createContext('www.webpagetest.org');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('webpagetest');2var context = wpt.createContext('www.webpagetest.org');3 if (err) return console.error(err);4 console.log(data);5});6#### `wpt.createContext(options)`7* `server` - the URL of the WebPageTest server to use (default: `www.webpagetest.org`)8* `key` - the API key to use (default: none)9* `timeout` - the timeout for requests to the WebPageTest server (default: 60000)10* `headers` - the headers to send with requests to the WebPageTest server (default: none)11#### `context.runTest(url, [options], callback)`12* `location` - the location to run the test from (default: `Dulles:Chrome`)13* `connectivity` - the connectivity profile to use for the test (default: none)14* `firstViewOnly` - run only the first view of the test (default: false)15* `runs` - the number of test runs to complete (default: 1)16* `pollResults` - poll for test results after the test completes (default: true)17* `timeout` - the timeout for the test (default: none)18* `video` - capture video of the test (default: false)19* `mobile` - run the test on a mobile device (default: false)20* `noExternals` - block external requests (default: false)21* `label` - assign a label to the test (default: none)22* `private` - keep the test private (default: false)23* `web10` - use Web10 for the test (default: false)24* `timeline` - capture a timeline trace of the test (default: false)25* `spof` - simulate a single point of failure (default: false)26* `ignoreSSL` - ignore SSL errors (default: false)27* `basicAuth` - basic authentication credentials (default: none)28* `script` - the script to run for the test (

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptb = require('wptb');2var context = wptb.createContext();3var wptb = require('wptb');4var context = wptb.createContext();5var wptb = require('wptb');6var context = wptb.createContext();7var wptb = require('wptb');8var context = wptb.createContext();9var wptb = require('wptb');10var context = wptb.createContext();11var wptb = require('wptb');12var context = wptb.createContext();13var wptb = require('wptb');14var context = wptb.createContext();15var wptb = require('wptb');16var context = wptb.createContext();17var wptb = require('wptb');18var context = wptb.createContext();19var wptb = require('wptb');20var context = wptb.createContext();21var wptb = require('wptb');22var context = wptb.createContext();23var wptb = require('wptb');24var context = wptb.createContext();25var wptb = require('wptb');

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptool = require('wptool');2const context = wptool.createContext();3context.close();4### wptool.createContext()5#### Context.close()6### Context.getSiteInfo()7const wptool = require('wptool');8const context = wptool.createContext();9context.getSiteInfo().then((info) => {10 console.log('Site info: ', info);11}).catch((err) => {12 console.error('Error: ', err);13}).finally(() => {14 context.close();15});16Site info: {17 namespaces: {18 },19 users: {20 '1': {

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