Best JavaScript code snippet using wpt
AssociationIndexOverlay.js
Source:AssociationIndexOverlay.js
1import React, {Component} from 'react';2import {DefaultResourceDatatable} from "./DefaultResourceDatatable";3import {MyDatatableImporter} from "../../helper/MyDatatableImporter";4import {OverlayPanel} from "../../components/overlaypanel/OverlayPanel";5import {ResourceIndex} from "./ResourceIndex";6export class AssociationIndexOverlay extends Component {7 static defaultStyle = {"margin-right":"0.769em","margin-top":"0.769em"};8 static TABLETYPE_View = "View";9 static TABLETYPE_ADD_MULTIPLE = "AddMultiple";10 static TABLETYPE_SET_SINGLE = "SetSingle";11 static TABLETYPE_REMOVE_MULTIPLE = "RemoveMultiple";12 static MENUDATA_FOR_TABLETYPE = {13 [AssociationIndexOverlay.TABLETYPE_ADD_MULTIPLE]: {14 label: "Associate",15 icon: "pi pi-plus"16 },17 [AssociationIndexOverlay.TABLETYPE_SET_SINGLE]: {18 label: "Set",19 icon: "pi pi-plus"20 },21 [AssociationIndexOverlay.TABLETYPE_REMOVE_MULTIPLE]: {22 label: "Disassociate",23 icon: "pi pi-minus"24 },25 }26 constructor(props) {27 super(props);28 this.state = {29 ownSelectedResources: [],30 };31 }32 handleCallback(resources){33 if(this.props.callbackFunction){34 this.props.callbackFunction(resources);35 }36 }37 onSelectionChange(ownSelectedResources){38 this.setState({39 ownSelectedResources: ownSelectedResources40 })41 }42 getActionItem(){43 let ownSelectedResources = this.state.ownSelectedResources;44 let amount = ownSelectedResources.length;45 let disabled = amount <= 0;46 let actionItem = {47 disabled: disabled,48 command: () => {this.handleCallback(ownSelectedResources)}49 }50 actionItem = Object.assign({}, actionItem, AssociationIndexOverlay.MENUDATA_FOR_TABLETYPE[this.props.tableType]);51 actionItem.label = actionItem.label + " ("+amount+")";52 return actionItem;53 }54 getMenuItems(){55 if(this.props.tableType===AssociationIndexOverlay.TABLETYPE_View){56 return null;57 } else {58 const items=[59 this.getActionItem()60 ];61 return items;62 }63 }64 getImportLabel(){65 let additionLabel = "";66 if(this.props.tableType===AssociationIndexOverlay.TABLETYPE_REMOVE_MULTIPLE){67 additionLabel=" to disassociate"68 }69 if(this.props.tableType===AssociationIndexOverlay.TABLETYPE_ADD_MULTIPLE){70 additionLabel=" to associate"71 }72 if(this.props.tableType===AssociationIndexOverlay.TABLETYPE_SET_SINGLE){73 additionLabel=" to set"74 }75 return "Import "+additionLabel;76 }77 handleImportResource(resources){78 if(this.props.tableType===AssociationIndexOverlay.TABLETYPE_REMOVE_MULTIPLE ||79 this.props.tableType===AssociationIndexOverlay.TABLETYPE_ADD_MULTIPLE80 ) {81 console.log("handleImportResource: "+resources.length);82 this.handleCallback(resources);83 } else {84 if(resources.length > 0)85 this.handleCallback([resources[0]]);86 }87 }88 render() {89 let resources = null;90 if(this.props.tableType===AssociationIndexOverlay.TABLETYPE_REMOVE_MULTIPLE ||91 this.props.tableType===AssociationIndexOverlay.TABLETYPE_View92 ) {93 resources = this.props.associatedResources94 }95 let preSelectedResources = null;96 let amountMaxSelectedResources = null;97 if(this.props.tableType===AssociationIndexOverlay.TABLETYPE_ADD_MULTIPLE ||98 this.props.tableType===AssociationIndexOverlay.TABLETYPE_SET_SINGLE ||99 this.props.tableType===AssociationIndexOverlay.TABLETYPE_View){100 preSelectedResources = this.props.associatedResources;101 }102 if(this.props.tableType===AssociationIndexOverlay.TABLETYPE_SET_SINGLE){103 amountMaxSelectedResources = 1;104 }105 let onHandleImport = null;106 if(this.props.tableType===AssociationIndexOverlay.TABLETYPE_ADD_MULTIPLE ||107 this.props.tableType===AssociationIndexOverlay.TABLETYPE_SET_SINGLE ||108 this.props.tableType===AssociationIndexOverlay.TABLETYPE_REMOVE_MULTIPLE)109 {110 onHandleImport = this.handleImportResource.bind(this);111 }112 return <div>113 <DefaultResourceDatatable114 importLabel={this.getImportLabel()}115 onHandleImport={onHandleImport}116 onSelectionChange={this.onSelectionChange.bind(this)}117 tableName={this.props.tableName}118 amountMaxSelectedResources={amountMaxSelectedResources}119 resources={resources}120 preSelectedResources={preSelectedResources}121 menuItems={this.getMenuItems()} />122 </div>123 }...
table-type.spec.ts
Source:table-type.spec.ts
1import Vue from 'vue';2jest.mock( '../components/vue-datatable/vue-datatable' );3jest.mock( '../components/vue-datatable-pager/vue-datatable-pager' );4jest.mock( './settings' );5jest.mock( './handlers/default-handler' );6import { VueDatatablePager } from '../components/vue-datatable-pager/vue-datatable-pager';7import { VueDatatable } from '../components/vue-datatable/vue-datatable';8import { DefaultHandler } from './handlers/default-handler';9// @ts-ignore10import { get, merge, set, Settings } from './settings';11import { TableType } from './table-type';12it( 'is initialized with name, a new settings settings, and a new handler', () => {13 const tabletype1 = new TableType<any>( 'name' );14 expect( tabletype1.id ).toBe( 'name' );15 expect( typeof tabletype1.settings ).toBe( 'object' );16 expect( typeof tabletype1.handler ).toBe( 'object' );17 const tabletype2 = new TableType<any>( 'name2' );18 expect( tabletype2.id ).toBe( 'name2' );19 expect( typeof tabletype1.settings ).toBe( 'object' );20 expect( typeof tabletype1.handler ).toBe( 'object' );21 expect( Settings ).toHaveBeenCalledTimes( 2 );22 expect( tabletype1.settings ).toEqual( tabletype2.settings );23 expect( tabletype1.settings ).not.toBe( tabletype2.settings );24 expect( DefaultHandler ).toHaveBeenCalledTimes( 2 );25 expect( tabletype1.handler ).toEqual( tabletype2.handler );26 expect( tabletype1.handler ).not.toBe( tabletype2.handler );27} );28it( 'can customize handlers', () => {29 const tabletype = new TableType<any>( 'name' );30 expect( typeof tabletype.setFilterHandler ).toBe( 'function' );31 const filterHandlerMock = jest.fn();32 expect( tabletype.setFilterHandler( filterHandlerMock ) ).toBe( tabletype );33 expect( tabletype.handler.filterHandler ).toBe( filterHandlerMock );34 expect( typeof tabletype.setSortHandler ).toBe( 'function' );35 const sortHandlerMock = jest.fn();36 expect( tabletype.setSortHandler( sortHandlerMock ) ).toBe( tabletype );37 expect( tabletype.handler.sortHandler ).toBe( sortHandlerMock );38 expect( typeof tabletype.setPaginateHandler ).toBe( 'function' );39 const paginateHandlerMock = jest.fn();40 expect( tabletype.setPaginateHandler( paginateHandlerMock ) ).toBe( tabletype );41 expect( tabletype.handler.paginateHandler ).toBe( paginateHandlerMock );42} );43describe( 'Settings getter/setter/merge', () => {44 it( 'Get', () => {45 const tabletype = new TableType<any>( 'name' );46 tabletype.setting( 'foo.bar' );47 expect( get ).toHaveBeenCalledTimes( 1 );48 expect( get ).toHaveBeenCalledWith( 'foo.bar' );49 } );50 it( 'Set', () => {51 const tabletype = new TableType<any>( 'name' );52 const obj = {};53 tabletype.setting( 'foo.bar', obj );54 expect( set ).toHaveBeenCalledTimes( 1 );55 expect( set ).toHaveBeenCalledWith( 'foo.bar', obj );56 } );57 it( 'Merge', () => {58 const tabletype = new TableType<any>( 'name' );59 const obj = {};60 tabletype.mergeSettings( obj );61 expect( merge ).toHaveBeenCalledTimes( 1 );62 expect( merge ).toHaveBeenCalledWith( obj );63 } );64} );65describe( 'Can generate table/pager definitions', () => {66 it( 'Generate table', () => {67 const tabletype = new TableType<any>( 'name' );68 const tableDefinition = tabletype.getTableDefinition();69 const componentProtoIndex = ( ( tableDefinition as any ).extendOptions.mixins as Array<typeof Vue> ).indexOf( VueDatatable );70 expect( componentProtoIndex ).not.toBe( -1 );71 const otherMixins = ( ( tableDefinition as any ).extendOptions.mixins as Array<typeof Vue> )72 .filter( ( v, i ) => i !== componentProtoIndex );73 expect( otherMixins ).toHaveLength( 1 );74 expect( ( otherMixins[0] as any ).extendOptions.computed.tableType.get() ).toBe( tabletype );75 } );76 it( 'Generate pager', () => {77 const tabletype = new TableType<any>( 'name' );78 const pagerDefinition = tabletype.getPagerDefinition();79 const componentProtoIndex = ( ( pagerDefinition as any ).extendOptions.mixins as Array<typeof Vue> ).indexOf( VueDatatablePager );80 expect( componentProtoIndex ).not.toBe( -1 );81 const otherMixins = ( ( pagerDefinition as any ).extendOptions.mixins as Array<typeof Vue> )82 .filter( ( v, i ) => i !== componentProtoIndex );83 expect( otherMixins ).toHaveLength( 1 );84 expect( ( otherMixins[0] as any ).extendOptions.computed.tableType.get() ).toBe( tabletype );85 } );...
task.js
Source:task.js
1/***2Task Js3***/45//æ¤åå·²åä»»å¡å°ä»£åä»»å¡6function revoke(taskId, processInstanceId, endTaskTable){7 $.ajax({8 type: "POST",9 url: ctx+"/rest/processAction/process/revoke/"+taskId+"/"+processInstanceId,10 dataType:"text",11 data: {},12 success: function (data) {13 $('#'+endTaskTable+'').DataTable().ajax.reload();14 showToastr('toast-bottom-right', 'success', data)15 },16 beforeSend:function(){17 18 },19 complete: function(){20 21 }22 });23}2425//ç¾æ¶26function claimTask(taskId, table){27 $.ajax( {28 url : ctx + "/rest/processAction/claim/" + taskId,29 dataType:"text",30 type: 'POST',31 success : function(data) {32 $('#'+table+'').DataTable().ajax.reload();33 showToastr('toast-bottom-right', 'success', data)34 }35 });36}37////ç¨æ·åæ¶ç³è¯·38function userCancelApply(taskId,processInstanceId, endTaskTable,tableType){39 var val='';40 if(tableType=='saleOrder'||tableType=='buyOrder'){41 val='userCancelOrderApply';42 }else if(tableType=='pay'||tableType=='payForBuyTable'){43 val='userCancelPayApply';44 }else if(tableType=='buyFram'||tableType=='saleFram'){45 val='userCancelFrameApply';46 }else if(tableType=='buyPrice'||tableType=='salePrice'){47 val='userCancelPriceApply';48 }else if(tableType=='outInvoice'){49 val='userCancelInvoiceApply';50 }else if(tableType=='delivery'){51 val='userCancelDeliveryApply';52 }else if(tableType=='procurementPlan'){53 val='userCancelProcurementPlanApply';54 }55 $.ajax( {56 url : "rest/order/"+val+"/" + taskId+"/"+processInstanceId,57 dataType:"text",58 type: 'POST',59 success : function(data) {60 if(tableType=='buyOrder'){61 data='éè´è®¢åç³è¯·åæ¶æåï¼';62 $('#sample_2').DataTable().ajax.reload();63 }else if(tableType=='saleOrder'){64 data='éå®è®¢åç³è¯·åæ¶æåï¼';65 $('#sample_2').DataTable().ajax.reload();66 }else if(tableType=='pay'){67 data='ä»æ¬¾ç³è¯·åæ¶æåï¼';68 $('#sample_2').DataTable().ajax.reload();69 }else if(tableType=='payForBuyTable'){70 data='ä»æ¬¾ç³è¯·åæ¶æåï¼';71 $('#sample_4').DataTable().ajax.reload();72 }else if(tableType=='buyPrice'){73 data='éè´ä»·æ ¼ç³è¯·åæ¶æåï¼';74 $('#sample_buy').DataTable().ajax.reload();75 }else if(tableType=='salePrice'){76 data='éå®ä»·æ ¼ç³è¯·åæ¶æåï¼';77 $('#sample_sale').DataTable().ajax.reload();78 }else if(tableType=='buyFram'){79 data='éè´æ¡æ¶ç³è¯·åæ¶æåï¼';80 $('#sample_2').DataTable().ajax.reload();81 }else if(tableType=='saleFram'){82 data='éå®æ¡æ¶ç³è¯·åæ¶æåï¼';83 $('#sample_2').DataTable().ajax.reload();84 }else if(tableType=='outInvoice'){85 data='é项票ç³è¯·åæ¶æåï¼';86 $('#sample_out').DataTable().ajax.reload();87 }else if(tableType=='delivery'){88 data='åè´§ç³è¯·åæ¶æåï¼';89 $('#endTaskDeliveryPlanTable').DataTable().ajax.reload();90 }else if(tableType=='procurementPlan'){91 data='éè´è®¡åç³è¯·åæ¶æåï¼';92 $('#sample_2').DataTable().ajax.reload();93 }94 showToastr('toast-bottom-right', 'success', data)95 $('#'+endTaskTable+'').DataTable().ajax.reload();96 },97 error:function(data) {98 //$scope.error = error;99 toastr.success('ç³è¯·åæ¶å¤±è´¥ï¼');100 }101 });
...
Using AI Code Generation
1var wpt = require('webpagetest');2var test = wpt('www.webpagetest.org');3test.runTest('www.google.com', {location: 'Dulles:Chrome'}, function(err, data) {4 if (err) return console.error(err);5 test.tableType(data.data.testId, 'requests', function(err, data) {6 if (err) return console.error(err);7 console.log(data);8 });9});10var wpt = require('webpagetest');11var test = wpt('www.webpagetest.org');12test.runTest('www.google.com', {location: 'Dulles:Chrome'}, function(err, data) {13 if (err) return console.error(err);14 test.testInfo(data.data.testId, function(err, data) {15 if (err) return console.error(err);16 console.log(data);17 });18});19var wpt = require('webpagetest');20var test = wpt('www.webpagetest.org');21test.getLocations(function(err, data) {22 if (err) return console.error(err);23 console.log(data);24});25var wpt = require('webpagetest');26var test = wpt('www.webpagetest.org');27test.getLocations(function(err, data) {28 if (err) return console.error(err);29 var filtered = data.filter(function(location) {30 return location.Location === 'Dulles:Chrome';31 });32 console.log(filtered);33});34var wpt = require('webpagetest');35var test = wpt('www.webpagetest.org');36test.getLocations(function(err, data) {37 if (err) return console.error(err);38 var filtered = data.filter(function(location) {39 return location.Location === 'Dulles:Chrome';40 });41 console.log(filtered[0].Browsers);42});43var wpt = require('webpagetest');
Using AI Code Generation
1var table = new wpTable();2table.tabletype("table1");3table.tabletype("table2");4table.tabletype("table3");5table.tabletype("table4");6table.tabletype("table5");7table.tabletype("table6");8table.tabletype("table7");9table.tabletype("table8");10table.tabletype("table9");11table.tabletype("table10");12table.tabletype("table11");13table.tabletype("table12");14table.tabletype("table13");15table.tabletype("table14");16table.tabletype("table15");17table.tabletype("table16");18table.tabletype("table17");19table.tabletype("table18");20table.tabletype("table19");21table.tabletype("table20");22table.tabletype("table21");23table.tabletype("table22");24table.tabletype("table23");25table.tabletype("table24");26table.tabletype("table25");27table.tabletype("table26");28table.tabletype("table27");29table.tabletype("table28");30table.tabletype("table29");31table.tabletype("table30");32table.tabletype("table31");33table.tabletype("table32");34table.tabletype("table33");35table.tabletype("table34");36table.tabletype("table35");37table.tabletype("table36");38table.tabletype("table37");39table.tabletype("table38");40table.tabletype("table39");41table.tabletype("table40");42table.tabletype("table41");43table.tabletype("table42");44table.tabletype("table43");45table.tabletype("table44");46table.tabletype("table45");47table.tabletype("table46");48table.tabletype("table47");49table.tabletype("table48");50table.tabletype("table49");51table.tabletype("table50");52table.tabletype("table51");53table.tabletype("table52");54table.tabletype("table53");55table.tabletype("table54");56table.tabletype("table55");57table.tabletype("table56");58table.tabletype("table57");59table.tabletype("table58");60table.tabletype("table59");61table.tabletype("table60");62table.tabletype("table61");63table.tabletype("table62");64table.tabletype("table63");65table.tabletype("table64");66table.tabletype("table65");67table.tabletype("table66");68table.tabletype("table67");69table.tabletype("table68");70table.tabletype("table69");71table.tabletype("table70");
Using AI Code Generation
1var wptable = require('wptable');2var table = new wptable();3table.tabletype('csv');4console.log(table.tabletype());5var wptable = require('wptable');6var table = new wptable();7table.tabletype('tsv');8console.log(table.tabletype());9var wptable = require('wptable');10var table = new wptable();11table.tabletype('json');12console.log(table.tabletype());13var wptable = require('wptable');14var table = new wptable();15table.tabletype('xml');16console.log(table.tabletype());17var wptable = require('wptable');18var table = new wptable();19table.tabletype('html');20console.log(table.tabletype());21var wptable = require('wptable');22var table = new wptable();23table.tabletype('xml');24console.log(table.tabletype());25var wptable = require('wptable');26var table = new wptable();27table.tabletype('html');28console.log(table.tabletype());29var wptable = require('wptable');30var table = new wptable();31table.tabletype('xml');32console.log(table.tabletype());33var wptable = require('wptable');34var table = new wptable();35table.tabletype('html');36console.log(table.tabletype());37var wptable = require('wpt
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.runTest('www.google.com', { location: 'Dulles_MotoG', connectivity: 'Cable', runs: 1, pollResults: 10 }, function (err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10wpt.getTableType(function (err, data) {11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17{ 1: 'Dulles:Chrome',18 11: 'Dulles:Safari.MotoG' }
Using AI Code Generation
1var wptable = require('wptable');2var table = wptable.tabletype("table");3console.log(table);4var wptable = require('wptable');5var table = wptable.tabletype("table");6console.log(table);7var wptable = require('wptable');8var table = wptable.tabletype("table");9console.log(table);10var wptable = require('wptable');11var table = wptable.tabletype("table");12console.log(table);13var wptable = require('wptable');14var table = wptable.tabletype("table");15console.log(table);16var wptable = require('wptable');17var table = wptable.tabletype("table");18console.log(table);19var wptable = require('wptable');20var table = wptable.tabletype("table");21console.log(table);22var wptable = require('wptable');23var table = wptable.tabletype("table");24console.log(table);25var wptable = require('wptable');26var table = wptable.tabletype("table");27console.log(table);28var wptable = require('wptable');29var table = wptable.tabletype("table");30console.log(table);31var wptable = require('wptable');32var table = wptable.tabletype("table");33console.log(table);34var wptable = require('wptable');35var table = wptable.tabletype("table");36console.log(table);37var wptable = require('wptable');38var table = wptable.tabletype("table");39console.log(table);
Using AI Code Generation
1var wptoolbox = require('wptoolbox');2var table = wptoolbox.tabletype();3console.log(table);4var wptoolbox = require('wptoolbox');5var table = wptoolbox.tablevalign();6console.log(table);7var wptoolbox = require('wptoolbox');8var table = wptoolbox.tablewidth();9console.log(table);10var wptoolbox = require('wptoolbox');11var text = wptoolbox.textalign();12console.log(text);
Using AI Code Generation
1var table= new WpTable();2table.tabletype("table");3table.tabletype("list");4table.tabletype("div");5var table= new WpTable();6table.tabletype("table");7table.tabletype("list");8table.tabletype("div");9var table= new WpTable();10table.tabletype("table");11table.tabletype("list");12table.tabletype("div");13var table= new WpTable();14table.tabletype("table");15table.tabletype("list");16table.tabletype("div");17var table= new WpTable();18table.tabletype("table");19table.tabletype("list");20table.tabletype("div");21var table= new WpTable();22table.tabletype("table");23table.tabletype("list");24table.tabletype("div");25var table= new WpTable();26table.tabletype("table");27table.tabletype("list");28table.tabletype("div");29var table= new WpTable();30table.tabletype("table");31table.tabletype("list");32table.tabletype("div");33var table= new WpTable();34table.tabletype("table");35table.tabletype("list");36table.tabletype("div");37var table= new WpTable();38table.tabletype("table");39table.tabletype("list");40table.tabletype("div");41var table= new WpTable();42table.tabletype("table");43table.tabletype("list");44table.tabletype("div");45var table= new WpTable();46table.tabletype("table
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!!