How to use startChain method in ava

Best JavaScript code snippet using ava

test_framework.js

Source:test_framework.js Github

copy

Full Screen

...63 app.testChainOfEvents = [];64 });65 it("should perform a chain's action", function() {66 var spy = spyOn(app.funcs, 'action');67 fw.startChain(app.testChainOfEvents);68 expect(spy).toHaveBeenCalledWith(0);69 expect(spy.callCount).toBe(1);70 });71 it("should perform a chain's fail method if the action fails", function() {72 var spy = spyOn(app.funcs, 'fail');73 fw.startChain(app.testChainOfEvents);74 app.act[0].reject();75 expect(spy).toHaveBeenCalledWith(0);76 expect(spy.callCount).toBe(1);77 });78 it("should perform a chain's done method if the action is successful", function() {79 var spy = spyOn(app.funcs, 'done');80 fw.startChain(app.testChainOfEvents);81 app.act[0].resolve();82 expect(spy).toHaveBeenCalledWith(0);83 expect(spy.callCount).toBe(1);84 });85 it("should move on to the next step if an action is successful", function() {86 var spy = spyOn(app.funcs, 'action').andCallThrough();87 fw.startChain(app.testChainOfEvents);88 app.act[0].resolve();89 expect(spy.mostRecentCall.args[0]).toBe(1);90 expect(spy.callCount).toBe(2);91 });92 it("should move on to the next step if a skipIf condition is true", function() {93 var spy = spyOn(app.funcs, 'action').andCallThrough();94 app.testChainOfEvents[0].preReq = ['skipIf', true];95 fw.startChain(app.testChainOfEvents);96 expect(spy.mostRecentCall.args[0]).toBe(1);97 expect(spy.callCount).toBe(1);98 delete app.testChainOfEvents[0].preReq;99 });100 it("should move on to the next step if a skipUnless condition is false", function() {101 var spy = spyOn(app.funcs, 'action').andCallThrough();102 app.testChainOfEvents[0].preReq = ['skipUnless', false];103 fw.startChain(app.testChainOfEvents);104 expect(spy.mostRecentCall.args[0]).toBe(1);105 expect(spy.callCount).toBe(1);106 delete app.testChainOfEvents[0].preReq;107 });108 it("should abort if an abortIf condition is true", function() {109 var spy = spyOn(app.funcs, 'action').andCallThrough();110 app.testChainOfEvents[0].preReq = ['abortIf', true];111 fw.startChain(app.testChainOfEvents);112 expect(spy.callCount).toBe(0);113 delete app.testChainOfEvents[0].preReq;114 });115 it("should abort if an abortUnless condition is false", function() {116 var spy = spyOn(app.funcs, 'action').andCallThrough();117 app.testChainOfEvents[0].preReq = ['abortUnless', false];118 fw.startChain(app.testChainOfEvents);119 expect(spy.callCount).toBe(0);120 delete app.testChainOfEvents[0].preReq;121 });122 it("should pass the server response to the done function on success", function() {123 var spy = spyOn(app.testChainOfEvents[0], 'done');124 fw.startChain(app.testChainOfEvents);125 app.act[0].resolve('testy');126 expect(spy).toHaveBeenCalledWith('testy');127 expect(spy.callCount).toBe(1);128 });129 it("should abort if a step fails", function() {130 var spy = spyOn(app.funcs, 'action').andCallThrough();131 fw.startChain(app.testChainOfEvents);132 app.act[0].reject();133 expect(spy.callCount).toBe(1); // First action was called, second wasn't134 });135 });...

Full Screen

Full Screen

create-chain.js

Source:create-chain.js Github

copy

Full Screen

1'use strict';2const chainRegistry = new WeakMap();3function startChain(name, call, defaults) {4 const fn = (...args) => {5 call({...defaults}, args);6 };7 Object.defineProperty(fn, 'name', {value: name});8 chainRegistry.set(fn, {call, defaults, fullName: name});9 return fn;10}11function extendChain(previous, name, flag) {12 if (!flag) {13 flag = name;14 }15 const fn = (...args) => {16 callWithFlag(previous, flag, args);17 };18 const fullName = `${chainRegistry.get(previous).fullName}.${name}`;19 Object.defineProperty(fn, 'name', {value: fullName});20 previous[name] = fn;21 chainRegistry.set(fn, {flag, fullName, prev: previous});22 return fn;23}24function callWithFlag(previous, flag, args) {25 const combinedFlags = {[flag]: true};26 do {27 const step = chainRegistry.get(previous);28 if (step.call) {29 step.call({...step.defaults, ...combinedFlags}, args);30 previous = null;31 } else {32 combinedFlags[step.flag] = true;33 previous = step.prev;34 }35 } while (previous);36}37function createHookChain(hook, isAfterHook) {38 // Hook chaining rules:39 // * `always` comes immediately after "after hooks"40 // * `skip` must come at the end41 // * no `only`42 // * no repeating43 extendChain(hook, 'cb', 'callback');44 extendChain(hook, 'skip', 'skipped');45 extendChain(hook.cb, 'skip', 'skipped');46 if (isAfterHook) {47 extendChain(hook, 'always');48 extendChain(hook.always, 'cb', 'callback');49 extendChain(hook.always, 'skip', 'skipped');50 extendChain(hook.always.cb, 'skip', 'skipped');51 }52 return hook;53}54function createChain(fn, defaults, meta) {55 // Test chaining rules:56 // * `serial` must come at the start57 // * `only` and `skip` must come at the end58 // * `failing` must come at the end, but can be followed by `only` and `skip`59 // * `only` and `skip` cannot be chained together60 // * no repeating61 const root = startChain('test', fn, {...defaults, type: 'test'});62 extendChain(root, 'cb', 'callback');63 extendChain(root, 'failing');64 extendChain(root, 'only', 'exclusive');65 extendChain(root, 'serial');66 extendChain(root, 'skip', 'skipped');67 extendChain(root.cb, 'failing');68 extendChain(root.cb, 'only', 'exclusive');69 extendChain(root.cb, 'skip', 'skipped');70 extendChain(root.cb.failing, 'only', 'exclusive');71 extendChain(root.cb.failing, 'skip', 'skipped');72 extendChain(root.failing, 'only', 'exclusive');73 extendChain(root.failing, 'skip', 'skipped');74 extendChain(root.serial, 'cb', 'callback');75 extendChain(root.serial, 'failing');76 extendChain(root.serial, 'only', 'exclusive');77 extendChain(root.serial, 'skip', 'skipped');78 extendChain(root.serial.cb, 'failing');79 extendChain(root.serial.cb, 'only', 'exclusive');80 extendChain(root.serial.cb, 'skip', 'skipped');81 extendChain(root.serial.cb.failing, 'only', 'exclusive');82 extendChain(root.serial.cb.failing, 'skip', 'skipped');83 extendChain(root.serial.failing, 'only', 'exclusive');84 extendChain(root.serial.failing, 'skip', 'skipped');85 root.after = createHookChain(startChain('test.after', fn, {...defaults, type: 'after'}), true);86 root.afterEach = createHookChain(startChain('test.afterEach', fn, {...defaults, type: 'afterEach'}), true);87 root.before = createHookChain(startChain('test.before', fn, {...defaults, type: 'before'}), false);88 root.beforeEach = createHookChain(startChain('test.beforeEach', fn, {...defaults, type: 'beforeEach'}), false);89 root.serial.after = createHookChain(startChain('test.after', fn, {...defaults, serial: true, type: 'after'}), true);90 root.serial.afterEach = createHookChain(startChain('test.afterEach', fn, {...defaults, serial: true, type: 'afterEach'}), true);91 root.serial.before = createHookChain(startChain('test.before', fn, {...defaults, serial: true, type: 'before'}), false);92 root.serial.beforeEach = createHookChain(startChain('test.beforeEach', fn, {...defaults, serial: true, type: 'beforeEach'}), false);93 // "todo" tests cannot be chained. Allow todo tests to be flagged as needing94 // to be serial.95 root.todo = startChain('test.todo', fn, {...defaults, type: 'test', todo: true});96 root.serial.todo = startChain('test.serial.todo', fn, {...defaults, serial: true, type: 'test', todo: true});97 root.meta = meta;98 return root;99}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Avalanche, BinTools, BN } = require("avalanche")2const avm = require("avalanche/dist/apis/avm")3const platformvm = require("avalanche/dist/apis/platformvm")4const { Buffer } = require("buffer/")5const fs = require("fs")6const path = require("path")7const bintools = BinTools.getInstance()8const main = async () => {9 const avalanche = new Avalanche(ip, port, protocol, 12345)10 const xKeychain = xchain.keyChain()11 const cKeychain = cchain.keyChain()12 const pKeychain = pchain.keyChain()13 const nKeychain = nchain.keyChain()14 const xChainBlockchainID = await xchain.getBlockchainID()15 const cChainBlockchainID = await cchain.getBlockchainID()16 const pChainBlockchainID = await pchain.getBlockchainID()17 const nChainBlockchainID = await nchain.getBlockchainID()18 const xChainAlias = xchain.getBlockchainAlias()19 const cChainAlias = cchain.getBlockchainAlias()20 const pChainAlias = pchain.getBlockchainAlias()21 const nChainAlias = nchain.getBlockchainAlias()22 const xChainNetworkID = xchain.getNetworkID()23 const cChainNetworkID = cchain.getNetworkID()24 const pChainNetworkID = pchain.getNetworkID()25 const nChainNetworkID = nchain.getNetworkID()26 const xChainSubnetID = xchain.getSubnetID()27 const cChainSubnetID = cchain.getSubnetID()28 const pChainSubnetID = pchain.getSubnetID()

Full Screen

Using AI Code Generation

copy

Full Screen

1const { startChain } = require("./startChain");2const { AVMAPI, KeyChain, BinTools, BN, Buffer } = require("avalanche");3const { OutputOwners } = require("avalanche/dist/apis/avm/outputs");4const { UTXOSet } = require("avalanche/dist/apis/avm/utxos");5const { UnsignedTx } = require("avalanche/dist/apis/avm/unsignedtx");6const { SECPTransferOutput } = require("avalanche/dist/apis/avm/outputs");7const { InitialStates } = require("avalanche/dist/apis/avm/initialstates");8const { SECPMintOutput } = require("avalanche/dist/apis/avm/outputs");9const { SECPTransferInput } = require("avalanche/dist/apis/avm/inputs");10const { TransferableInput } = require("avalanche/dist/apis/avm/transferableinput");11const { TransferableOutput } = require("avalanche/dist/apis/avm/transferableoutput");12const { TransferableOperation } = require("avalanche/dist/apis/avm/transferableoperation");13const { OperationTx } = require("avalanche/dist/apis/avm/operationtx");14const { Tx } = require("avalanche/dist/apis/avm/tx");15const { StandardUTXO } = require("avalanche/dist/apis/avm/utxos");16const { StandardAssetAmountDestination } = require("avalanche/dist/apis/avm/outputs");17const { AVMConstants } = require("avalanche/dist/apis/avm/constants");18const { UnixNow } = require("avalanche/dist/utils");19const { AVMKeyChain } = require("avalanche/dist/apis/avm/keychain");20const { AVMU } = require("avalanche/dist/utils");21const { Defaults } = require("avalanche/dist/utils");22const { PayloadBase } = require("avalanche/dist/utils");23const { SelectCredentialClass } = require("avalanche/dist/utils");24const { Credential } = require("avalanche/dist/utils/credentials");25const { SignatureIdx } = require("avalanche/dist/utils");26const { StandardUTXOID } = require("avalanche/dist/apis/avm/utxos");27const { UnixEpochTime } = require("avalanche/dist/utils");28const { UnixTime } = require("avalanche/dist/utils");29const { UnixTimeSeconds

Full Screen

Using AI Code Generation

copy

Full Screen

1var availableChaincode = require('./availableChaincode.js');2var startChain = availableChaincode.startChain();3var availableChaincode = require('./availableChaincode.js');4var startChain = availableChaincode.startChain();5var availableChaincode = require('./availableChaincode.js');6var startChain = availableChaincode.startChain();7var availableChaincode = require('./availableChaincode.js');8var startChain = availableChaincode.startChain();9var availableChaincode = require('./availableChaincode.js');10var startChain = availableChaincode.startChain();11var availableChaincode = require('./availableChaincode.js');12var startChain = availableChaincode.startChain();13var availableChaincode = require('./availableChaincode.js');14var startChain = availableChaincode.startChain();15var availableChaincode = require('./availableChaincode.js');16var startChain = availableChaincode.startChain();17var availableChaincode = require('./availableChaincode.js');18var startChain = availableChaincode.startChain();19var availableChaincode = require('./availableChaincode.js');20var startChain = availableChaincode.startChain();21var availableChaincode = require('./availableChaincode.js');22var startChain = availableChaincode.startChain();23var availableChaincode = require('./availableChaincode.js');24var startChain = availableChaincode.startChain();25var availableChaincode = require('./availableChaincode.js');26var startChain = availableChaincode.startChain();27var availableChaincode = require('./availableChaincode.js');28var startChain = availableChaincode.startChain();29var availableChaincode = require('./availableChaincode.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1var avalon = require('avalon');2var chain = avalon.startChain();3 .add('test1', function(done) {4 console.log('test1');5 done();6 })7 .add('test2', function(done) {8 console.log('test2');9 done();10 })11 .add('test3', function(done) {12 console.log('test3');13 done();14 })15 .run();16var avalon = require('avalon');17var chain = avalon.startChain();18 .add('test1', function(done) {19 console.log('test1');20 done();21 })22 .add('test2', function(done) {23 console.log('test2');24 done();25 })26 .add('test3', function(done) {27 console.log('test3');28 done();29 })30 .run();31var avalon = require('avalon');32var chain = avalon.startChain();33 .add('test1', function(done) {34 console.log('test1');35 done();36 })37 .add('test2', function(done) {38 console.log('test2');39 done();40 })41 .add('test3', function(done) {42 console.log('test3');43 done();44 })45 .run();46var avalon = require('avalon');47var chain = avalon.startChain();48 .add('test1', function(done) {49 console.log('test1');50 done();51 })52 .add('test2', function(done) {53 console.log('test2');54 done();55 })56 .add('test3', function(done) {

Full Screen

Using AI Code Generation

copy

Full Screen

1const availableBlock = require('./availableBlock.js');2const availableCoin = require('./availableCoin.js');3const availableTransaction = require('./availableTransaction.js');4const availableWallet = require('./availableWallet.js');5const availableWalletTransaction = require('./availableWalletTransaction.js');6const availableWalletBlock = require('./availableWalletBlock.js');7const myBlock = new availableBlock();8myBlock.startChain();9const myCoin = new availableCoin();10myCoin.startChain();11const myTransaction = new availableTransaction();12myTransaction.startChain();13const myWallet = new availableWallet();14myWallet.startChain();15const myWalletTransaction = new availableWalletTransaction();16myWalletTransaction.startChain();17const myWalletBlock = new availableWalletBlock();18myWalletBlock.startChain();

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 ava 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