How to use instance.run method in ava

Best JavaScript code snippet using ava

Action.js

Source:Action.js Github

copy

Full Screen

...119 fn: 'handleRoute',120 scope: controller121 }122 });123 expect(instance.run() instanceof Ext.promise.Promise).toBeTruthy();124 });125 it("should resolve promise", function () {126 var promise;127 instance = new Ext.route.Action({128 actions: {129 fn: 'handleRoute',130 scope: controller131 }132 });133 promise = instance.run();134 promiseHasBeenResolved(promise);135 });136 it("should reject promise", function () {137 var promise;138 instance = new Ext.route.Action({139 befores: {140 fn: 'beforeHandleRouteBlock',141 scope: controller142 }143 });144 promise = instance.run();145 promiseHasBeenRejected(promise);146 });147 it("should be destroyed after running", function () {148 var promise;149 instance = new Ext.route.Action({150 actions: {151 fn: 'handleRoute',152 scope: controller153 }154 });155 promise = instance.run();156 promiseHasBeenResolved(promise);157 runs(function () {158 expect(instance.destroyed).toBeTruthy();159 });160 });161 it("should run a single before function", function () {162 var promise;163 instance = new Ext.route.Action({164 befores: {165 fn: 'beforeHandleRoute',166 scope: controller167 }168 });169 promise = instance.run();170 promiseHasBeenResolved(promise);171 runs(function () {172 expect(beforeExecuted).toBe(1);173 });174 });175 it("should run multiple before functions", function () {176 var promise;177 instance = new Ext.route.Action({178 befores: [{179 fn: 'beforeHandleRoute',180 scope: controller181 },{182 fn: 'beforeHandleRoute',183 scope: controller184 }]185 });186 promise = instance.run();187 promiseHasBeenResolved(promise);188 runs(function () {189 expect(beforeExecuted).toBe(2);190 });191 });192 it("should run a single action function", function () {193 var promise;194 instance = new Ext.route.Action({195 actions: {196 fn: 'handleRoute',197 scope: controller198 }199 });200 promise = instance.run();201 promiseHasBeenResolved(promise);202 runs(function () {203 expect(actionExecuted).toBe(1);204 });205 });206 it("should run multiple action functions", function () {207 var promise;208 instance = new Ext.route.Action({209 actions: [{210 fn: 'handleRoute',211 scope: controller212 },{213 fn: 'handleRoute',214 scope: controller215 }]216 });217 promise = instance.run();218 promiseHasBeenResolved(promise);219 runs(function () {220 expect(actionExecuted).toBe(2);221 });222 });223 });224 describe("before", function () {225 describe("as a config", function () {226 it("should add before as an object", function () {227 instance = new Ext.route.Action({228 befores: {}229 });230 expect(instance.getBefores().length).toBe(1);231 });232 it("should add before as an array of objects", function () {233 instance = new Ext.route.Action({234 befores: [{}, {}]235 });236 expect(instance.getBefores().length).toBe(2);237 });238 it("should run before", function () {239 var fn = spyOn({240 test: function (action) {241 action.resume();242 }243 }, 'test').andCallThrough();244 instance = new Ext.route.Action({245 befores: {246 fn: fn247 }248 });249 instance.run();250 expect(fn).toHaveBeenCalled();251 });252 });253 describe("added using method", function () {254 it("should add before when no stack exists", function () {255 instance = new Ext.route.Action();256 instance.before(function () {});257 expect(instance.getBefores().length).toBe(1);258 });259 it("should add before to empty before stack", function () {260 instance = new Ext.route.Action({261 befores: []262 });263 instance.before(function () {});264 expect(instance.getBefores().length).toBe(1);265 });266 it("should add before to non-empty before stack", function () {267 instance = new Ext.route.Action({268 befores: [{}]269 });270 instance.before(function () {});271 expect(instance.getBefores().length).toBe(2);272 });273 describe("run added before", function () {274 it("should run before when stack was empty", function () {275 var fn = spyOn({276 test: function (action) {277 action.resume();278 }279 }, 'test').andCallThrough(),280 promise;281 instance = new Ext.route.Action();282 instance.before(fn);283 promise = instance.run();284 promiseHasBeenResolved(promise);285 runs(function () {286 expect(fn).toHaveBeenCalled();287 });288 });289 it("should run before when stack not empty", function () {290 var fn = spyOn({291 test: function (action) {292 action.resume();293 }294 }, 'test').andCallThrough(),295 promise;296 instance = new Ext.route.Action({297 befores: {298 fn: function (action) {299 action.resume();300 }301 }302 });303 instance.before(fn);304 promise = instance.run();305 promiseHasBeenResolved(promise);306 runs(function () {307 expect(fn).toHaveBeenCalled();308 });309 });310 it("should not run before when stack not empty", function () {311 var fn = spyOn({312 test: function (action) {313 action.resume();314 }315 }, 'test').andCallThrough(),316 promise;317 instance = new Ext.route.Action({318 befores: {319 fn: function (action) {320 action.stop();321 }322 }323 });324 instance.before(fn);325 promise = instance.run();326 promiseHasBeenRejected(promise);327 runs(function () {328 expect(fn).not.toHaveBeenCalled();329 });330 });331 //before inception332 it("should run before when added in a before", function () {333 var fn = spyOn({334 test: function (action) {335 action.resume();336 }337 }, 'test').andCallThrough(),338 promise;339 instance = new Ext.route.Action({340 befores: {341 fn: function (action) {342 action.before(fn).resume();343 }344 }345 });346 promise = instance.run();347 promiseHasBeenResolved(promise);348 runs(function () {349 expect(fn).toHaveBeenCalled();350 });351 });352 it("should not run before when added in a before that will stop", function () {353 var fn = spyOn({354 test: function (action) {355 action.resume();356 }357 }, 'test').andCallThrough(),358 promise;359 instance = new Ext.route.Action({360 befores: {361 fn: function (action) {362 action.before(fn).stop();363 }364 }365 });366 promise = instance.run();367 promiseHasBeenRejected(promise);368 runs(function () {369 expect(fn).not.toHaveBeenCalled();370 });371 });372 });373 describe("run added before with promises", function () {374 it("should run before when stack was empty", function () {375 var fn = spyOn({376 test: function (action) {377 return new Ext.Promise(function (resolve) {378 resolve();379 });380 }381 }, 'test').andCallThrough(),382 promise;383 instance = new Ext.route.Action();384 instance.before(fn);385 promise = instance.run();386 promiseHasBeenResolved(promise);387 runs(function () {388 expect(fn).toHaveBeenCalled();389 });390 });391 it("should run before when stack not empty", function () {392 var fn = spyOn({393 test: function (action) {394 return new Ext.Promise(function (resolve) {395 resolve();396 });397 }398 }, 'test').andCallThrough(),399 promise;400 instance = new Ext.route.Action({401 befores: {402 fn: function (action) {403 return new Ext.Promise(function (resolve) {404 resolve();405 });406 }407 }408 });409 instance.before(fn);410 promise = instance.run();411 promiseHasBeenResolved(promise);412 runs(function () {413 expect(fn).toHaveBeenCalled();414 });415 });416 it("should not run before when stack not empty", function () {417 var fn = spyOn({418 test: function (action) {419 return new Ext.Promise(function (resolve) {420 resolve();421 });422 }423 }, 'test').andCallThrough(),424 promise;425 instance = new Ext.route.Action({426 befores: {427 fn: function (action) {428 return new Ext.Promise(function (resolve, reject) {429 reject();430 });431 }432 }433 });434 instance.before(fn);435 promise = instance.run();436 promiseHasBeenRejected(promise);437 runs(function () {438 expect(fn).not.toHaveBeenCalled();439 });440 });441 it("should run before when added in a before", function () {442 var fn = spyOn({443 test: function (action) {444 return new Ext.Promise(function (resolve) {445 resolve();446 });447 }448 }, 'test').andCallThrough(),449 promise;450 instance = new Ext.route.Action({451 befores: {452 fn: function (action) {453 action.before(fn);454 return new Ext.Promise(function (resolve) {455 resolve();456 });457 }458 }459 });460 promise = instance.run();461 promiseHasBeenResolved(promise);462 runs(function () {463 expect(fn).toHaveBeenCalled();464 });465 });466 it("should not run before when added in a before that will stop", function () {467 var fn = spyOn({468 test: function (action) {469 return new Ext.Promise(function (resolve) {470 resolve();471 });472 }473 }, 'test').andCallThrough(),474 promise;475 instance = new Ext.route.Action({476 befores: {477 fn: function (action) {478 action.before(fn);479 return new Ext.Promise(function (resolve, reject) {480 reject();481 });482 }483 }484 });485 promise = instance.run();486 promiseHasBeenRejected(promise);487 runs(function () {488 expect(fn).not.toHaveBeenCalled();489 });490 });491 });492 });493 });494 describe("action", function () {495 describe("as a config", function () {496 it("should add action as an object", function () {497 instance = new Ext.route.Action({498 actions: {}499 });500 expect(instance.getActions().length).toBe(1);501 });502 it("should add action as an array of objects", function () {503 instance = new Ext.route.Action({504 actions: [{}, {}]505 });506 expect(instance.getActions().length).toBe(2);507 });508 it("should run action", function () {509 var fn = spyOn({510 test: Ext.emptyFn511 }, 'test');512 instance = new Ext.route.Action({513 actions: {514 fn: fn515 }516 });517 instance.run();518 expect(fn).toHaveBeenCalled();519 });520 });521 describe("added using method", function () {522 it("should add action when no stack exists", function () {523 instance = new Ext.route.Action();524 instance.action(function () {});525 expect(instance.getActions().length).toBe(1);526 });527 it("should add action to empty action stack", function () {528 instance = new Ext.route.Action({529 actions: []530 });531 instance.action(function () {});532 expect(instance.getActions().length).toBe(1);533 });534 it("should add action to non-empty action stack", function () {535 instance = new Ext.route.Action({536 actions: [{}]537 });538 instance.action(function () {});539 expect(instance.getActions().length).toBe(2);540 });541 describe("run added action", function () {542 it("should run action when stack was empty", function () {543 var fn = spyOn({544 test: Ext.emptyFn545 }, 'test'),546 promise;547 instance = new Ext.route.Action();548 instance.action(fn);549 promise = instance.run();550 promiseHasBeenResolved(promise);551 runs(function () {552 expect(fn).toHaveBeenCalled();553 });554 });555 it("should run action when stack not empty", function () {556 var fn = spyOn({557 test: Ext.emptyFn558 }, 'test'),559 promise;560 instance = new Ext.route.Action({561 actions: {562 fn: Ext.emptyFn563 }564 });565 instance.action(fn);566 promise = instance.run();567 promiseHasBeenResolved(promise);568 runs(function () {569 expect(fn).toHaveBeenCalled();570 });571 });572 it("should run action when added in a before", function () {573 var fn = spyOn({574 test: Ext.emptyFn575 }, 'test'),576 promise;577 instance = new Ext.route.Action({578 befores: {579 fn: function (action) {580 action.action(fn).resume();581 }582 }583 });584 promise = instance.run();585 promiseHasBeenResolved(promise);586 runs(function () {587 expect(fn).toHaveBeenCalled();588 });589 });590 it("should not run action when added in a before and action is stopped", function () {591 var fn = spyOn({592 test: Ext.emptyFn593 }, 'test'),594 promise;595 instance = new Ext.route.Action({596 befores: {597 fn: function (action) {598 action.action(fn).stop();599 }600 }601 });602 promise = instance.run();603 promiseHasBeenRejected(promise);604 runs(function () {605 expect(fn).not.toHaveBeenCalled();606 });607 });608 });609 });610 });611 describe("then", function () {612 it("should execute resolve function", function () {613 var resolve = spyOn({614 test: Ext.emptyFn615 }, 'test'),616 promise;617 instance = new Ext.route.Action();618 instance.then(resolve);619 promise = instance.run();620 promiseHasBeenResolved(promise);621 runs(function () {622 expect(resolve).toHaveBeenCalled();623 });624 });625 it("should execute reject function", function () {626 var resolve = spyOn({627 test: Ext.emptyFn628 }, 'test'),629 reject = spyOn({630 test: Ext.emptyFn631 }, 'test'),632 promise;633 instance = new Ext.route.Action({634 befores: {635 fn: function (action) {636 action.stop();637 }638 }639 });640 instance.then(resolve, reject);641 promise = instance.run();642 promiseHasBeenRejected(promise);643 runs(function () {644 expect(resolve).not.toHaveBeenCalled();645 expect(reject).toHaveBeenCalled();646 });647 });648 });...

Full Screen

Full Screen

tableView.js

Source:tableView.js Github

copy

Full Screen

1import {2 addClass,3 empty,4 fastInnerHTML,5 fastInnerText,6 getScrollbarWidth,7 hasClass,8 isChildOf,9 isInput,10 isOutsideInput11} from './helpers/dom/element';12import EventManager from './eventManager';13import {stopPropagation, isImmediatePropagationStopped, isRightClick, isLeftClick} from './helpers/dom/event';14import Walkontable from './3rdparty/walkontable/src';15import {handleMouseEvent} from './selection/mouseEventHandler';16/**17 * Handsontable TableView constructor18 * @param {Object} instance19 */20function TableView(instance) {21 var that = this;22 this.eventManager = new EventManager(instance);23 this.instance = instance;24 this.settings = instance.getSettings();25 this.selectionMouseDown = false;26 var originalStyle = instance.rootElement.getAttribute('style');27 if (originalStyle) {28 instance.rootElement.setAttribute('data-originalstyle', originalStyle); // needed to retrieve original style in jsFiddle link generator in HT examples. may be removed in future versions29 }30 addClass(instance.rootElement, 'handsontable');31 var table = document.createElement('TABLE');32 addClass(table, 'htCore');33 if (instance.getSettings().tableClassName) {34 addClass(table, instance.getSettings().tableClassName);35 }36 this.THEAD = document.createElement('THEAD');37 table.appendChild(this.THEAD);38 this.TBODY = document.createElement('TBODY');39 table.appendChild(this.TBODY);40 instance.table = table;41 instance.container.insertBefore(table, instance.container.firstChild);42 this.eventManager.addEventListener(instance.rootElement, 'mousedown', (event) => {43 this.selectionMouseDown = true;44 if (!that.isTextSelectionAllowed(event.target)) {45 clearTextSelection();46 event.preventDefault();47 window.focus(); // make sure that window that contains HOT is active. Important when HOT is in iframe.48 }49 });50 this.eventManager.addEventListener(instance.rootElement, 'mouseup', () => {51 this.selectionMouseDown = false;52 });53 this.eventManager.addEventListener(instance.rootElement, 'mousemove', (event) => {54 if (this.selectionMouseDown && !that.isTextSelectionAllowed(event.target)) {55 // Clear selection only when fragmentSelection is enabled, otherwise clearing selection breakes the IME editor.56 if (this.settings.fragmentSelection) {57 clearTextSelection();58 }59 event.preventDefault();60 }61 });62 this.eventManager.addEventListener(document.documentElement, 'keyup', (event) => {63 if (instance.selection.isInProgress() && !event.shiftKey) {64 instance.selection.finish();65 }66 });67 var isMouseDown;68 this.isMouseDown = function() {69 return isMouseDown;70 };71 this.eventManager.addEventListener(document.documentElement, 'mouseup', (event) => {72 if (instance.selection.isInProgress() && isLeftClick(event)) { // is left mouse button73 instance.selection.finish();74 }75 isMouseDown = false;76 if (isOutsideInput(document.activeElement) || (!instance.selection.isSelected() && !isRightClick(event))) {77 instance.unlisten();78 }79 });80 this.eventManager.addEventListener(document.documentElement, 'contextmenu', (event) => {81 if (instance.selection.isInProgress() && isRightClick(event)) {82 instance.selection.finish();83 isMouseDown = false;84 }85 });86 this.eventManager.addEventListener(document.documentElement, 'touchend', () => {87 if (instance.selection.isInProgress()) {88 instance.selection.finish();89 }90 });91 this.eventManager.addEventListener(document.documentElement, 'mousedown', (event) => {92 var originalTarget = event.target;93 var next = event.target;94 var eventX = event.x || event.clientX;95 var eventY = event.y || event.clientY;96 if (isMouseDown || !instance.rootElement) {97 return; // it must have been started in a cell98 }99 // immediate click on "holder" means click on the right side of vertical scrollbar100 if (next === instance.view.wt.wtTable.holder) {101 var scrollbarWidth = getScrollbarWidth();102 if (document.elementFromPoint(eventX + scrollbarWidth, eventY) !== instance.view.wt.wtTable.holder ||103 document.elementFromPoint(eventX, eventY + scrollbarWidth) !== instance.view.wt.wtTable.holder) {104 return;105 }106 } else {107 while (next !== document.documentElement) {108 if (next === null) {109 if (event.isTargetWebComponent) {110 break;111 }112 // click on something that was a row but now is detached (possibly because your click triggered a rerender)113 return;114 }115 if (next === instance.rootElement) {116 // click inside container117 return;118 }119 next = next.parentNode;120 }121 }122 // function did not return until here, we have an outside click!123 var outsideClickDeselects = typeof that.settings.outsideClickDeselects === 'function' ?124 that.settings.outsideClickDeselects(originalTarget) :125 that.settings.outsideClickDeselects;126 if (outsideClickDeselects) {127 instance.deselectCell();128 } else {129 instance.destroyEditor(false, false);130 }131 });132 this.eventManager.addEventListener(table, 'selectstart', (event) => {133 if (that.settings.fragmentSelection || isInput(event.target)) {134 return;135 }136 // https://github.com/handsontable/handsontable/issues/160137 // Prevent text from being selected when performing drag down.138 event.preventDefault();139 });140 var clearTextSelection = function() {141 // http://stackoverflow.com/questions/3169786/clear-text-selection-with-javascript142 if (window.getSelection) {143 if (window.getSelection().empty) { // Chrome144 window.getSelection().empty();145 } else if (window.getSelection().removeAllRanges) { // Firefox146 window.getSelection().removeAllRanges();147 }148 } else if (document.selection) { // IE?149 document.selection.empty();150 }151 };152 var walkontableConfig = {153 debug: () => that.settings.debug,154 externalRowCalculator: this.instance.getPlugin('autoRowSize') && this.instance.getPlugin('autoRowSize').isEnabled(),155 table,156 preventOverflow: () => this.settings.preventOverflow,157 stretchH: () => that.settings.stretchH,158 data: instance.getDataAtCell,159 totalRows: () => instance.countRows(),160 totalColumns: () => instance.countCols(),161 fixedColumnsLeft: () => that.settings.fixedColumnsLeft,162 fixedRowsTop: () => that.settings.fixedRowsTop,163 fixedRowsBottom: () => that.settings.fixedRowsBottom,164 minSpareRows: () => that.settings.minSpareRows,165 renderAllRows: that.settings.renderAllRows,166 rowHeaders: () => {167 let headerRenderers = [];168 if (instance.hasRowHeaders()) {169 headerRenderers.push((row, TH) => that.appendRowHeader(row, TH));170 }171 instance.runHooks('afterGetRowHeaderRenderers', headerRenderers);172 return headerRenderers;173 },174 columnHeaders: () => {175 let headerRenderers = [];176 if (instance.hasColHeaders()) {177 headerRenderers.push((column, TH) => {178 that.appendColHeader(column, TH);179 });180 }181 instance.runHooks('afterGetColumnHeaderRenderers', headerRenderers);182 return headerRenderers;183 },184 columnWidth: instance.getColWidth,185 rowHeight: instance.getRowHeight,186 cellRenderer(row, col, TD) {187 const cellProperties = that.instance.getCellMeta(row, col);188 const prop = that.instance.colToProp(col);189 let value = that.instance.getDataAtRowProp(row, prop);190 if (that.instance.hasHook('beforeValueRender')) {191 value = that.instance.runHooks('beforeValueRender', value, cellProperties);192 }193 that.instance.runHooks('beforeRenderer', TD, row, col, prop, value, cellProperties);194 that.instance.getCellRenderer(cellProperties)(that.instance, TD, row, col, prop, value, cellProperties);195 that.instance.runHooks('afterRenderer', TD, row, col, prop, value, cellProperties);196 },197 selections: that.instance.selection.highlight,198 hideBorderOnMouseDownOver: () => that.settings.fragmentSelection,199 onCellMouseDown: (event, coords, TD, wt) => {200 const blockCalculations = {201 row: false,202 column: false,203 cell: false204 };205 instance.listen();206 that.activeWt = wt;207 isMouseDown = true;208 instance.runHooks('beforeOnCellMouseDown', event, coords, TD, blockCalculations);209 if (isImmediatePropagationStopped(event)) {210 return;211 }212 handleMouseEvent(event, {213 coords,214 selection: instance.selection,215 controller: blockCalculations,216 });217 instance.runHooks('afterOnCellMouseDown', event, coords, TD);218 that.activeWt = that.wt;219 },220 onCellContextMenu: (event, coords, TD, wt) => {221 that.activeWt = wt;222 isMouseDown = false;223 if (instance.selection.isInProgress()) {224 instance.selection.finish();225 }226 instance.runHooks('beforeOnCellContextMenu', event, coords, TD);227 if (isImmediatePropagationStopped(event)) {228 return;229 }230 instance.runHooks('afterOnCellContextMenu', event, coords, TD);231 that.activeWt = that.wt;232 },233 onCellMouseOut: (event, coords, TD, wt) => {234 that.activeWt = wt;235 instance.runHooks('beforeOnCellMouseOut', event, coords, TD);236 if (isImmediatePropagationStopped(event)) {237 return;238 }239 instance.runHooks('afterOnCellMouseOut', event, coords, TD);240 that.activeWt = that.wt;241 },242 onCellMouseOver: (event, coords, TD, wt) => {243 const blockCalculations = {244 row: false,245 column: false,246 cell: false247 };248 that.activeWt = wt;249 instance.runHooks('beforeOnCellMouseOver', event, coords, TD, blockCalculations);250 if (isImmediatePropagationStopped(event)) {251 return;252 }253 if (isMouseDown) {254 handleMouseEvent(event, {255 coords,256 selection: instance.selection,257 controller: blockCalculations,258 });259 }260 instance.runHooks('afterOnCellMouseOver', event, coords, TD);261 that.activeWt = that.wt;262 },263 onCellMouseUp: (event, coords, TD, wt) => {264 that.activeWt = wt;265 instance.runHooks('beforeOnCellMouseUp', event, coords, TD);266 instance.runHooks('afterOnCellMouseUp', event, coords, TD);267 that.activeWt = that.wt;268 },269 onCellCornerMouseDown(event) {270 event.preventDefault();271 instance.runHooks('afterOnCellCornerMouseDown', event);272 },273 onCellCornerDblClick(event) {274 event.preventDefault();275 instance.runHooks('afterOnCellCornerDblClick', event);276 },277 beforeDraw(force, skipRender) {278 that.beforeRender(force, skipRender);279 },280 onDraw(force) {281 that.onDraw(force);282 },283 onScrollVertically() {284 instance.runHooks('afterScrollVertically');285 },286 onScrollHorizontally() {287 instance.runHooks('afterScrollHorizontally');288 },289 onBeforeRemoveCellClassNames: () => instance.runHooks('beforeRemoveCellClassNames'),290 onAfterDrawSelection: (currentRow, currentColumn, cornersOfSelection, layerLevel) => instance.runHooks('afterDrawSelection',291 currentRow, currentColumn, cornersOfSelection, layerLevel),292 onBeforeDrawBorders(corners, borderClassName) {293 instance.runHooks('beforeDrawBorders', corners, borderClassName);294 },295 onBeforeTouchScroll() {296 instance.runHooks('beforeTouchScroll');297 },298 onAfterMomentumScroll() {299 instance.runHooks('afterMomentumScroll');300 },301 onBeforeStretchingColumnWidth: (stretchedWidth, column) => instance.runHooks('beforeStretchingColumnWidth', stretchedWidth, column),302 onModifyRowHeaderWidth: (rowHeaderWidth) => instance.runHooks('modifyRowHeaderWidth', rowHeaderWidth),303 onModifyGetCellCoords: (row, column, topmost) => instance.runHooks('modifyGetCellCoords', row, column, topmost),304 viewportRowCalculatorOverride(calc) {305 let rows = instance.countRows();306 let viewportOffset = that.settings.viewportRowRenderingOffset;307 if (viewportOffset === 'auto' && that.settings.fixedRowsTop) {308 viewportOffset = 10;309 }310 if (typeof viewportOffset === 'number') {311 calc.startRow = Math.max(calc.startRow - viewportOffset, 0);312 calc.endRow = Math.min(calc.endRow + viewportOffset, rows - 1);313 }314 if (viewportOffset === 'auto') {315 let center = calc.startRow + calc.endRow - calc.startRow;316 let offset = Math.ceil(center / rows * 12);317 calc.startRow = Math.max(calc.startRow - offset, 0);318 calc.endRow = Math.min(calc.endRow + offset, rows - 1);319 }320 instance.runHooks('afterViewportRowCalculatorOverride', calc);321 },322 viewportColumnCalculatorOverride(calc) {323 let cols = instance.countCols();324 let viewportOffset = that.settings.viewportColumnRenderingOffset;325 if (viewportOffset === 'auto' && that.settings.fixedColumnsLeft) {326 viewportOffset = 10;327 }328 if (typeof viewportOffset === 'number') {329 calc.startColumn = Math.max(calc.startColumn - viewportOffset, 0);330 calc.endColumn = Math.min(calc.endColumn + viewportOffset, cols - 1);331 }332 if (viewportOffset === 'auto') {333 let center = calc.startColumn + calc.endColumn - calc.startColumn;334 let offset = Math.ceil(center / cols * 12);335 calc.startRow = Math.max(calc.startColumn - offset, 0);336 calc.endColumn = Math.min(calc.endColumn + offset, cols - 1);337 }338 instance.runHooks('afterViewportColumnCalculatorOverride', calc);339 },340 rowHeaderWidth: () => that.settings.rowHeaderWidth,341 columnHeaderHeight() {342 const columnHeaderHeight = instance.runHooks('modifyColumnHeaderHeight');343 return that.settings.columnHeaderHeight || columnHeaderHeight;344 }345 };346 instance.runHooks('beforeInitWalkontable', walkontableConfig);347 this.wt = new Walkontable(walkontableConfig);348 this.activeWt = this.wt;349 this.eventManager.addEventListener(that.wt.wtTable.spreader, 'mousedown', (event) => {350 // right mouse button exactly on spreader means right click on the right hand side of vertical scrollbar351 if (event.target === that.wt.wtTable.spreader && event.which === 3) {352 stopPropagation(event);353 }354 });355 this.eventManager.addEventListener(that.wt.wtTable.spreader, 'contextmenu', (event) => {356 // right mouse button exactly on spreader means right click on the right hand side of vertical scrollbar357 if (event.target === that.wt.wtTable.spreader && event.which === 3) {358 stopPropagation(event);359 }360 });361 this.eventManager.addEventListener(document.documentElement, 'click', () => {362 if (that.settings.observeDOMVisibility) {363 if (that.wt.drawInterrupted) {364 that.instance.forceFullRender = true;365 that.render();366 }367 }368 });369}370TableView.prototype.isTextSelectionAllowed = function(el) {371 if (isInput(el)) {372 return true;373 }374 let isChildOfTableBody = isChildOf(el, this.instance.view.wt.wtTable.spreader);375 if (this.settings.fragmentSelection === true && isChildOfTableBody) {376 return true;377 }378 if (this.settings.fragmentSelection === 'cell' && this.isSelectedOnlyCell() && isChildOfTableBody) {379 return true;380 }381 if (!this.settings.fragmentSelection && this.isCellEdited() && this.isSelectedOnlyCell()) {382 return true;383 }384 return false;385};386/**387 * Check if selected only one cell.388 *389 * @returns {Boolean}390 */391TableView.prototype.isSelectedOnlyCell = function() {392 var [row, col, rowEnd, colEnd] = this.instance.getSelectedLast() || [];393 return row !== void 0 && row === rowEnd && col === colEnd;394};395TableView.prototype.isCellEdited = function() {396 var activeEditor = this.instance.getActiveEditor();397 return activeEditor && activeEditor.isOpened();398};399TableView.prototype.beforeRender = function(force, skipRender) {400 if (force) {401 // this.instance.forceFullRender = did Handsontable request full render?402 this.instance.runHooks('beforeRender', this.instance.forceFullRender, skipRender);403 }404};405TableView.prototype.onDraw = function(force) {406 if (force) {407 // this.instance.forceFullRender = did Handsontable request full render?408 this.instance.runHooks('afterRender', this.instance.forceFullRender);409 }410};411TableView.prototype.render = function() {412 this.wt.draw(!this.instance.forceFullRender);413 this.instance.forceFullRender = false;414 this.instance.renderCall = false;415};416/**417 * Returns td object given coordinates418 *419 * @param {CellCoords} coords420 * @param {Boolean} topmost421 */422TableView.prototype.getCellAtCoords = function(coords, topmost) {423 var td = this.wt.getCell(coords, topmost);424 if (td < 0) { // there was an exit code (cell is out of bounds)425 return null;426 }427 return td;428};429/**430 * Scroll viewport to selection.431 *432 * @param {CellCoords} coords433 */434TableView.prototype.scrollViewport = function(coords) {435 this.wt.scrollViewport(coords);436};437/**438 * Append row header to a TH element439 * @param row440 * @param TH441 */442TableView.prototype.appendRowHeader = function(row, TH) {443 if (TH.firstChild) {444 let container = TH.firstChild;445 if (!hasClass(container, 'relative')) {446 empty(TH);447 this.appendRowHeader(row, TH);448 return;449 }450 this.updateCellHeader(container.querySelector('.rowHeader'), row, this.instance.getRowHeader);451 } else {452 let div = document.createElement('div');453 let span = document.createElement('span');454 div.className = 'relative';455 span.className = 'rowHeader';456 this.updateCellHeader(span, row, this.instance.getRowHeader);457 div.appendChild(span);458 TH.appendChild(div);459 }460 this.instance.runHooks('afterGetRowHeader', row, TH);461};462/**463 * Append column header to a TH element464 * @param col465 * @param TH466 */467TableView.prototype.appendColHeader = function(col, TH) {468 if (TH.firstChild) {469 let container = TH.firstChild;470 if (hasClass(container, 'relative')) {471 this.updateCellHeader(container.querySelector('.colHeader'), col, this.instance.getColHeader);472 } else {473 empty(TH);474 this.appendColHeader(col, TH);475 }476 } else {477 var div = document.createElement('div');478 let span = document.createElement('span');479 div.className = 'relative';480 span.className = 'colHeader';481 this.updateCellHeader(span, col, this.instance.getColHeader);482 div.appendChild(span);483 TH.appendChild(div);484 }485 this.instance.runHooks('afterGetColHeader', col, TH);486};487/**488 * Update header cell content489 *490 * @since 0.15.0-beta4491 * @param {HTMLElement} element Element to update492 * @param {Number} index Row index or column index493 * @param {Function} content Function which should be returns content for this cell494 */495TableView.prototype.updateCellHeader = function(element, index, content) {496 let renderedIndex = index;497 let parentOverlay = this.wt.wtOverlays.getParentOverlay(element) || this.wt;498 // prevent wrong calculations from SampleGenerator499 if (element.parentNode) {500 if (hasClass(element, 'colHeader')) {501 renderedIndex = parentOverlay.wtTable.columnFilter.sourceToRendered(index);502 } else if (hasClass(element, 'rowHeader')) {503 renderedIndex = parentOverlay.wtTable.rowFilter.sourceToRendered(index);504 }505 }506 if (renderedIndex > -1) {507 fastInnerHTML(element, content(index));508 } else {509 // workaround for https://github.com/handsontable/handsontable/issues/1946510 fastInnerText(element, String.fromCharCode(160));511 addClass(element, 'cornerHeader');512 }513};514/**515 * Given a element's left position relative to the viewport, returns maximum element width until the right516 * edge of the viewport (before scrollbar)517 *518 * @param {Number} leftOffset519 * @return {Number}520 */521TableView.prototype.maximumVisibleElementWidth = function(leftOffset) {522 var workspaceWidth = this.wt.wtViewport.getWorkspaceWidth();523 var maxWidth = workspaceWidth - leftOffset;524 return maxWidth > 0 ? maxWidth : 0;525};526/**527 * Given a element's top position relative to the viewport, returns maximum element height until the bottom528 * edge of the viewport (before scrollbar)529 *530 * @param {Number} topOffset531 * @return {Number}532 */533TableView.prototype.maximumVisibleElementHeight = function(topOffset) {534 var workspaceHeight = this.wt.wtViewport.getWorkspaceHeight();535 var maxHeight = workspaceHeight - topOffset;536 return maxHeight > 0 ? maxHeight : 0;537};538TableView.prototype.mainViewIsActive = function() {539 return this.wt === this.activeWt;540};541TableView.prototype.destroy = function() {542 this.wt.destroy();543 this.eventManager.destroy();544};...

Full Screen

Full Screen

test-test.js

Source:test-test.js Github

copy

Full Screen

1var common = require('../common');2var assert = require('assert');3var sinon = require('sinon');4var EventEmitter = require('events').EventEmitter;5var stackTrace = require('stack-trace');6var sandboxProcess = new EventEmitter();7sandboxProcess.nextTick = function(cb) {8 cb();9};10var Sandbox = common.sandbox('test', {11 globals: {12 process: sandboxProcess,13 }14});15var Test = Sandbox.exports;16var testInstance;17function test(fn) {18 testInstance = new Test();19 fn();20}21test(function addOneTest() {22 var testName = 'my test';23 var testFn = function() {};24 var testInstance = Test.create(testName, testFn);25 assert.strictEqual(testInstance.name, testName);26 assert.strictEqual(testInstance.testFn, testFn);27 assert.ok(testInstance._createTrace);28});29test(function addTestWithOptions() {30 var testName = 'my test';31 var testOptions = {foo: 'bar'};32 var testFn = function() {};33 var testInstance = Test.create(testName, testOptions, testFn);34 assert.strictEqual(testInstance.foo, testOptions.foo);35});36test(function runEmptyTest() {37 testInstance.testFn = sinon.spy();38 var runCb = sinon.spy();39 testInstance.run(runCb);40 assert.ok(testInstance.testFn.called);41 var doneErr = runCb.args[0][0];42 assert.ok(!doneErr);43 assert.ok(testInstance._ended);44});45test(function runSyncException() {46 var err = new Error('something went wrong');47 testInstance.testFn = function() {48 sandboxProcess.emit('uncaughtException', err);49 };50 var runCb = sinon.spy();51 testInstance.run(runCb);52 assert.strictEqual(testInstance.error, err);53 assert.strictEqual(runCb.args[0][0], err);54});55test(function runSyncExceptionInAsyncTest() {56 var err = new Error('something went wrong');57 testInstance.testFn = function(done) {58 sandboxProcess.emit('uncaughtException', err);59 };60 var runCb = sinon.spy();61 testInstance.run(runCb);62 assert.strictEqual(testInstance.error, err);63 assert.strictEqual(runCb.args[0][0], err);64});65test(function runAsyncTest() {66 var clock = sinon.useFakeTimers();;67 testInstance.testFn = function(done) {68 setTimeout(function() {69 done();70 }, 100);71 };72 var runCb = sinon.spy();73 testInstance.run(runCb);74 clock.tick(99);75 assert.ok(!runCb.called);76 clock.tick(1);77 assert.ok(runCb.called);78 assert.ok(testInstance._ended);79 clock.restore();80});81test(function runAsyncTestDoneTwice() {82 testInstance.testFn = function(done) {83 done();84 done();85 };86 var runCb = sinon.spy();87 testInstance.run(runCb);88 assert.strictEqual(runCb.callCount, 1);89});90test(function runAsyncTestError() {91 var clock = sinon.useFakeTimers();;92 var err = new Error('ouch');93 testInstance.testFn = function(done) {94 setTimeout(function() {95 done(err);96 }, 100);97 };98 var runCb = sinon.spy();99 testInstance.run(runCb);100 clock.tick(100);101 assert.strictEqual(runCb.args[0][0], err);102 clock.restore();103});104test(function runAsyncTestException() {105 testInstance.testFn = function(done) {106 };107 var runCb = sinon.spy();108 testInstance.run(runCb);109 var err = new Error('oh no');110 sandboxProcess.emit('uncaughtException', err);111 assert.strictEqual(runCb.args[0][0], err);112 var listeners = [].concat(sandboxProcess.listeners('uncaughtException'));113 sandboxProcess.removeAllListeners('uncaughtException');114 assert.strictEqual(listeners.length, 0);115});116test(function runBeforeAndAfterSync() {117 sinon.spy(testInstance, 'beforeFn');118 sinon.spy(testInstance, 'afterFn');119 testInstance.testFn = function() {120 assert.ok(testInstance.beforeFn.called);121 };122 var runCb = sinon.spy();123 testInstance.run(runCb);124 assert.equal(runCb.args[0][0], null);125 assert.ok(runCb.called);126 assert.ok(testInstance.afterFn.called);127});128test(function afterExecutesEvenOnTestError() {129 sinon.spy(testInstance, 'afterFn');130 var err = new Error('oh noes');131 testInstance.testFn = function() {132 sandboxProcess.emit('uncaughtException', err);133 };134 var runCb = sinon.spy();135 testInstance.run(runCb);136 assert.strictEqual(runCb.args[0][0], err);137 assert.ok(testInstance.afterFn.called);138});139test(function asyncTimeout() {140 var clock = sinon.useFakeTimers();;141 Sandbox.globals.setTimeout = setTimeout;142 Sandbox.globals.Date = Date;143 testInstance.testFn = function(done) {};144 var timeout = testInstance.timeout = 100;145 var runCb = sinon.spy();146 testInstance.run(runCb);147 clock.tick(99);148 assert.strictEqual(runCb.called, false);149 clock.tick(1);150 var doneErr = runCb.args[0][0];151 assert.ok(doneErr.timeout);152 assert.ok(doneErr.message.match(/timeout/i));153 assert.ok(doneErr.message.indexOf('exceeded ' + timeout + 'ms') > -1);154 assert.ok(doneErr.message.indexOf('took 100ms') > -1);155 clock.restore()156 Sandbox.globals.setTimeout = setTimeout;157 Sandbox.globals.Date = Date;158});159test(function syncTimeout() {160 testInstance.testFn = function() {161 };162 var timeout = testInstance.timeout = -1;163 var runCb = sinon.spy();164 testInstance.run(runCb);165 assert.strictEqual(runCb.called, true);166 var doneErr = runCb.args[0][0];167 assert.ok(doneErr.message.match(/timeout/i));168 assert.ok(doneErr.message.indexOf('exceeded ' + timeout + 'ms') > -1);169});170test(function alterTimeout() {171 var clock = sinon.useFakeTimers();;172 Sandbox.globals.setTimeout = setTimeout;173 Sandbox.globals.clearTimeout = clearTimeout;174 Sandbox.globals.Date = Date;175 testInstance.testFn = function(done) {};176 testInstance.timeout = 100;177 var runCb = sinon.spy();178 testInstance.run(runCb);179 clock.tick(99);180 assert.strictEqual(runCb.called, false);181 testInstance.setTimeout(101);182 clock.tick(100);183 assert.strictEqual(runCb.called, false);184 clock.tick(1);185 assert.strictEqual(runCb.called, true);186 clock.restore()187 Sandbox.globals.setTimeout = setTimeout;188 Sandbox.globals.clearTimeout = clearTimeout;189 Sandbox.globals.Date = Date;190});191test(function clearsAysyncTimeoutOnSuccess() {192 var realClearTimeout = clearTimeout;193 var timeoutId = 23;194 Sandbox.globals.setTimeout = sinon.stub().returns(timeoutId);195 Sandbox.globals.clearTimeout = sinon.stub();196 testInstance.testFn = function(done) {197 done();198 };199 testInstance.timeout = 100;200 var runCb = sinon.spy();201 testInstance.run(runCb);202 assert.ok(runCb.called);203 assert.ok(Sandbox.globals.clearTimeout.calledWith(timeoutId));204 Sandbox.globals.clearTimeout = realClearTimeout;205});206test(function cancelTimeout() {207 var clock = sinon.useFakeTimers();;208 Sandbox.globals.setTimeout = setTimeout;209 Sandbox.globals.clearTimeout = clearTimeout;210 Sandbox.globals.Date = Date;211 testInstance.testFn = function(done) {};212 testInstance.timeout = 100;213 var runCb = sinon.spy();214 testInstance.run(runCb);215 testInstance.setTimeout(0);216 clock.tick(100);217 assert.ok(!testInstance._ended);218 testInstance.end();219 assert.ok(testInstance._ended);220 var doneErr = runCb.args[0][0];221 assert.ok(!doneErr);222 clock.restore()223 Sandbox.globals.setTimeout = setTimeout;224 Sandbox.globals.clearTimeout = clearTimeout;225 Sandbox.globals.Date = Date;226});227test(function addTraceInfoForTimeout() {228 var file = __dirname + '/imaginary.js';229 var line = 42;230 testInstance._createTrace = [231 {232 getFileName: function() { return common.dir.lib + '/foo.js' },233 getLineNumber: function() { return 23; },234 },235 {236 getFileName: function() { return file },237 getLineNumber: function() { return line; },238 }239 ];240 var err = new Error('oh noes');241 err.timeout = true;242 testInstance._addErrorLocation(err);243 assert.equal(err.file, file);244 assert.equal(err.line, line);245});246test(function addTraceInfoForRegularError() {247 var err = new Error('oh noes');248 var errorLine = stackTrace.get()[0].getLineNumber() - 1;249 testInstance._addErrorLocation(err);250 assert.equal(err.file, __filename);251 assert.equal(err.line, errorLine);252});253test(function selected() {254 testInstance.name = 'foo';255 assert.equal(testInstance.selected(), false);256 testInstance.name = '!foo';257 assert.equal(testInstance.selected(), true);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1test('my passing test', t => {2 t.pass();3});4test('my failing test', t => {5 t.fail();6});7test('my passing test', t => {8 t.pass();9});10test('my failing test', t => {11 t.fail();12});13test('my passing test', t => {14 t.pass();15});16test('my failing test', t => {17 t.fail();18});19test('my passing test', t => {20 t.pass();21});22test('my failing test', t => {23 t.fail();24});25test('my passing test', t => {26 t.pass();27});28test('my failing test', t => {29 t.fail();30});31test('my passing test', t => {32 t.pass();33});34test('my failing test', t => {35 t.fail();36});37test('my passing test', t => {38 t.pass();39});40test('my failing test', t => {41 t.fail();42});43test('my passing test', t => {44 t.pass();45});46test('my failing test', t => {47 t.fail();48});49test('my passing test', t => {50 t.pass();51});52test('my failing test', t => {53 t.fail();54});55test('my passing test', t => {56 t.pass();57});58test('my failing test', t => {59 t.fail();60});

Full Screen

Using AI Code Generation

copy

Full Screen

1const test = require('ava');2const {spawn} = require('child_process');3test('test', t => {4 const ava = spawn('./node_modules/.bin/ava', ['test.js']);5 ava.stdout.on('data', (data) => {6 console.log(`stdout: ${data}`);7 });8 ava.stderr.on('data', (data) => {9 console.log(`stderr: ${data}`);10 });11 ava.on('close', (code) => {12 console.log(`child process exited with code ${code}`);13 });14});

Full Screen

Using AI Code Generation

copy

Full Screen

1const test = require('ava');2const { exec } = require('child_process');3const { promisify } = require('util');4const execAsync = promisify(exec);5const { join } = require('path');6const { readFile } = require('fs');7const { promisify } = require('util');8const readFileAsync = promisify(readFile);9const { join } = require('path');10const { readFile } = require('fs');11const { promisify } = require('util');12const readFileAsync = promisify(readFile);13const { join } = require('path');14const { readFile } = require('fs');15const { promisify } = require('util');16const readFileAsync = promisify(readFile);17const { join } = require('path');18const { readFile } = require('fs');19const { promisify } = require('util');20const readFileAsync = promisify(readFile);21const { join } = require('path');22const { readFile } = require('fs');23const { promisify } = require('util');24const readFileAsync = promisify(readFile);25test('test', async (t) => {26 const { stdout, stderr } = await execAsync('node test.js');27 t.true(stdout.includes('1..1'));28 t.true(stdout.includes('ok 1'));29 t.true(stdout.includes('test.js'));30 t.is(stderr, '');31});32const test = require('ava');33const { exec } = require('child_process');34const { promisify } = require('util');35const execAsync = promisify(exec);36const { join } = require('path');37const { readFile } = require('fs');38const { promisify } = require('util');39const readFileAsync = promisify(readFile);40const { join } = require('path');41const { readFile } = require('fs');42const { promisify } = require('util');43const readFileAsync = promisify(readFile);44const { join } = require('path');45const { readFile } = require('fs');46const { promisify } = require('util');47const readFileAsync = promisify(readFile);48const { join } = require('path');49const { readFile } = require('fs');50const { promisify } = require('util');51const readFileAsync = promisify(readFile);52const { join } = require('path');53const { readFile } = require('fs

Full Screen

Using AI Code Generation

copy

Full Screen

1import test from 'ava';2import delay from 'delay';3import pEvent from 'p-event';4import {execa} from 'execa';5import {join} from 'path';6import {fork} from 'child_process';7import {readFileSync} from 'fs';8const fixture = join(__dirname, 'fixture.js');9test('run', async t => {10 const cp = execa('node', [fixture]);11 cp.stdout.pipe(process.stdout);12 cp.stderr.pipe(process.stderr);13 const {stdout} = await pEvent(cp, 'close');14 t.is(stdout, 'unicorn');15});16test('run method', async t => {17 const cp = fork(fixture);18 cp.stdout.pipe(process.stdout);19 cp.stderr.pipe(process.stderr);20 const {stdout} = await pEvent(cp, 'close');21 t.is(stdout, 'unicorn');22});23test('run method with delay', async t => {24 const cp = fork(fixture);25 cp.stdout.pipe(process.stdout);26 cp.stderr.pipe(process.stderr);27 await delay(1000);28 const {stdout} = await pEvent(cp, 'close');29 t.is(stdout, 'unicorn');30});31test('run method with delay in fixture', async t => {32 const cp = fork(fixture);33 cp.stdout.pipe(process.stdout);34 cp.stderr.pipe(process.stderr);35 const {stdout} = await pEvent(cp, 'close');36 t.is(stdout, 'unicorn');37});38test('run method with delay in fixture and stdout', async t => {39 const cp = fork(fixture);40 cp.stdout.pipe(process.stdout);41 cp.stderr.pipe(process.stderr);42 const {stdout} = await pEvent(cp, 'close');43 t.is(stdout, 'unicorn');44});45test('run method with delay in fixture and stdout and stderr', async t => {46 const cp = fork(fixture);47 cp.stdout.pipe(process.stdout);48 cp.stderr.pipe(process.stderr);49 const {stdout} = await pEvent(cp, 'close');50 t.is(stdout, 'unicorn');51});52test('run method with delay in fixture and stdout and stderr and require', async t => {53 const cp = fork(fixture);54 cp.stdout.pipe(process.stdout);55 cp.stderr.pipe(process.stderr);56 const {stdout} = await pEvent(cp, 'close');57 t.is(stdout, 'unicorn');58});59test('run method with delay in fixture and stdout and stderr and require and readFileSync', async t => {60 const cp = fork(fixture);61 cp.stdout.pipe(process.stdout);62 cp.stderr.pipe(process.stderr);63 const {stdout} = await pEvent(cp, 'close');

Full Screen

Using AI Code Generation

copy

Full Screen

1import test from 'ava';2import {instance} from 'ava';3import {main} from '../src/main.js';4test('main', t => {5 const inst = instance(main);6 inst.run();7 t.is(inst.log[0], 'hello');8});9export function main() {10 console.log('hello');11}12import test from 'ava';13import {instance} from 'ava';14test('callback', t => {15 const inst = instance();16 const cb = inst.cb(err => {17 t.is(err, undefined);18 });19 cb();20});21import test from 'ava';22import {instance} from 'ava';23test('callback', t => {24 const inst = instance();25 const plan = inst.plan(2);26 const cb = inst.cb(plan(err => {27 t.is(err, undefined);28 }));29 cb();30 cb();31});32import test from 'ava';33import {instance} from 'ava';34import {main} from '../src/main.js';35test('main', t => {36 const inst = instance(main);37 inst.run();38 t.is(inst.log[0], 'hello');39});40import test from 'ava';41import {instance} from 'ava';42import {main} from '../src/main.js';43test('main', t => {44 const inst = instance(main);45 inst.run();46 t.is(inst.error[0], 'hello');47});48import test from 'ava';

Full Screen

Using AI Code Generation

copy

Full Screen

1import test from 'ava';2import { run } from 'meteor/avajs:core';3import { Meteor } from 'meteor/meteor';4Meteor.isClient = true;5test('some test', async t => {6 const { stdout } = await run({7 });8 t.true(stdout.includes('ok 1'));9});10import test from 'ava';11import { run } from 'meteor/avajs:core';12import { Meteor } from 'meteor/meteor';13Meteor.isServer = true;14test('some test', async t => {15 const { stdout } = await run({16 });17 t.true(stdout.includes('ok 1'));18});19import test from 'ava';20import { run } from 'meteor/avajs:core';21import { Meteor } from 'meteor/meteor';22Meteor.isCordova = true;23test('some test', async t => {24 const { stdout } = await run({25 });26 t.true(stdout.includes('ok 1'));27});28import test from 'ava';29import { run } from 'meteor/avajs:core';30import { Meteor } from 'meteor/meteor';31Meteor.isDevelopment = true;32test('some test', async t => {33 const { stdout } = await run({34 });35 t.true(stdout.includes('ok 1'));36});37import test from 'ava';38import { run } from 'meteor/avajs:core';39import { Meteor } from 'meteor/meteor';40Meteor.isProduction = true;41test('some test', async t => {42 const { stdout } = await run({43 });

Full Screen

Using AI Code Generation

copy

Full Screen

1const test = require('ava');2const { run } = require('ava');3const { resolve } = require('path');4test('run method exists', t => {5 t.true(typeof run === 'function');6});7test('run method exists', t => {8 t.true(typeof run === 'function');9});10test('run method exists', t => {11 t.true(typeof run === 'function');12});13test('run method exists', t => {14 t.true(typeof run === 'function');15});16test('run method exists', t => {17 t.true(typeof run === 'function');18});19test('run method exists', t => {20 t.true(typeof run === 'function');21});22test('run method exists', t => {23 t.true(typeof run === 'function');24});25test('run method exists', t => {26 t.true(typeof run === 'function');27});28run({29 files: [resolve(__dirname, 'test.js')]30}).then(({ exitCode }) => {31 process.exit(exitCode);32});

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