How to use plugins.init method in Cypress

Best JavaScript code snippet using cypress

plugincollection.js

Source:plugincollection.js Github

copy

Full Screen

...65 } );66 describe( 'load()', () => {67 it( 'should not fail when trying to load 0 plugins (empty array)', () => {68 const plugins = new PluginCollection( editor, availablePlugins );69 return plugins.init( [] )70 .then( () => {71 expect( getPlugins( plugins ) ).to.be.empty;72 } );73 } );74 it( 'should add collection items for loaded plugins', () => {75 const plugins = new PluginCollection( editor, availablePlugins );76 return plugins.init( [ PluginA, PluginB ] )77 .then( () => {78 expect( getPlugins( plugins ).length ).to.equal( 2 );79 expect( plugins.get( PluginA ) ).to.be.an.instanceof( PluginA );80 expect( plugins.get( PluginB ) ).to.be.an.instanceof( PluginB );81 } );82 } );83 it( 'should add collection items for loaded plugins using plugin names', () => {84 const plugins = new PluginCollection( editor, availablePlugins );85 return plugins.init( [ 'A', 'B' ] )86 .then( () => {87 expect( getPlugins( plugins ).length ).to.equal( 2 );88 expect( plugins.get( 'A' ) ).to.be.an.instanceof( PluginA );89 expect( plugins.get( 'B' ) ).to.be.an.instanceof( PluginB );90 } );91 } );92 it( 'should load dependency plugins', () => {93 const plugins = new PluginCollection( editor, availablePlugins );94 const spy = sinon.spy( plugins, '_add' );95 return plugins.init( [ PluginA, PluginC ] )96 .then( loadedPlugins => {97 expect( getPlugins( plugins ).length ).to.equal( 3 );98 expect( getPluginNames( getPluginsFromSpy( spy ) ) )99 .to.deep.equal( [ 'A', 'B', 'C' ], 'order by plugins._add()' );100 expect( getPluginNames( loadedPlugins ) )101 .to.deep.equal( [ 'A', 'B', 'C' ], 'order by returned value' );102 } );103 } );104 it( 'should load dependency plugins defined by plugin names', () => {105 const plugins = new PluginCollection( editor, availablePlugins );106 const spy = sinon.spy( plugins, '_add' );107 return plugins.init( [ 'J' ] )108 .then( loadedPlugins => {109 expect( getPlugins( plugins ).length ).to.equal( 3 );110 expect( getPluginNames( getPluginsFromSpy( spy ) ) )111 .to.deep.equal( [ 'A', 'K', 'J' ], 'order by plugins._add()' );112 expect( getPluginNames( loadedPlugins ) )113 .to.deep.equal( [ 'A', 'K', 'J' ], 'order by returned value' );114 } );115 } );116 it( 'should be ok when dependencies are loaded first', () => {117 const plugins = new PluginCollection( editor, availablePlugins );118 const spy = sinon.spy( plugins, '_add' );119 return plugins.init( [ PluginA, PluginB, PluginC ] )120 .then( loadedPlugins => {121 expect( getPlugins( plugins ).length ).to.equal( 3 );122 expect( getPluginNames( getPluginsFromSpy( spy ) ) )123 .to.deep.equal( [ 'A', 'B', 'C' ], 'order by plugins._add()' );124 expect( getPluginNames( loadedPlugins ) )125 .to.deep.equal( [ 'A', 'B', 'C' ], 'order by returned value' );126 } );127 } );128 it( 'should load deep dependency plugins', () => {129 const plugins = new PluginCollection( editor, availablePlugins );130 const spy = sinon.spy( plugins, '_add' );131 return plugins.init( [ PluginD ] )132 .then( loadedPlugins => {133 expect( getPlugins( plugins ).length ).to.equal( 4 );134 // The order must have dependencies first.135 expect( getPluginNames( getPluginsFromSpy( spy ) ) )136 .to.deep.equal( [ 'A', 'B', 'C', 'D' ], 'order by plugins._add()' );137 expect( getPluginNames( loadedPlugins ) )138 .to.deep.equal( [ 'A', 'B', 'C', 'D' ], 'order by returned value' );139 } );140 } );141 it( 'should handle cross dependency plugins', () => {142 const plugins = new PluginCollection( editor, availablePlugins );143 const spy = sinon.spy( plugins, '_add' );144 return plugins.init( [ PluginA, PluginE ] )145 .then( loadedPlugins => {146 expect( getPlugins( plugins ).length ).to.equal( 3 );147 // The order must have dependencies first.148 expect( getPluginNames( getPluginsFromSpy( spy ) ) )149 .to.deep.equal( [ 'A', 'F', 'E' ], 'order by plugins._add()' );150 expect( getPluginNames( loadedPlugins ) )151 .to.deep.equal( [ 'A', 'F', 'E' ], 'order by returned value' );152 } );153 } );154 it( 'should load grand child classes', () => {155 const plugins = new PluginCollection( editor, availablePlugins );156 return plugins.init( [ PluginG ] )157 .then( () => {158 expect( getPlugins( plugins ).length ).to.equal( 1 );159 } );160 } );161 it( 'should load plugin which does not extend the base Plugin class', () => {162 class Y {}163 const plugins = new PluginCollection( editor, availablePlugins );164 return plugins.init( [ Y ] )165 .then( () => {166 expect( getPlugins( plugins ).length ).to.equal( 1 );167 } );168 } );169 it( 'should load plugin which is a simple function', () => {170 function pluginAsFunction( editor ) {171 this.editor = editor;172 }173 const plugins = new PluginCollection( editor, availablePlugins );174 return plugins.init( [ pluginAsFunction ] )175 .then( () => {176 expect( getPlugins( plugins ).length ).to.equal( 1 );177 } );178 } );179 it( 'should set the `editor` property on loaded plugins', () => {180 const plugins = new PluginCollection( editor, availablePlugins );181 function pluginAsFunction( editor ) {182 this.editor = editor;183 }184 class Y {185 constructor( editor ) {186 this.editor = editor;187 }188 }189 return plugins.init( [ PluginA, PluginB, pluginAsFunction, Y ] )190 .then( () => {191 expect( plugins.get( PluginA ).editor ).to.equal( editor );192 expect( plugins.get( PluginB ).editor ).to.equal( editor );193 expect( plugins.get( pluginAsFunction ).editor ).to.equal( editor );194 expect( plugins.get( Y ).editor ).to.equal( editor );195 } );196 } );197 it( 'should reject on broken plugins (forward the error thrown in a plugin)', () => {198 const consoleErrorStub = sinon.stub( console, 'error' );199 const plugins = new PluginCollection( editor, availablePlugins );200 return plugins.init( [ PluginA, PluginX, PluginB ] )201 // Throw here, so if by any chance plugins.init() was resolved correctly catch() will be stil executed.202 .then( () => {203 throw new Error( 'Test error: this promise should not be resolved successfully' );204 } )205 .catch( err => {206 expect( err ).to.be.an.instanceof( TestError );207 expect( err ).to.have.property( 'message', 'Some error inside a plugin' );208 sinon.assert.calledOnce( consoleErrorStub );209 expect( consoleErrorStub.args[ 0 ][ 0 ] ).to.match( /^plugincollection-load/ );210 } );211 } );212 it( 'should reject when loading non-existent plugin', () => {213 const consoleErrorStub = sinon.stub( console, 'error' );214 const plugins = new PluginCollection( editor, availablePlugins );215 return plugins.init( [ 'NonExistentPlugin' ] )216 // Throw here, so if by any chance plugins.init() was resolved correctly catch() will be stil executed.217 .then( () => {218 throw new Error( 'Test error: this promise should not be resolved successfully' );219 } )220 .catch( err => {221 assertCKEditorError( err, 'plugincollection-plugin-not-found', editor );222 sinon.assert.calledOnce( consoleErrorStub );223 expect( consoleErrorStub.args[ 0 ][ 0 ] ).to.match( /^plugincollection-plugin-not-found/ );224 } );225 } );226 it( 'should load chosen plugins (plugins and removePlugins are constructors)', () => {227 const plugins = new PluginCollection( editor, availablePlugins );228 return plugins.init( [ PluginA, PluginB, PluginC ], [ PluginA ] )229 .then( () => {230 expect( getPlugins( plugins ).length ).to.equal( 2 );231 expect( plugins.get( PluginB ) ).to.be.an.instanceof( PluginB );232 expect( plugins.get( PluginC ) ).to.be.an.instanceof( PluginC );233 } );234 } );235 it( 'should load chosen plugins (plugins are constructors, removePlugins are names)', () => {236 const plugins = new PluginCollection( editor, availablePlugins );237 return plugins.init( [ PluginA, PluginB, PluginC ], [ 'A' ] )238 .then( () => {239 expect( getPlugins( plugins ).length ).to.equal( 2 );240 expect( plugins.get( PluginB ) ).to.be.an.instanceof( PluginB );241 expect( plugins.get( PluginC ) ).to.be.an.instanceof( PluginC );242 } );243 } );244 it( 'should load chosen plugins (plugins and removePlugins are names)', () => {245 const plugins = new PluginCollection( editor, availablePlugins );246 return plugins.init( [ 'A', 'B', 'C' ], [ 'A' ] )247 .then( () => {248 expect( getPlugins( plugins ).length ).to.equal( 2 );249 expect( plugins.get( PluginB ) ).to.be.an.instanceof( PluginB );250 expect( plugins.get( PluginC ) ).to.be.an.instanceof( PluginC );251 } );252 } );253 it( 'should load chosen plugins (plugins are names, removePlugins are constructors)', () => {254 const plugins = new PluginCollection( editor, availablePlugins );255 return plugins.init( [ 'A', 'B', 'C' ], [ PluginA ] )256 .then( () => {257 expect( getPlugins( plugins ).length ).to.equal( 2 );258 expect( plugins.get( PluginB ) ).to.be.an.instanceof( PluginB );259 expect( plugins.get( PluginC ) ).to.be.an.instanceof( PluginC );260 } );261 } );262 it( 'should load chosen plugins (plugins are names, removePlugins contains an anonymous plugin)', () => {263 class AnonymousPlugin {}264 const plugins = new PluginCollection( editor, [ AnonymousPlugin ].concat( availablePlugins ) );265 return plugins.init( [ AnonymousPlugin, 'A', 'B' ], [ AnonymousPlugin ] )266 .then( () => {267 expect( getPlugins( plugins ).length ).to.equal( 2 );268 expect( plugins.get( PluginA ) ).to.be.an.instanceof( PluginA );269 expect( plugins.get( PluginB ) ).to.be.an.instanceof( PluginB );270 } );271 } );272 it( 'should throw when context plugin requires not a context plugin', async () => {273 class FooContextPlugin extends ContextPlugin {}274 FooContextPlugin.requires = [ PluginA ];275 const plugins = new PluginCollection( editor, [ FooContextPlugin, PluginA ] );276 const consoleErrorStub = sinon.stub( console, 'error' );277 let error;278 try {279 await plugins.init( [ FooContextPlugin ] );280 } catch ( err ) {281 error = err;282 }283 assertCKEditorError( error, /^plugincollection-context-required/ );284 sinon.assert.calledOnce( consoleErrorStub );285 } );286 it( 'should not throw when non context plugin requires context plugin', async () => {287 class FooContextPlugin extends ContextPlugin {}288 class BarPlugin extends Plugin {}289 BarPlugin.requires = [ FooContextPlugin ];290 const plugins = new PluginCollection( editor, [ FooContextPlugin, BarPlugin ] );291 await plugins.init( [ BarPlugin ] );292 expect( getPlugins( plugins ) ).to.length( 2 );293 } );294 it( 'should not throw when context plugin requires context plugin', async () => {295 class FooContextPlugin extends ContextPlugin {}296 class BarContextPlugin extends ContextPlugin {}297 BarContextPlugin.requires = [ FooContextPlugin ];298 const plugins = new PluginCollection( editor, [ FooContextPlugin, BarContextPlugin ] );299 await plugins.init( [ BarContextPlugin ] );300 expect( getPlugins( plugins ) ).to.length( 2 );301 } );302 it( 'should reject when loaded plugin requires not allowed plugins', () => {303 const consoleErrorStub = sinon.stub( console, 'error' );304 const plugins = new PluginCollection( editor, availablePlugins );305 return plugins.init( [ PluginA, PluginB, PluginC, PluginD ], [ PluginA, PluginB ] )306 // Throw here, so if by any chance plugins.init() was resolved correctly catch() will be still executed.307 .then( () => {308 throw new Error( 'Test error: this promise should not be resolved successfully' );309 } )310 .catch( err => {311 assertCKEditorError( err, /^plugincollection-required/, editor );312 sinon.assert.calledTwice( consoleErrorStub );313 } );314 } );315 it( 'should reject when loading more than one plugin with the same name', () => {316 const plugins = new PluginCollection( editor );317 const consoleErrorStub = sinon.stub( console, 'error' );318 return plugins.init( [ PluginFoo, AnotherPluginFoo ] )319 .then( () => {320 throw new Error( 'The `init()` method should fail.' );321 } )322 .catch( err => {323 assertCKEditorError( err, /^plugincollection-plugin-name-conflict/, null, {324 pluginName: 'Foo',325 plugin1: PluginFoo,326 plugin2: AnotherPluginFoo327 } );328 sinon.assert.calledOnce( consoleErrorStub );329 } );330 } );331 it( 'should reject when loading more than one plugin with the same name (plugin requires plugin with the same name)', () => {332 PluginFoo.requires = [ AnotherPluginFoo ];333 const plugins = new PluginCollection( editor );334 const consoleErrorStub = sinon.stub( console, 'error' );335 return plugins.init( [ PluginFoo ] )336 .then( () => {337 throw new Error( 'The `init()` method should fail.' );338 } )339 .catch( err => {340 assertCKEditorError( err, /^plugincollection-plugin-name-conflict/, null );341 sinon.assert.calledOnce( consoleErrorStub );342 } );343 } );344 it( 'should reject when loading more than one plugin with the same name' +345 '(plugin with the same name is built-in the PluginCollection)', () => {346 availablePlugins = [ PluginFoo ];347 const plugins = new PluginCollection( editor, availablePlugins );348 const consoleErrorStub = sinon.stub( console, 'error' );349 return plugins.init( [ 'Foo', AnotherPluginFoo ] )350 .then( () => {351 throw new Error( 'The `init()` method should fail.' );352 } )353 .catch( err => {354 assertCKEditorError( err, /^plugincollection-plugin-name-conflict/, null );355 sinon.assert.calledOnce( consoleErrorStub );356 } );357 } );358 it( 'should get plugin from external plugins instead of creating new instance', async () => {359 const externalPlugins = new PluginCollection( editor );360 await externalPlugins.init( [ PluginA, PluginB ] );361 const plugins = new PluginCollection( editor, [], Array.from( externalPlugins ) );362 await plugins.init( [ PluginA ] );363 expect( getPlugins( plugins ) ).to.length( 1 );364 expect( plugins.get( PluginA ) ).to.equal( externalPlugins.get( PluginA ) ).to.instanceof( PluginA );365 } );366 it( 'should get plugin by name from external plugins instead of creating new instance', async () => {367 const externalPlugins = new PluginCollection( editor );368 await externalPlugins.init( [ PluginA, PluginB ] );369 const plugins = new PluginCollection( editor, [], Array.from( externalPlugins ) );370 await plugins.init( [ 'A' ] );371 expect( getPlugins( plugins ) ).to.length( 1 );372 expect( plugins.get( PluginA ) ).to.equal( externalPlugins.get( PluginA ) ).to.instanceof( PluginA );373 } );374 it( 'should get dependency of plugin from external plugins instead of creating new instance', async () => {375 const externalPlugins = new PluginCollection( editor );376 await externalPlugins.init( [ PluginA, PluginB ] );377 const plugins = new PluginCollection( editor, [], Array.from( externalPlugins ) );378 await plugins.init( [ PluginC ] );379 expect( getPlugins( plugins ) ).to.length( 2 );380 expect( plugins.get( PluginB ) ).to.equal( externalPlugins.get( PluginB ) ).to.instanceof( PluginB );381 expect( plugins.get( PluginC ) ).to.instanceof( PluginC );382 } );383 } );384 describe( 'get()', () => {385 it( 'retrieves plugin by its constructor', () => {386 class SomePlugin extends Plugin {}387 availablePlugins.push( SomePlugin );388 const plugins = new PluginCollection( editor, availablePlugins );389 return plugins.init( [ SomePlugin ] )390 .then( () => {391 expect( plugins.get( SomePlugin ) ).to.be.instanceOf( SomePlugin );392 } );393 } );394 it( 'retrieves plugin by its name and constructor', () => {395 class SomePlugin extends Plugin {}396 SomePlugin.pluginName = 'foo/bar';397 availablePlugins.push( SomePlugin );398 const plugins = new PluginCollection( editor, availablePlugins );399 return plugins.init( [ SomePlugin ] )400 .then( () => {401 expect( plugins.get( 'foo/bar' ) ).to.be.instanceOf( SomePlugin );402 expect( plugins.get( SomePlugin ) ).to.be.instanceOf( SomePlugin );403 } );404 } );405 it( 'throws if plugin cannot be retrieved by name', () => {406 const plugins = new PluginCollection( editor, availablePlugins );407 return plugins.init( [] ).then( () => {408 expectToThrowCKEditorError( () => plugins.get( 'foo' ),409 /^plugincollection-plugin-not-loaded/, editor, { plugin: 'foo' }410 );411 } );412 } );413 it( 'throws if plugin cannot be retrieved by class', () => {414 class SomePlugin extends Plugin {}415 SomePlugin.pluginName = 'foo';416 const plugins = new PluginCollection( editor, availablePlugins );417 return plugins.init( [] ).then( () => {418 expectToThrowCKEditorError( () => plugins.get( SomePlugin ),419 /^plugincollection-plugin-not-loaded/, editor, { plugin: 'foo' } );420 } );421 } );422 it( 'throws if plugin cannot be retrieved by class (class name in error)', () => {423 class SomePlugin extends Plugin {}424 const plugins = new PluginCollection( editor, availablePlugins );425 return plugins.init( [] ).then( () => {426 expectToThrowCKEditorError( () => plugins.get( SomePlugin ),427 /^plugincollection-plugin-not-loaded/,428 editor, { plugin: 'SomePlugin' }429 );430 } );431 } );432 } );433 describe( 'has()', () => {434 let plugins;435 beforeEach( () => {436 plugins = new PluginCollection( editor, availablePlugins );437 } );438 it( 'returns false if plugins is not loaded (retrieved by name)', () => {439 expect( plugins.has( 'foobar' ) ).to.be.false;440 } );441 it( 'returns false if plugins is not loaded (retrieved by class)', () => {442 class SomePlugin extends Plugin {443 }444 expect( plugins.has( SomePlugin ) ).to.be.false;445 } );446 it( 'returns true if plugins is loaded (retrieved by name)', () => {447 return plugins.init( [ PluginA ] ).then( () => {448 expect( plugins.has( 'A' ) ).to.be.true;449 } );450 } );451 it( 'returns true if plugins is loaded (retrieved by class)', () => {452 return plugins.init( [ PluginA ] ).then( () => {453 expect( plugins.has( PluginA ) ).to.be.true;454 } );455 } );456 } );457 describe( 'destroy()', () => {458 it( 'calls Plugin#destroy() method on every loaded plugin', () => {459 let destroySpyForPluginA, destroySpyForPluginB;460 const plugins = new PluginCollection( editor, [] );461 return plugins.init( [ PluginA, PluginB ] )462 .then( () => {463 destroySpyForPluginA = sinon.spy( plugins.get( PluginA ), 'destroy' );464 destroySpyForPluginB = sinon.spy( plugins.get( PluginB ), 'destroy' );465 return plugins.destroy();466 } )467 .then( () => {468 expect( destroySpyForPluginA.calledOnce ).to.equal( true );469 expect( destroySpyForPluginB.calledOnce ).to.equal( true );470 } );471 } );472 it( 'waits until all plugins are destroyed', () => {473 const destroyedPlugins = [];474 class AsynchronousPluginA extends Plugin {475 destroy() {476 return new Promise( resolve => {477 setTimeout( () => {478 super.destroy();479 destroyedPlugins.push( 'AsynchronousPluginA.destroy()' );480 resolve();481 } );482 } );483 }484 }485 class AsynchronousPluginB extends Plugin {486 destroy() {487 return new Promise( resolve => {488 setTimeout( () => {489 super.destroy();490 destroyedPlugins.push( 'AsynchronousPluginB.destroy()' );491 resolve();492 } );493 } );494 }495 }496 const plugins = new PluginCollection( editor, [] );497 return plugins.init( [ AsynchronousPluginA, AsynchronousPluginB ] )498 .then( () => plugins.destroy() )499 .then( () => {500 expect( destroyedPlugins ).to.contain( 'AsynchronousPluginB.destroy()' );501 expect( destroyedPlugins ).to.contain( 'AsynchronousPluginA.destroy()' );502 } );503 } );504 it( 'does not execute Plugin#destroy() for plugins which do not have this method', () => {505 class FooPlugin {506 constructor( editor ) {507 this.editor = editor;508 }509 }510 const plugins = new PluginCollection( editor, [] );511 return plugins.init( [ PluginA, FooPlugin ] )512 .then( () => plugins.destroy() )513 .then( destroyedPlugins => {514 expect( destroyedPlugins.length ).to.equal( 1 );515 } );516 } );517 } );518 describe( 'iterator', () => {519 it( 'exists', () => {520 const plugins = new PluginCollection( editor, availablePlugins );521 expect( plugins ).to.have.property( Symbol.iterator );522 } );523 it( 'returns only plugins by constructors', () => {524 class SomePlugin1 extends Plugin {}525 class SomePlugin2 extends Plugin {}526 SomePlugin2.pluginName = 'foo/bar';527 availablePlugins.push( SomePlugin1 );528 availablePlugins.push( SomePlugin2 );529 const plugins = new PluginCollection( editor, availablePlugins );530 return plugins.init( [ SomePlugin1, SomePlugin2 ] )531 .then( () => {532 const pluginConstructors = Array.from( plugins )533 .map( entry => entry[ 0 ] );534 expect( pluginConstructors ).to.have.members( [ SomePlugin1, SomePlugin2 ] );535 } );536 } );537 } );538} );539function createPlugin( name ) {540 const P = class extends Plugin {541 constructor( editor ) {542 super( editor );543 this.pluginName = name;544 }...

Full Screen

Full Screen

core.js

Source:core.js Github

copy

Full Screen

1$( document ).ajaxStart(function() {2 NProgress.start();3});4$( document ).ajaxComplete(function() {5 NProgress.done();6});7$(document).ajaxSuccess(function() {8 NProgress.done();9});10Core = {11 init:function(){12 $(document).ready(function(){13 cPlugins.initAll();14 Fjax.dedectModal();15 dTable.dedectTable();16 Fjax.dedectConfirm();17 $( '#dl-menu' ).dlmenu();18 });19 },20 getApiPost:function(route,data,callback){21 $.ajax({22 url:route,23 type :"POST",24 data:data,25 success:function(deger){callback(deger);}26 });27 },28 getApiGet:function(route,data,callback){29 $.ajax({30 url:route,31 type :"GET",32 data:data,33 success:function(deger){callback(deger);}34 });35 },36 createID:function(){37 var text = "";38 var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";39 for( var i=0; i < 5; i++ )40 text += possible.charAt(Math.floor(Math.random() * possible.length));41 return text;42 }43}44cPlugins = {45 initAll:function(){46 cPlugins.initChosen();47 cPlugins.initDatePicker();48 cPlugins.initAutoComplete();49 cPlugins.initMask();50 cPlugins.initTipsy();51 cPlugins.initChecbox();52 },53 initChecbox:function(){54 $(".checkboxcustom").each(function(){$(this).checkbox();});55 $(".checkboxcustom1").each(function(){$(this).checkbox(56 {57 buttonStyle: 'btn-base',58 buttonStyleChecked: 'btn-success',59 checkedClass: 'icon-check',60 uncheckedClass: 'icon-check-empty'61 }62 );});63 $(".checkboxcustom2").each(function(){$(this).checkbox({buttonStyle: 'btn-danger',buttonStyleChecked: 'btn-success',checkedClass: 'icon-check',uncheckedClass: 'icon-check-empty'});});64 },65 initChosen:function(){66 $(".select").each(function(){67 $(this).chosen();68 });69 },70 initMask:function(){71 $(".tarih").mask("99/99/9999");72 $(".telefon").mask("(999) 999-9999");73 },74 initDatePicker:function(){75 $(".dpform").each(function(){76 $(this).datepicker({77 format: 'mm/dd/yyyy'78 });79 });80 },81 initAutoComplete:function(){82 $(".autocomplete").attr('autocomplete', 'off');83 $('.autocomplete').each(function(){84 var source = $(this).attr("data-source");85 if (typeof ac_siteURL != 'undefined') {86 source = ac_siteURL+ source;87 }88 if(source){89 $(this).typeahead({90 source: function (query, process) {91 return $.get(source, { query: query }, function (data) {92 if(query.length<=1){window.disdata='';}93 if(!window.disdata){94 window.disdata=data;95 return process(data.options);96 }97 });98 }99 });100 }else{101 console.warn("autocomplete için data-source belirtilmemiş");102 }103 });104 },105 initTipsy:function(){106 $(".tipUst").tipsy({gravity: 's'});107 $(".tipAlt").tipsy({gravity: 'n'});108 $(".tipSol").tipsy({gravity: 'e'});109 $(".tipSag").tipsy({gravity: 'w'});110 }111}112Fjax = {113 dedectModal:function(){114 $("a.modalfjax").each(function(){115 $(this).bind("click",function(){116 Core.getApiGet($(this).attr("href"),{type:'modal'},function(deger){117 $("#temp").html(deger);118 cPlugins.initAll();119 dTable.dedectTableModal();120 });121 return false;122 });123 });124 },125 dedectConfirm:function(){126 $("a.confirm").each(function(){127 $(this).bind("click",function(){128 var confirmMessage = $(this).attr("data-message");129 if(confirmMessage){130 if(confirm(confirmMessage)==true){131 location.href=$(this).attr("href");132 }else{133 return false;134 }135 }136 return false;137 });138 });139 }140}141dTable = {142 dedectTable:function(){143 dTable.dedectTableConsole(".dtable");144 },145 dedectTableModal:function(){146 dTable.dedectTableConsole(".modal-dialog .dtable");147 },148 dedectTableConsole:function(className){149 $(className).each(function(){150 var isAjax = $(this).attr("data-table-ajax");151 var source = $(this).attr("data-source");152 var seriColuns = $(this).attr("data-columns");153 var seriVals= $(this).attr("data-vals");154 var customWhere= $(this).attr("data-customwhere");155 if (typeof siteURL != 'undefined'){156 var setting = {157 "oLanguage": {158 "sUrl": siteURL+'datatable/getlanguagedata'159 },160 "iDisplayLength": 50161 };162 }163 if(source){164 setting = {165 "bProcessing": true,166 "bServerSide": true,167 "bDestroy": true,168 "sAjaxSource": source,169 "fnServerData": function (sSource, aoData, fnCallback) {170 aoData.push({"name":"columns","value":seriColuns});171 aoData.push({"name":"columnsval","value":seriVals});172 aoData.push({"name":"customwhere","value":customWhere});173 $.ajax({174 "dataType": "json",175 "type": "POST",176 "url": sSource,177 "data": aoData,178 "success": fnCallback179 }).done(function(){180 cPlugins.initAll();181 Fjax.dedectConfirm();182 });183 },184 "oLanguage": {185 "sUrl": siteURL+'datatable/getlanguagedata'186 },187 "iDisplayLength": 50188 };189 }190 var Dtablem = $(this).dataTable(setting);191 //dTable.changeContentFilter(Dtablem);192 });193 },194 changeContentFilter:function(oTable){195 alert('merba');196 $(".tfoot").each( function ( i ) {197 alert('selmai');198 this.innerHTML = fnCreateSelect( oTable.fnGetColumnData(i) );199 $('select', this).change( function () {200 oTable.fnFilter( $(this).val(), i );201 } );202 } );203 cPlugins.initAll();204 }205}...

Full Screen

Full Screen

socialShitLoader.js

Source:socialShitLoader.js Github

copy

Full Screen

1function initAllSocialPlugins(){2 if(!isInitSocialPlugins()){3 initSocialPlugins(); 4 initAllFacebookLikeButtons(); 5 }6 7}8function initSocialPlugins(){9 addScript('https://apis.google.com/js/plusone.js');10 addScript('http://platform.twitter.com/widgets.js');11 addScript('http://assets.pinterest.com/js/pinit.js');12 $('body').attr('data-social-plugins-init',true);13}14function initAllFacebookLikeButtons(){15 $('.facebookLikeButtonContainer').each(function(){16 initFacebookLikePlugin(this);17 });18}19function initFacebookLikePlugin(elementId){20 var iframe = $('<iframe></iframe>');21 var $elem = $(elementId);22 var params = {23 href:$elem.attr('data-facebook-src'),24 locate: $('body').attr('data-locale-code'),25 layout: 'button_count',26 show_faces: false,27 width: 130,28 action: 'like',29 colorscheme: 'light',30 height: 8031 };32 iframe.attr({33 scrolling: 'no',34 frameborder: 0,35 src: 'http://www.facebook.com/plugins/like.php?'+jQuery.param(params)36 }).css({37 border: 'none',38 overflow: 'hidden',39 height: '20px',40 width: '130px',41 allowTransparency: 'true'42 }); 43 $(elementId).html(iframe); 44}45function isInitSocialPlugins(){46 47 if(typeof $('body').attr('data-social-plugins-init') != 'undefined' ){48 return true;49 } else {50 return false;51 }52 //console.log(typeof $('body').attr('data-social-plugins-init'));53 //return $('body').hasAttr('data-social-plugins-init');54}55function addScript(src){56 var s = document.createElement('script');57 s.type = 'text/javascript';58 s.async = true;59 s.src = src;60 var x = document.getElementsByTagName('script')[0];61 x.parentNode.insertBefore(s, x); ...

Full Screen

Full Screen

register_rollup_search_strategy.test.js

Source:register_rollup_search_strategy.test.js Github

copy

Full Screen

1/*2* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one3* or more contributor license agreements. Licensed under the Elastic License;4* you may not use this file except in compliance with the Elastic License.5*/6import { registerRollupSearchStrategy } from './register_rollup_search_strategy';7describe('Register Rollup Search Strategy', () => {8 let kbnServer;9 let metrics;10 beforeEach(() => {11 const afterPluginsInit = jest.fn((callback) => callback());12 kbnServer = {13 afterPluginsInit,14 };15 metrics = {16 addSearchStrategy: jest.fn().mockName('addSearchStrategy'),17 AbstractSearchRequest: jest.fn().mockName('AbstractSearchRequest'),18 AbstractSearchStrategy: jest.fn().mockName('AbstractSearchStrategy'),19 DefaultSearchCapabilities: jest.fn().mockName('DefaultSearchCapabilities'),20 };21 });22 test('should run initialization on "afterPluginsInit" hook', () => {23 registerRollupSearchStrategy(kbnServer, {24 plugins: {},25 });26 expect(kbnServer.afterPluginsInit).toHaveBeenCalled();27 });28 test('should run initialization if metrics plugin available', () => {29 registerRollupSearchStrategy(kbnServer, {30 plugins: {31 metrics,32 },33 });34 expect(metrics.addSearchStrategy).toHaveBeenCalled();35 });36 test('should not run initialization if metrics plugin unavailable', () => {37 registerRollupSearchStrategy(kbnServer, {38 plugins: {},39 });40 expect(metrics.addSearchStrategy).not.toHaveBeenCalled();41 });...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1'use strict';2Object.defineProperty(exports, "__esModule", {3 value: true4});5var _scan_mixin = require('./scan_mixin');6Object.defineProperty(exports, 'scanMixin', {7 enumerable: true,8 get: function () {9 return _scan_mixin.scanMixin;10 }11});12var _initialize_mixin = require('./initialize_mixin');13Object.defineProperty(exports, 'initializeMixin', {14 enumerable: true,15 get: function () {16 return _initialize_mixin.initializeMixin;17 }18});19var _wait_for_plugins_init = require('./wait_for_plugins_init');20Object.defineProperty(exports, 'waitForInitSetupMixin', {21 enumerable: true,22 get: function () {23 return _wait_for_plugins_init.waitForInitSetupMixin;24 }25});26Object.defineProperty(exports, 'waitForInitResolveMixin', {27 enumerable: true,28 get: function () {29 return _wait_for_plugins_init.waitForInitResolveMixin;30 }...

Full Screen

Full Screen

boot.js

Source:boot.js Github

copy

Full Screen

1/* global Fluid, CONFIG */2Fluid.boot = {};3Fluid.boot.registerEvents = function() {4 Fluid.events.billboard();5 Fluid.events.registerNavbarEvent();6 Fluid.events.registerParallaxEvent();7 Fluid.events.registerScrollDownArrowEvent();8 Fluid.events.registerScrollTopArrowEvent();9 Fluid.events.registerImageLoadedEvent();10};11Fluid.boot.initPlugins = function() {12 CONFIG.anchorjs.enable && Fluid.plugins.initAnchor();13 CONFIG.toc.enable && Fluid.plugins.initTocBot();14 CONFIG.image_zoom.enable && Fluid.plugins.initFancyBox();15 CONFIG.copy_btn && Fluid.plugins.initCopyCode();16};17document.addEventListener('DOMContentLoaded', function() {18 Fluid.boot.registerEvents();19 Fluid.boot.initPlugins();...

Full Screen

Full Screen

application.js

Source:application.js Github

copy

Full Screen

1import "bootstrap";2// import 'mapbox-gl/dist/mapbox-gl.css'; // <-- you need to uncomment the stylesheet_pack_tag in the layout!3import { initMapbox } from '../plugins/init_mapbox';4import { initMapboxForShow } from '../plugins/init_mapboxforshow';5initMapbox();6initMapboxForShow();7// import { startTime } from '../plugins/init_currenttime';8// startTime();9// import { make_copy_button } from '../plugins/init_copytoclipboard';...

Full Screen

Full Screen

plugins.js

Source:plugins.js Github

copy

Full Screen

...6 }7 }8};9$(document).ready(function(){10 $.monstra.plugins.init();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const plugins = require('@cypress/code-coverage/task')2module.exports = (on, config) => {3 plugins(on, config)4}5{6}7- [Cypress Dashboard GitHub Repository](

Full Screen

Using AI Code Generation

copy

Full Screen

1const cucumber = require('cypress-cucumber-preprocessor').default2const browserify = require('@cypress/browserify-preprocessor')3browserifyOptions.browserifyOptions.plugin.unshift(['tsify'])4module.exports = (on, config) => {5 on('file:preprocessor', cucumber())6 on('file:preprocessor', browserify(browserifyOptions))7}8import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'9Given('I open Google page', () => {10})11When('I type {string} in the search box', (text) => {12 cy.get('input[name="q"]').type(text)13})14Then('I press enter', () => {15 cy.get('input[name="q"]').type('{enter}')16})17Then('I should see {string} in the search results', (text) => {18 cy.get('h3').contains(text)19})20{21}

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = (on, config) => {2 on('file:preprocessor', cucumber());3}4import './commands';5import 'cypress-cucumber-preprocessor/steps';6{7}8module.exports = (on, config) => {9 on('file:preprocessor', cucumber());10}11{12}13import './commands';14import 'cypress-cucumber-preprocessor/steps';15module.exports = (on, config) => {16 on('file:preprocessor', cucumber());17}18{19}20import './commands';21import 'cypress-cucumber-preprocessor/steps';22module.exports = (on, config) => {23 on('file:preprocessor', cucumber());24}25{26}27import './commands';28import 'cypress-cucumber-preprocessor/steps';29module.exports = (on, config) => {30 on('file:preprocessor', cucumber());31}32{33}

Full Screen

Using AI Code Generation

copy

Full Screen

1import plugins from './plugins';2plugins.init();3import plugins from './plugins';4plugins.init();5import plugins from './plugins';6plugins.init();7import plugins from './plugins';8plugins.init();9import plugins from './plugins';10plugins.init();11import plugins from './plugins';12plugins.init();13import plugins from './plugins';14plugins.init();15import plugins from './plugins';16plugins.init();17import plugins from './plugins';18plugins.init();

Full Screen

Using AI Code Generation

copy

Full Screen

1import 'cypress-plugin-retries'2Cypress.config('retries', { runMode: 2, openMode: 0 })3describe('My First Test', () => {4 it('Visits the Kitchen Sink', () => {5 })6 it('Fails the test', () => {7 expect(true).to.equal(false)8 })9})10import 'cypress-plugin-retries'11Cypress.config('retries', { runMode: 2, openMode: 0 })12describe('My First Test', () => {13 beforeEach(() => {14 Cypress.currentTest.retries(2)15 })16 it('Visits the Kitchen Sink', () => {17 })18 it('Fails the test', () => {19 expect(true).to.equal(false)20 })21})22import 'cypress-plugin-retries'23Cypress.config('retries', { runMode: 2, openMode: 0 })24describe('My First Test', () => {25 it('Visits the Kitchen Sink', () => {26 })27 it('Fails the test', () => {28 expect(true).to.equal(false)29 }).retries(2)30})31import 'cypress-plugin-retries'32Cypress.config('retries', { runMode: 2, openMode: 0 })33describe('My First Test', () => {34 it('Visits the Kitchen Sink', () => {35 })36 it('Fails the test', () => {37 expect(true).to.equal(false)38 }).retries(Cypress.currentTest

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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