Best Python code snippet using responses
Interpolant.tests.js
Source:Interpolant.tests.js  
1/* global QUnit */2import { Interpolant } from '../../../../src/math/Interpolant';3export default QUnit.module( 'Maths', () => {4	QUnit.module( 'Interpolant', () => {5		// Since this is an abstract base class, we have to make it concrete in order6		// to QUnit.test its functionality...7		class Mock extends Interpolant {8			constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) {9				super( parameterPositions, sampleValues, sampleSize, resultBuffer );10			}11		}12		Mock.prototype.intervalChanged_ = function intervalChanged( i1, t0, t1 ) {13			if ( Mock.calls !== null ) {14				Mock.calls.push( {15					func: 'intervalChanged',16					args: [ i1, t0, t1 ]17				} );18			}19		};20		Mock.prototype.interpolate_ = function interpolate( i1, t0, t, t1 ) {21			if ( Mock.calls !== null ) {22				Mock.calls.push( {23					func: 'interpolate',24					args: [ i1, t0, t, t1 ]25				} );26			}27			return this.copySampleValue_( i1 - 1 );28		};29		Mock.prototype.beforeStart_ = function beforeStart( i, t, t0 ) {30			if ( Mock.calls !== null ) {31				Mock.calls.push( {32					func: 'beforeStart',33					args: [ i, t, t0 ]34				} );35			}36			return this.copySampleValue_( i );37		};38		Mock.prototype.afterEnd_ = function afterEnd( i, tN, t ) {39			if ( Mock.calls !== null ) {40				Mock.calls.push( {41					func: 'afterEnd',42					args: [ i, tN, t ]43				} );44			}45			return this.copySampleValue_( i );46		};47		// Call capturing facility48		Mock.calls = null;49		Mock.captureCall = function ( args ) {50			if ( Mock.calls !== null ) {51				Mock.calls.push( {52					func: Mock.captureCall.caller.name,53					args: Array.prototype.slice.call( args )54				} );55			}56		};57		// Tests58		// INSTANCING59		QUnit.todo( "Instancing", ( assert ) => {60			assert.ok( false, "everything's gonna be alright" );61		} );62		// PUBLIC STUFF63		QUnit.todo( "evaluate", ( assert ) => {64			assert.ok( false, "everything's gonna be alright" );65		} );66		// PRIVATE STUFF67		QUnit.test( "copySampleValue_", ( assert ) => {68			var interpolant = new Mock( null, [ 1, 11, 2, 22, 3, 33 ], 2, [] );69			assert.deepEqual( interpolant.copySampleValue_( 0 ), [ 1, 11 ], "sample fetch (0)" );70			assert.deepEqual( interpolant.copySampleValue_( 1 ), [ 2, 22 ], "sample fetch (1)" );71			assert.deepEqual( interpolant.copySampleValue_( 2 ), [ 3, 33 ], "first sample (2)" );72		} );73		QUnit.test( "evaluate -> intervalChanged_ / interpolate_", ( assert ) => {74			var actual, expect;75			var interpolant = new Mock( [ 11, 22, 33, 44, 55, 66, 77, 88, 99 ], null, 0, null );76			Mock.calls = [];77			interpolant.evaluate( 11 );78			actual = Mock.calls[ 0 ];79			expect = {80				func: 'intervalChanged',81				args: [ 1, 11, 22 ]82			};83			assert.deepEqual( actual, expect, JSON.stringify( expect ) );84			actual = Mock.calls[ 1 ];85			expect = {86				func: 'interpolate',87				args: [ 1, 11, 11, 22 ]88			};89			assert.deepEqual( actual, expect, JSON.stringify( expect ) );90			assert.ok( Mock.calls.length === 2, "no further calls" );91			Mock.calls = [];92			interpolant.evaluate( 12 ); // same interval93			actual = Mock.calls[ 0 ];94			expect = {95				func: 'interpolate',96				args: [ 1, 11, 12, 22 ]97			};98			assert.deepEqual( actual, expect, JSON.stringify( expect ) );99			assert.ok( Mock.calls.length === 1, "no further calls" );100			Mock.calls = [];101			interpolant.evaluate( 22 ); // step forward102			actual = Mock.calls[ 0 ];103			expect = {104				func: 'intervalChanged',105				args: [ 2, 22, 33 ]106			};107			assert.deepEqual( actual, expect, JSON.stringify( expect ) );108			actual = Mock.calls[ 1 ];109			expect = {110				func: 'interpolate',111				args: [ 2, 22, 22, 33 ]112			};113			assert.deepEqual( actual, expect, JSON.stringify( expect ) );114			assert.ok( Mock.calls.length === 2 );115			Mock.calls = [];116			interpolant.evaluate( 21 ); // step back117			actual = Mock.calls[ 0 ];118			expect = {119				func: 'intervalChanged',120				args: [ 1, 11, 22 ]121			};122			assert.deepEqual( actual, expect, JSON.stringify( expect ) );123			actual = Mock.calls[ 1 ];124			expect = {125				func: 'interpolate',126				args: [ 1, 11, 21, 22 ]127			};128			assert.deepEqual( actual, expect, JSON.stringify( expect ) );129			assert.ok( Mock.calls.length === 2, "no further calls" );130			Mock.calls = [];131			interpolant.evaluate( 20 ); // same interval132			actual = Mock.calls[ 0 ];133			expect = {134				func: 'interpolate',135				args: [ 1, 11, 20, 22 ]136			};137			assert.deepEqual( actual, expect, JSON.stringify( expect ) );138			assert.ok( Mock.calls.length === 1, "no further calls" );139			Mock.calls = [];140			interpolant.evaluate( 43 ); // two steps forward141			actual = Mock.calls[ 0 ];142			expect = {143				func: 'intervalChanged',144				args: [ 3, 33, 44 ]145			};146			assert.deepEqual( actual, expect, JSON.stringify( expect ) );147			actual = Mock.calls[ 1 ];148			expect = {149				func: 'interpolate',150				args: [ 3, 33, 43, 44 ]151			};152			assert.deepEqual( actual, expect, JSON.stringify( expect ) );153			assert.ok( Mock.calls.length === 2, "no further calls" );154			Mock.calls = [];155			interpolant.evaluate( 12 ); // two steps back156			actual = Mock.calls[ 0 ];157			expect = {158				func: 'intervalChanged',159				args: [ 1, 11, 22 ]160			};161			assert.deepEqual( actual, expect, JSON.stringify( expect ) );162			actual = Mock.calls[ 1 ];163			expect = {164				func: 'interpolate',165				args: [ 1, 11, 12, 22 ]166			};167			assert.deepEqual( actual, expect, JSON.stringify( expect ) );168			assert.ok( Mock.calls.length === 2, "no further calls" );169			Mock.calls = [];170			interpolant.evaluate( 77 ); // random access171			actual = Mock.calls[ 0 ];172			expect = {173				func: 'intervalChanged',174				args: [ 7, 77, 88 ]175			};176			assert.deepEqual( actual, expect, JSON.stringify( expect ) );177			actual = Mock.calls[ 1 ];178			expect = {179				func: 'interpolate',180				args: [ 7, 77, 77, 88 ]181			};182			assert.deepEqual( actual, expect, JSON.stringify( expect ) );183			assert.ok( Mock.calls.length === 2, "no further calls" );184			Mock.calls = [];185			interpolant.evaluate( 80 ); // same interval186			actual = Mock.calls[ 0 ];187			expect = {188				func: 'interpolate',189				args: [ 7, 77, 80, 88 ]190			};191			assert.deepEqual( actual, expect, JSON.stringify( expect ) );192			assert.ok( Mock.calls.length === 1, "no further calls" );193			Mock.calls = [];194			interpolant.evaluate( 36 ); // random access195			actual = Mock.calls[ 0 ];196			expect = {197				func: 'intervalChanged',198				args: [ 3, 33, 44 ]199			};200			assert.deepEqual( actual, expect, JSON.stringify( expect ) );201			actual = Mock.calls[ 1 ];202			expect = {203				func: 'interpolate',204				args: [ 3, 33, 36, 44 ]205			};206			assert.deepEqual( actual, expect, JSON.stringify( expect ) );207			assert.ok( Mock.calls.length === 2, "no further calls" );208			Mock.calls = [];209			interpolant.evaluate( 24 ); // fast reset / loop (2nd)210			actual = Mock.calls[ 0 ];211			expect = {212				func: 'intervalChanged',213				args: [ 2, 22, 33 ]214			};215			assert.deepEqual( actual, expect, JSON.stringify( expect ) );216			actual = Mock.calls[ 1 ];217			expect = {218				func: 'interpolate',219				args: [ 2, 22, 24, 33 ]220			};221			assert.deepEqual( actual, expect, JSON.stringify( expect ) );222			assert.ok( Mock.calls.length === 2, "no further calls" );223			Mock.calls = [];224			interpolant.evaluate( 16 ); // fast reset / loop (2nd)225			actual = Mock.calls[ 0 ];226			expect = {227				func: 'intervalChanged',228				args: [ 1, 11, 22 ]229			};230			assert.deepEqual( actual, expect, JSON.stringify( expect ) );231			actual = Mock.calls[ 1 ];232			expect = {233				func: 'interpolate',234				args: [ 1, 11, 16, 22 ]235			};236			assert.deepEqual( actual, expect, JSON.stringify( expect ) );237			assert.ok( Mock.calls.length === 2, "no further calls" );238		} );239		QUnit.test( "evaulate -> beforeStart_ [once]", ( assert ) => {240			var actual, expect;241			var interpolant = new Mock( [ 11, 22, 33 ], null, 0, null );242			Mock.calls = [];243			interpolant.evaluate( 10 );244			actual = Mock.calls[ 0 ];245			expect = {246				func: 'beforeStart',247				args: [ 0, 10, 11 ]248			};249			assert.deepEqual( actual, expect, JSON.stringify( expect ) );250			assert.ok( Mock.calls.length === 1, "no further calls" );251			// Check operation resumes normally and intervalChanged gets called252			Mock.calls = [];253			interpolant.evaluate( 11 );254			actual = Mock.calls[ 0 ];255			expect = {256				func: 'intervalChanged',257				args: [ 1, 11, 22 ]258			};259			assert.deepEqual( actual, expect, JSON.stringify( expect ) );260			actual = Mock.calls[ 1 ];261			expect = {262				func: 'interpolate',263				args: [ 1, 11, 11, 22 ]264			};265			assert.deepEqual( actual, expect, JSON.stringify( expect ) );266			assert.ok( Mock.calls.length === 2, "no further calls" );267			// Back off-bounds268			Mock.calls = [];269			interpolant.evaluate( 10 );270			actual = Mock.calls[ 0 ];271			expect = {272				func: 'beforeStart',273				args: [ 0, 10, 11 ]274			};275			assert.deepEqual( actual, expect, JSON.stringify( expect ) );276			assert.ok( Mock.calls.length === 1, "no further calls" );277		} );278		QUnit.test( "evaluate -> beforeStart_ [twice]", ( assert ) => {279			var actual, expect;280			var interpolant = new Mock( [ 11, 22, 33 ], null, 0, null );281			Mock.calls = [];282			interpolant.evaluate( 10 );283			actual = Mock.calls[ 0 ];284			expect = {285				func: 'beforeStart',286				args: [ 0, 10, 11 ]287			};288			assert.deepEqual( actual, expect, JSON.stringify( expect ) );289			assert.ok( Mock.calls.length === 1, "no further calls" );290			Mock.calls = []; // again - consider changed state291			interpolant.evaluate( 10 );292			actual = Mock.calls[ 0 ];293			expect = {294				func: 'beforeStart',295				args: [ 0, 10, 11 ]296			};297			assert.deepEqual( actual, expect, JSON.stringify( expect ) );298			assert.ok( Mock.calls.length === 1, "no further calls" );299			// Check operation resumes normally and intervalChanged gets called300			Mock.calls = [];301			interpolant.evaluate( 11 );302			actual = Mock.calls[ 0 ];303			expect = {304				func: 'intervalChanged',305				args: [ 1, 11, 22 ]306			};307			assert.deepEqual( actual, expect, JSON.stringify( expect ) );308			actual = Mock.calls[ 1 ];309			expect = {310				func: 'interpolate',311				args: [ 1, 11, 11, 22 ]312			};313			assert.deepEqual( actual, expect, JSON.stringify( expect ) );314			assert.ok( Mock.calls.length === 2, "no further calls" );315		} );316		QUnit.test( "evaluate -> afterEnd_ [once]", ( assert ) => {317			var actual, expect;318			var interpolant = new Mock( [ 11, 22, 33 ], null, 0, null );319			Mock.calls = [];320			interpolant.evaluate( 33 );321			actual = Mock.calls[ 0 ];322			expect = {323				func: 'afterEnd',324				args: [ 2, 33, 33 ]325			};326			assert.deepEqual( actual, expect, JSON.stringify( expect ) );327			assert.ok( Mock.calls.length === 1, "no further calls" );328			// Check operation resumes normally and intervalChanged gets called329			Mock.calls = [];330			interpolant.evaluate( 32 );331			actual = Mock.calls[ 0 ];332			expect = {333				func: 'intervalChanged',334				args: [ 2, 22, 33 ]335			};336			assert.deepEqual( actual, expect, JSON.stringify( expect ) );337			actual = Mock.calls[ 1 ];338			expect = {339				func: 'interpolate',340				args: [ 2, 22, 32, 33 ]341			};342			assert.deepEqual( actual, expect, JSON.stringify( expect ) );343			assert.ok( Mock.calls.length === 2, "no further calls" );344			// Back off-bounds345			Mock.calls = [];346			interpolant.evaluate( 33 );347			actual = Mock.calls[ 0 ];348			expect = {349				func: 'afterEnd',350				args: [ 2, 33, 33 ]351			};352			assert.deepEqual( actual, expect, JSON.stringify( expect ) );353			assert.ok( Mock.calls.length === 1, "no further calls" );354		} );355		QUnit.test( "evaluate -> afterEnd_ [twice]", ( assert ) => {356			var actual, expect;357			var interpolant = new Mock( [ 11, 22, 33 ], null, 0, null );358			Mock.calls = [];359			interpolant.evaluate( 33 );360			actual = Mock.calls[ 0 ];361			expect = {362				func: 'afterEnd',363				args: [ 2, 33, 33 ]364			};365			assert.deepEqual( actual, expect, JSON.stringify( expect ) );366			assert.ok( Mock.calls.length === 1, "no further calls" );367			Mock.calls = []; // again - consider changed state368			interpolant.evaluate( 33 );369			actual = Mock.calls[ 0 ];370			expect = {371				func: 'afterEnd',372				args: [ 2, 33, 33 ]373			};374			assert.deepEqual( actual, expect, JSON.stringify( expect ) );375			assert.ok( Mock.calls.length === 1, "no further calls" );376			// Check operation resumes normally and intervalChanged gets called377			Mock.calls = [];378			interpolant.evaluate( 32 );379			actual = Mock.calls[ 0 ];380			expect = {381				func: 'intervalChanged',382				args: [ 2, 22, 33 ]383			};384			assert.deepEqual( actual, expect, JSON.stringify( expect ) );385			actual = Mock.calls[ 1 ];386			expect = {387				func: 'interpolate',388				args: [ 2, 22, 32, 33 ]389			};390			assert.deepEqual( actual, expect, JSON.stringify( expect ) );391			assert.ok( Mock.calls.length === 2, "no further calls" );392		} );393	} );...call_graph.py
Source:call_graph.py  
...53                _function_node(contract, function),54                _solidity_function_node(internal_call),55            )56        )57def _render_external_calls(external_calls):58    return "\n".join(external_calls)59def _render_internal_calls(contract, contract_functions, contract_calls):60    lines = []61    lines.append(f"subgraph {_contract_subgraph(contract)} {{")62    lines.append(f'label = "{contract.name}"')63    lines.extend(contract_functions[contract])64    lines.extend(contract_calls[contract])65    lines.append("}")66    return "\n".join(lines)67def _render_solidity_calls(solidity_functions, solidity_calls):68    lines = []69    lines.append("subgraph cluster_solidity {")70    lines.append('label = "[Solidity]"')71    lines.extend(solidity_functions)72    lines.extend(solidity_calls)73    lines.append("}")74    return "\n".join(lines)75def _process_external_call(76    contract,77    function,78    external_call,79    contract_functions,80    external_calls,81    all_contracts,82):83    external_contract, external_function = external_call84    if not external_contract in all_contracts:85        return86    # add variable as node to respective contract87    if isinstance(external_function, (Variable)):88        contract_functions[external_contract].add(89            _node(90                _function_node(external_contract, external_function),91                external_function.name,92            )93        )94    external_calls.add(95        _edge(96            _function_node(contract, function),97            _function_node(external_contract, external_function),98        )99    )100# pylint: disable=too-many-arguments101def _process_function(102    contract,103    function,104    contract_functions,105    contract_calls,106    solidity_functions,107    solidity_calls,108    external_calls,109    all_contracts,110):111    contract_functions[contract].add(112        _node(_function_node(contract, function), function.name),113    )114    for internal_call in function.internal_calls:115        _process_internal_call(116            contract,117            function,118            internal_call,119            contract_calls,120            solidity_functions,121            solidity_calls,122        )123    for external_call in function.high_level_calls:124        _process_external_call(125            contract,126            function,127            external_call,128            contract_functions,129            external_calls,130            all_contracts,131        )132def _process_functions(functions):133    contract_functions = defaultdict(set)  # contract -> contract functions nodes134    contract_calls = defaultdict(set)  # contract -> contract calls edges135    solidity_functions = set()  # solidity function nodes136    solidity_calls = set()  # solidity calls edges137    external_calls = set()  # external calls edges138    all_contracts = set()139    for function in functions:140        all_contracts.add(function.contract_declarer)141    for function in functions:142        _process_function(143            function.contract_declarer,144            function,145            contract_functions,146            contract_calls,147            solidity_functions,148            solidity_calls,149            external_calls,150            all_contracts,151        )152    render_internal_calls = ""153    for contract in all_contracts:154        render_internal_calls += _render_internal_calls(155            contract, contract_functions, contract_calls156        )157    render_solidity_calls = _render_solidity_calls(solidity_functions, solidity_calls)158    render_external_calls = _render_external_calls(external_calls)159    return render_internal_calls + render_solidity_calls + render_external_calls160class PrinterCallGraph(AbstractPrinter):161    ARGUMENT = "call-graph"162    HELP = "Export the call-graph of the contracts to a dot file"163    WIKI = "https://github.com/trailofbits/slither/wiki/Printer-documentation#call-graph"164    def output(self, filename):165        """166        Output the graph in filename167        Args:168            filename(string)169        """170        all_contracts_filename = ""171        if not filename.endswith(".dot"):172            all_contracts_filename = f"{filename}.all_contracts.call-graph.dot"...test_write.py
Source:test_write.py  
1# -*- coding: utf-8 -*-2from __future__ import print_function, division, absolute_import, unicode_literals3import pytest4from RPLCD.gpio import CharLCD5from RPLCD.common import LCD_SETDDRAMADDR6def test_write_simple(mocker, charlcd_kwargs):7    """8    Write "HelloWorld" to the display.9    """10    lcd = CharLCD(**charlcd_kwargs)11    send_data = mocker.patch.object(lcd, '_send_data')12    text = 'HelloWorld'13    lcd.write_string(text)14    assert send_data.call_count == len(text)15    calls = [c[0] for c in send_data.call_args_list]16    assert calls[0] == (72,)17    assert calls[1] == (101,)18    assert calls[2] == (108,)19    assert calls[3] == (108,)20    assert calls[4] == (111,)21    assert calls[5] == (87,)22    assert calls[6] == (111,)23    assert calls[7] == (114,)24    assert calls[8] == (108,)25    assert calls[9] == (100,)26def test_caching(mocker, charlcd_kwargs):27    """28    Characters should only be written if they have changed29    """30    lcd = CharLCD(**charlcd_kwargs)31    send_data = mocker.patch.object(lcd, '_send_data')32    send_instruction = mocker.patch.object(lcd, '_send_instruction')33    lcd.write_string('hello')34    assert send_data.call_count == 535    data_calls = [c[0] for c in send_data.call_args_list]36    assert data_calls[0] == (104,)37    assert data_calls[1] == (101,)38    assert data_calls[2] == (108,)39    assert data_calls[3] == (108,)40    assert data_calls[4] == (111,)41    lcd.home()42    send_data.reset_mock()43    send_instruction.reset_mock()44    lcd.write_string('he77o')45    assert send_data.call_count == 246    assert send_instruction.call_count == 347    data_calls = [c[0] for c in send_data.call_args_list]48    instruction_calls = [c[0] for c in send_instruction.call_args_list]49    assert instruction_calls[0] == (LCD_SETDDRAMADDR | 1,)50    assert instruction_calls[1] == (LCD_SETDDRAMADDR | 2,)51    assert data_calls[0] == (55,)52    assert data_calls[1] == (55,)53    assert instruction_calls[2] == (LCD_SETDDRAMADDR | 5,)54@pytest.mark.parametrize(['charmap', 'ue'], [55    ('A00', 0b11110101),56    ('A02', 0b11111100),57])58def test_charmap(mocker, charmap, ue, charlcd_kwargs):59    """60    The charmap should be used. The "ü" Umlaut should be encoded correctly.61    """62    lcd = CharLCD(charmap=charmap, **charlcd_kwargs)63    send = mocker.patch.object(lcd, '_send_data')64    text = 'Züri'65    lcd.write_string(text)66    assert send.call_count == 4, 'call count was %d' % send.call_count67    calls = [c[0] for c in send.call_args_list]68    assert calls[0] == (90,)69    assert calls[1] == (ue,)70    assert calls[2] == (114,)71    assert calls[3] == (105,)72@pytest.mark.parametrize(['rows', 'cols'], [73    (2, 16),74    (4, 20),75])76def test_write_newline(mocker, rows, cols, charlcd_kwargs):77    """78    Write text containing CR/LF chars to the display.79    """80    lcd = CharLCD(rows=rows, cols=cols, **charlcd_kwargs)81    send_data = mocker.patch.object(lcd, '_send_data')82    send_instruction = mocker.patch.object(lcd, '_send_instruction')83    text = '\nab\n\rcd'84    lcd.write_string(text)85    assert send_data.call_count + send_instruction.call_count == len(text)86    data_calls = [c[0] for c in send_data.call_args_list]87    instruction_calls = [c[0] for c in send_instruction.call_args_list]88    assert instruction_calls[0] == (0x80 + 0x40,), instruction_calls89    assert data_calls[0] == (97,), data_calls90    assert data_calls[1] == (98,), data_calls91    if rows == 2:92        assert instruction_calls[1] == (0x80 + 2,), instruction_calls93        assert instruction_calls[2] == (0x80 + 0,), instruction_calls94    else:95        assert instruction_calls[1] == (0x80 + cols + 2,), instruction_calls96        assert instruction_calls[2] == (0x80 + cols + 0,), instruction_calls97    assert data_calls[2] == (99,), data_calls...calls-mixin.js
Source:calls-mixin.js  
1/**2 * Copyright (C) 2021 Unicorn a.s.3 *4 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public5 * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later6 * version.7 *8 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied9 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at10 * <https://gnu.org/licenses/> for more details.11 *12 * You may obtain additional information at <https://unicorn.com> or contact Unicorn a.s. at address: V Kapslovne 2767/2,13 * Praha 3, Czech Republic or at the email: info@unicorn.com.14 */15import React from "react";16import { PropTypes } from "uu5g05";17import Environment from "../environment/environment.js";18export const CallsMixin = {19  //@@viewOn:statics20  statics: {21    "UU5.Common.CallsMixin": {22      requiredMixins: ["UU5.Common.BaseMixin"],23      errors: {24        callsNotFound: "Property calls was not set.",25        staticsCallsNotFound: "Variable calls was not found in statics.",26        callNameNotFound: "Call key %s was not found in calls.",27        callNotFound: "Call %s was not found in calls.",28      },29    },30  },31  //@@viewOff:statics32  //@@viewOn:propTypes33  propTypes: {34    calls: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),35  },36  //@@viewOff:propTypes37  //@@viewOn:getDefaultProps38  getDefaultProps() {39    return {40      calls: null,41    };42  },43  //@@viewOff:getDefaultProps44  //@@viewOn:reactLifeCycle45  getInitialState() {46    // initialize47    this.registerMixin("UU5.Common.CallsMixin");48    // state49    return {50      calls: null,51    };52  },53  UNSAFE_componentWillMount() {54    this._setCalls(this.props.calls);55  },56  UNSAFE_componentWillReceiveProps(nextProps) {57    this._setCalls(nextProps.calls);58  },59  //@@viewOff:reactLifeCycle60  //@@viewOn:interface61  hasUU5CommonCallsMixin() {62    return this.hasMixin("UU5.Common.CallsMixin");63  },64  getUU5CommonCallsMixinProps() {65    return {66      calls: this.getCalls(),67    };68  },69  getUU5CommonCallsMixinPropsToPass() {70    return this.getUU5CommonCallsMixinProps();71  },72  getCalls() {73    if (!this.state.calls) {74      this.showError("callsNotFound", null, { mixinName: "UU5.Common.CallsMixin" });75    }76    return this.state.calls;77  },78  setCalls(calls) {79    this._setCalls(calls);80    return this;81  },82  getCall(item, mixinName) {83    let callNames = mixinName84      ? this.constructor[mixinName]85        ? this.constructor[mixinName].calls86        : null87      : this.constructor.calls;88    let callName = callNames && callNames[item];89    let calls = this.getCalls();90    let call = null;91    if (!callNames) {92      this.showError("staticsCallsNotFound", null, {93        mixinName: "UU5.Common.CallsMixin",94        context: {95          constructor: this.constructor,96        },97      });98    } else if (!callName) {99      this.showError("callNameNotFound", item, {100        mixinName: "UU5.Common.CallsMixin",101        context: {102          calls: calls,103        },104      });105    } else {106      call = calls[callName];107      if (!call) {108        this.showError("callNotFound", callName, {109          mixinName: "UU5.Common.CallsMixin",110          context: {111            calls: calls,112          },113        });114      }115    }116    return call;117  },118  //@@viewOff:interface119  //@@viewOn:overriding120  //@@viewOff:overriding121  //@@viewOn:private122  _setCalls(calls) {123    if (calls) {124      typeof calls === "string" && (calls = this.stringToObjectType(calls, "object", Environment.calls));125      this.setState({ calls: calls });126    }127    return this;128  },129  //@@viewOff:private130};...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
