How to use invoker method in Playwright Internal

Best JavaScript code snippet using playwright-internal

command.spec.js

Source:command.spec.js Github

copy

Full Screen

1/**2 * @author NHN. FE Development Team <dl_javascript@nhn.com>3 * @fileoverview Tests command with command-factory4 */5import snippet from 'tui-code-snippet';6import fabric from 'fabric';7import Graphics from '@/graphics';8import Invoker from '@/invoker';9import commandFactory from '@/factory/command';10import { Promise } from '@/util';11import { commandNames as commands } from '@/consts';12describe('commandFactory', () => {13 let invoker, mockImage, canvas, graphics, dimensions;14 beforeEach(() => {15 dimensions = {16 width: 100,17 height: 100,18 };19 graphics = new Graphics(document.createElement('canvas'));20 invoker = new Invoker();21 mockImage = new fabric.Image(null, dimensions);22 graphics.setCanvasImage('', mockImage);23 canvas = graphics.getCanvas();24 });25 describe('functions', () => {26 it('can register custom command', (done) => {27 const testCommand = {28 name: 'testCommand',29 execute() {},30 undo() {},31 };32 spyOn(testCommand, 'execute').and.returnValue(Promise.resolve('testCommand'));33 spyOn(testCommand, 'undo').and.returnValue(Promise.resolve());34 commandFactory.register(testCommand);35 const command = commandFactory.create('testCommand');36 expect(command).not.toBe(null);37 invoker38 .execute('testCommand', graphics)39 .then((commandName) => {40 expect(commandName).toBe('testCommand');41 expect(testCommand.execute).toHaveBeenCalledWith(graphics);42 done();43 })44 ['catch']((message) => {45 fail(message);46 done();47 });48 });49 it('can pass parameters on execute', (done) => {50 commandFactory.register({51 name: 'testCommand',52 execute(compMap, obj1, obj2, obj3) {53 expect(obj1).toBe(1);54 expect(obj2).toBe(2);55 expect(obj3).toBe(3);56 return Promise.resolve();57 },58 });59 invoker60 .execute('testCommand', graphics, 1, 2, 3)61 .then(() => {62 done();63 })64 ['catch']((message) => {65 fail(message);66 done();67 });68 });69 it('can pass parameters on undo', (done) => {70 commandFactory.register({71 name: 'testCommand',72 execute() {73 return Promise.resolve();74 },75 undo(compMap, obj1, obj2, obj3) {76 expect(obj1).toBe(1);77 expect(obj2).toBe(2);78 expect(obj3).toBe(3);79 return Promise.resolve();80 },81 });82 invoker83 .execute('testCommand', graphics, 1, 2, 3)84 .then(() => invoker.undo())85 .then(() => done())86 ['catch']((message) => {87 fail(message);88 done();89 });90 });91 });92 describe('addObjectCommand', () => {93 let obj;94 it('should stamp object', (done) => {95 obj = new fabric.Rect();96 invoker.execute(commands.ADD_OBJECT, graphics, obj).then(() => {97 expect(snippet.hasStamp(obj)).toBe(true);98 done();99 });100 });101 it('should add object to canvas', (done) => {102 obj = new fabric.Rect();103 invoker.execute(commands.ADD_OBJECT, graphics, obj).then(() => {104 expect(canvas.contains(obj)).toBe(true);105 done();106 });107 });108 it('"undo()" should remove object from canvas', (done) => {109 obj = new fabric.Rect();110 invoker111 .execute(commands.ADD_OBJECT, graphics, obj)112 .then(() => invoker.undo())113 .then(() => {114 expect(canvas.contains(obj)).toBe(false);115 done();116 });117 });118 });119 describe('changeSelectionCommand', () => {120 let obj;121 beforeEach(() => {122 spyOn(canvas, 'getPointer');123 obj = new fabric.Rect({124 width: 10,125 height: 10,126 top: 10,127 left: 10,128 scaleX: 1,129 scaleY: 1,130 angle: 0,131 });132 graphics._addFabricObject(obj);133 graphics._onMouseDown({ target: obj });134 const props = [135 {136 id: graphics.getObjectId(obj),137 width: 30,138 height: 30,139 top: 30,140 left: 30,141 scaleX: 0.5,142 scaleY: 0.5,143 angle: 10,144 },145 ];146 const makeCommand = commandFactory.create(commands.CHANGE_SELECTION, graphics, props);147 makeCommand.execute(graphics, props);148 invoker.pushUndoStack(makeCommand);149 });150 it('should work undo command correctly', (done) => {151 invoker.undo().then(() => {152 expect(obj.width).toBe(10);153 expect(obj.height).toBe(10);154 expect(obj.left).toBe(10);155 expect(obj.top).toBe(10);156 expect(obj.scaleX).toBe(1);157 expect(obj.scaleY).toBe(1);158 expect(obj.angle).toBe(0);159 done();160 });161 });162 it('should work redo command correctly', (done) => {163 invoker.undo().then(() => {164 invoker.redo().then(() => {165 expect(obj.width).toBe(30);166 expect(obj.height).toBe(30);167 expect(obj.left).toBe(30);168 expect(obj.top).toBe(30);169 expect(obj.scaleX).toBe(0.5);170 expect(obj.scaleY).toBe(0.5);171 expect(obj.angle).toBe(10);172 done();173 });174 });175 });176 });177 describe('loadImageCommand', () => {178 const imageURL = 'base/tests/fixtures/sampleImage.jpg';179 beforeEach(() => {180 graphics.setCanvasImage('', null);181 });182 it('should clear canvas', () => {183 spyOn(canvas, 'clear');184 invoker.execute(commands.LOAD_IMAGE, graphics, 'image', imageURL);185 expect(canvas.clear).toHaveBeenCalled();186 });187 it('should load new image', (done) => {188 invoker.execute(commands.LOAD_IMAGE, graphics, 'image', imageURL).then((sizeChange) => {189 expect(graphics.getImageName()).toEqual('image');190 expect(graphics.getCanvasImage().getSrc()).toContain(imageURL);191 expect(sizeChange.oldWidth).toEqual(jasmine.any(Number));192 expect(sizeChange.oldHeight).toEqual(jasmine.any(Number));193 expect(sizeChange.newWidth).toEqual(jasmine.any(Number));194 expect(sizeChange.newHeight).toEqual(jasmine.any(Number));195 done();196 });197 });198 it('After running the LOAD_IMAGE command, existing objects should not include cropzone.', (done) => {199 const objCropzone = new fabric.Object({ type: 'cropzone' });200 invoker.execute(commands.ADD_OBJECT, graphics, objCropzone).then(() => {201 invoker.execute(commands.LOAD_IMAGE, graphics, 'image', imageURL).then(() => {202 const lastUndoIndex = invoker._undoStack.length - 1;203 const savedObjects = invoker._undoStack[lastUndoIndex].undoData.objects;204 expect(savedObjects.length).toBe(0);205 done();206 });207 });208 });209 it('`evented` attribute of the saved object must be true after LOAD_IMAGE.', (done) => {210 const objCircle = new fabric.Object({211 type: 'circle',212 evented: false,213 });214 invoker.execute(commands.ADD_OBJECT, graphics, objCircle).then(() => {215 invoker.execute(commands.LOAD_IMAGE, graphics, 'image', imageURL).then(() => {216 const lastUndoIndex = invoker._undoStack.length - 1;217 const [savedObject] = invoker._undoStack[lastUndoIndex].undoData.objects;218 expect(savedObject.evented).toBe(true);219 done();220 });221 });222 });223 it('"undo()" should clear image if not exists prev image', (done) => {224 invoker225 .execute(commands.LOAD_IMAGE, graphics, 'image', imageURL)226 .then(() => invoker.undo())227 .then(() => {228 expect(graphics.getCanvasImage()).toBe(null);229 expect(graphics.getImageName()).toBe('');230 done();231 });232 });233 it('"undo()" should restore to prev image', (done) => {234 const newImageURL = 'base/tests/fixtures/TOAST%20UI%20Component.png';235 invoker236 .execute(commands.LOAD_IMAGE, graphics, 'image', imageURL)237 .then(() => invoker.execute(commands.LOAD_IMAGE, graphics, 'newImage', newImageURL))238 .then(() => {239 expect(graphics.getImageName()).toBe('newImage');240 expect(graphics.getCanvasImage().getSrc()).toContain(newImageURL);241 return invoker.undo();242 })243 .then(() => {244 expect(graphics.getImageName()).toEqual('image');245 expect(graphics.getCanvasImage().getSrc()).toContain(imageURL);246 done();247 });248 });249 });250 describe('flipImageCommand', () => {251 it('flipX', () => {252 const originFlipX = mockImage.flipX;253 invoker.execute(commands.FLIP_IMAGE, graphics, 'flipX');254 expect(mockImage.flipX).toBe(!originFlipX);255 });256 it('flipY', () => {257 const originFlipY = mockImage.flipY;258 invoker.execute(commands.FLIP_IMAGE, graphics, 'flipY');259 expect(mockImage.flipY).toBe(!originFlipY);260 });261 it('resetFlip', () => {262 mockImage.flipX = true;263 mockImage.flipY = true;264 invoker.execute(commands.FLIP_IMAGE, graphics, 'reset');265 expect(mockImage.flipX).toBe(false);266 expect(mockImage.flipY).toBe(false);267 });268 it('"undo()" should restore flipX', (done) => {269 const originFlipX = mockImage.flipX;270 invoker271 .execute(commands.FLIP_IMAGE, graphics, 'flipX')272 .then(() => invoker.undo())273 .then(() => {274 expect(mockImage.flipX).toBe(originFlipX);275 done();276 });277 });278 it('"undo()" should restore filpY', (done) => {279 const originFlipY = mockImage.flipY;280 invoker281 .execute(commands.FLIP_IMAGE, graphics, 'flipY')282 .then(() => invoker.undo())283 .then(() => {284 expect(mockImage.flipY).toBe(originFlipY);285 done();286 });287 });288 });289 describe('textCommand', () => {290 let textObjectId;291 const defaultFontSize = 50;292 const defaultUnderline = false;293 beforeEach((done) => {294 invoker295 .execute(commands.ADD_TEXT, graphics, 'text', {296 styles: {297 fontSize: defaultFontSize,298 underline: false,299 },300 })301 .then((textObject) => {302 textObjectId = textObject.id;303 done();304 });305 });306 it('"changeTextStyle" should set text style', (done) => {307 invoker308 .execute(commands.CHANGE_TEXT_STYLE, graphics, textObjectId, {309 fontSize: 30,310 underline: true,311 })312 .then(() => {313 const textObject = graphics.getObject(textObjectId);314 expect(textObject.fontSize).toBe(30);315 expect(textObject.underline).toBe(true);316 done();317 });318 });319 it('"undo()" should restore fontSize', (done) => {320 invoker321 .execute(commands.CHANGE_TEXT_STYLE, graphics, textObjectId, {322 fontSize: 30,323 underline: true,324 })325 .then(() => invoker.undo())326 .then(() => {327 const textObject = graphics.getObject(textObjectId);328 expect(textObject.fontSize).toBe(defaultFontSize);329 expect(textObject.underline).toBe(defaultUnderline);330 done();331 });332 });333 });334 describe('rotationImageCommand', () => {335 it('"rotate()" should add angle', () => {336 const originAngle = mockImage.angle;337 invoker.execute(commands.ROTATE_IMAGE, graphics, 'rotate', 10);338 expect(mockImage.angle).toBe(originAngle + 10);339 });340 it('"setAngle()" should set angle', () => {341 mockImage.angle = 100;342 invoker.execute(commands.ROTATE_IMAGE, graphics, 'setAngle', 30);343 expect(mockImage.angle).toBe(30);344 });345 it('"undo()" should restore angle', (done) => {346 const originalAngle = mockImage.angle;347 invoker348 .execute(commands.ROTATE_IMAGE, graphics, 'setAngle', 100)349 .then(() => invoker.undo())350 .then(() => {351 expect(mockImage.angle).toBe(originalAngle);352 done();353 });354 });355 });356 describe('shapeCommand', () => {357 let shapeObjectId;358 const defaultStrokeWidth = 12;359 beforeEach((done) => {360 invoker361 .execute(commands.ADD_SHAPE, graphics, 'rect', {362 strokeWidth: defaultStrokeWidth,363 })364 .then((shapeObject) => {365 shapeObjectId = shapeObject.id;366 done();367 });368 });369 it('"changeShape" should set strokeWidth', (done) => {370 invoker371 .execute(commands.CHANGE_SHAPE, graphics, shapeObjectId, {372 strokeWidth: 50,373 })374 .then(() => {375 const shapeObject = graphics.getObject(shapeObjectId);376 expect(shapeObject.strokeWidth).toBe(50);377 done();378 });379 });380 it('"redo()" should restore strokeWidth', (done) => {381 invoker382 .execute(commands.CHANGE_SHAPE, graphics, shapeObjectId, {383 strokeWidth: 50,384 })385 .then(() => invoker.undo())386 .then(() => {387 const shapeObject = graphics.getObject(shapeObjectId);388 expect(shapeObject.strokeWidth).toBe(defaultStrokeWidth);389 done();390 });391 });392 });393 describe('clearCommand', () => {394 let canvasContext;395 beforeEach(() => {396 canvasContext = canvas;397 });398 it('should clear all objects', () => {399 const objects = [new fabric.Rect(), new fabric.Rect(), new fabric.Rect()];400 canvas.add.apply(canvasContext, objects);401 expect(canvas.contains(objects[0])).toBe(true);402 expect(canvas.contains(objects[1])).toBe(true);403 expect(canvas.contains(objects[2])).toBe(true);404 invoker.execute(commands.CLEAR_OBJECTS, graphics);405 expect(canvas.contains(objects[0])).toBe(false);406 expect(canvas.contains(objects[1])).toBe(false);407 expect(canvas.contains(objects[2])).toBe(false);408 });409 it('"undo()" restore all objects', (done) => {410 const objects = [new fabric.Rect(), new fabric.Rect(), new fabric.Rect()];411 canvas.add.apply(canvasContext, objects);412 invoker413 .execute(commands.CLEAR_OBJECTS, graphics)414 .then(() => invoker.undo())415 .then(() => {416 expect(canvas.contains(objects[0])).toBe(true);417 expect(canvas.contains(objects[1])).toBe(true);418 expect(canvas.contains(objects[2])).toBe(true);419 done();420 });421 });422 });423 describe('removeCommand', () => {424 let object, object2, group;425 beforeEach(() => {426 object = new fabric.Rect({427 left: 10,428 top: 10,429 });430 object2 = new fabric.Rect({431 left: 5,432 top: 20,433 });434 group = new fabric.Group();435 graphics.add(object);436 graphics.add(object2);437 graphics.add(group);438 group.add(object, object2);439 });440 it('should remove an object', () => {441 graphics.setActiveObject(object);442 invoker.execute(commands.REMOVE_OBJECT, graphics, snippet.stamp(object));443 expect(canvas.contains(object)).toBe(false);444 });445 it('should remove objects group', () => {446 canvas.setActiveObject(group);447 invoker.execute(commands.REMOVE_OBJECT, graphics, snippet.stamp(group));448 expect(canvas.contains(object)).toBe(false);449 expect(canvas.contains(object2)).toBe(false);450 });451 it('"undo()" should restore the removed object', (done) => {452 canvas.setActiveObject(object);453 invoker454 .execute(commands.REMOVE_OBJECT, graphics, snippet.stamp(object))455 .then(() => invoker.undo())456 .then(() => {457 expect(canvas.contains(object)).toBe(true);458 done();459 });460 });461 it('"undo()" should restore the removed objects (group)', (done) => {462 canvas.setActiveObject(group);463 invoker464 .execute(commands.REMOVE_OBJECT, graphics, snippet.stamp(group))465 .then(() => invoker.undo())466 .then(() => {467 expect(canvas.contains(object)).toBe(true);468 expect(canvas.contains(object2)).toBe(true);469 done();470 });471 });472 it('"undo ()" should restore the position of the removed object (group). ', (done) => {473 const activeSelection = graphics.getActiveSelectionFromObjects(canvas.getObjects());474 graphics.setActiveObject(activeSelection);475 invoker476 .execute(commands.REMOVE_OBJECT, graphics, graphics.getActiveObjectIdForRemove())477 .then(() => invoker.undo())478 .then(() => {479 expect(object.left).toBe(10);480 expect(object.top).toBe(10);481 expect(object2.left).toBe(5);482 expect(object2.top).toBe(20);483 done();484 });485 });486 });487 describe('resizeCommand', () => {488 it('resize', () => {489 const newDimensions = {490 width: 20,491 height: 20,492 };493 invoker.execute(commands.RESIZE_IMAGE, graphics, newDimensions);494 const { width, height, scaleX, scaleY } = mockImage;495 expect({496 width: width * scaleX,497 height: height * scaleY,498 }).toEqual(newDimensions);499 });500 it('"undo()" should restore dimensions of image', (done) => {501 const newDimensions = {502 width: 20,503 height: 20,504 };505 invoker506 .execute(commands.RESIZE_IMAGE, graphics, newDimensions)507 .then(() => invoker.undo())508 .then(() => {509 const { width, height, scaleX, scaleY } = mockImage;510 expect({511 width: width * scaleX,512 height: height * scaleY,513 }).toEqual(dimensions);514 done();515 });516 });517 });...

Full Screen

Full Screen

command-invoker.test.js

Source:command-invoker.test.js Github

copy

Full Screen

1'use strict';2const CommandInvoker = require('../command-invoker');3const sandbox = require('sinon').createSandbox();4describe('CommandInvoker', () => {5 let invoker;6 beforeEach(() => {7 invoker = new CommandInvoker();8 });9 afterEach(() => {10 sandbox.reset();11 sandbox.restore();12 });13 it('should create a proper command and pass entity, arg & flags', async function () {14 const HelpCommand = require('../commands/help-command');15 const stub = sandbox.stub(HelpCommand.prototype, 'execute');16 invoker.entity = 'app';17 invoker.command = 'help';18 await invoker.executeCommand();19 expect(stub).to.have.been.calledOnce;20 });21 it('should execute help command if user doesn\'t provide any argument', async function () {22 const HelpCommand = require('../commands/help-command');23 const stub = sandbox.stub(HelpCommand.prototype, 'execute');24 await invoker.parse(['', 'mdb']);25 await invoker.executeCommand();26 expect(stub).to.have.been.calledOnce;27 });28 it('should throw error if flag contain `=` instead of space', function () {29 try {30 invoker.parse(['', 'mdb', 'login', '--method=google']);31 } catch (e) {32 return expect(e.message).to.be.eq('Please use space instead of `=` on flags');33 }34 chai.assert.fail('_isFlag function should throw error if flag contain `=`');35 });36 describe('should properly parse entity, command, arg and flags', function () {37 it('mdb help', function () {38 invoker.parse(['', 'mdb', 'help']);39 expect(invoker.entity).to.eq('app');40 expect(invoker.command).to.eq('help');41 expect(invoker.args).to.deep.eq([]);42 expect(invoker.flags).to.deep.eq([]);43 });44 it('mdb version', function () {45 invoker.parse(['', 'mdb', 'version']);46 expect(invoker.entity).to.eq('app');47 expect(invoker.command).to.eq('version');48 expect(invoker.args).to.deep.eq([]);49 expect(invoker.flags).to.deep.eq([]);50 });51 it('mdb -v', function () {52 invoker.parse(['', 'mdb', '-v']);53 expect(invoker.entity).to.eq('app');54 expect(invoker.command).to.eq('version');55 expect(invoker.args).to.deep.eq([]);56 expect(invoker.flags).to.deep.eq([]);57 });58 it('mdb --version', function () {59 invoker.parse(['', 'mdb', '--version']);60 expect(invoker.entity).to.eq('app');61 expect(invoker.command).to.eq('version');62 expect(invoker.args).to.deep.eq([]);63 expect(invoker.flags).to.deep.eq([]);64 });65 it('mdb update', function () {66 invoker.parse(['', 'mdb', 'update']);67 expect(invoker.entity).to.eq('app');68 expect(invoker.command).to.eq('update');69 expect(invoker.args).to.deep.eq([]);70 expect(invoker.flags).to.deep.eq([]);71 });72 it('mdb register', function () {73 invoker.parse(['', 'mdb', 'register']);74 expect(invoker.entity).to.eq('user');75 expect(invoker.command).to.eq('register');76 expect(invoker.args).to.deep.eq([]);77 expect(invoker.flags).to.deep.eq([]);78 });79 it('mdb login', function () {80 invoker.parse(['', 'mdb', 'login']);81 expect(invoker.entity).to.eq('user');82 expect(invoker.command).to.eq('login');83 expect(invoker.args).to.deep.eq([]);84 expect(invoker.flags).to.deep.eq([]);85 });86 it('mdb logout', function () {87 invoker.parse(['', 'mdb', 'logout']);88 expect(invoker.entity).to.eq('user');89 expect(invoker.command).to.eq('logout');90 expect(invoker.args).to.deep.eq([]);91 expect(invoker.flags).to.deep.eq([]);92 });93 it('mdb starters', function () {94 invoker.parse(['', 'mdb', 'starters']);95 expect(invoker.entity).to.eq('starter');96 expect(invoker.command).to.eq('ls');97 expect(invoker.args).to.deep.eq([]);98 expect(invoker.flags).to.deep.eq([]);99 });100 it('mdb starter ls', function () {101 invoker.parse(['', 'mdb', 'starter', 'ls']);102 expect(invoker.entity).to.eq('starter');103 expect(invoker.command).to.eq('ls');104 expect(invoker.args).to.deep.eq([]);105 expect(invoker.flags).to.deep.eq([]);106 });107 it('mdb starter init', function () {108 invoker.parse(['', 'mdb', 'starter', 'init']);109 expect(invoker.entity).to.eq('starter');110 expect(invoker.command).to.eq('init');111 expect(invoker.args).to.deep.eq([]);112 expect(invoker.flags).to.deep.eq([]);113 });114 it('mdb backend init', function () {115 invoker.parse(['', 'mdb', 'backend', 'init']);116 expect(invoker.entity).to.eq('backend');117 expect(invoker.command).to.eq('init');118 expect(invoker.args).to.deep.eq([]);119 expect(invoker.flags).to.deep.eq([]);120 });121 it('mdb frontend init', function () {122 invoker.parse(['', 'mdb', 'frontend', 'init']);123 expect(invoker.entity).to.eq('frontend');124 expect(invoker.command).to.eq('init');125 expect(invoker.args).to.deep.eq([]);126 expect(invoker.flags).to.deep.eq([]);127 });128 it('mdb blank init', function () {129 invoker.parse(['', 'mdb', 'blank', 'init']);130 expect(invoker.entity).to.eq('blank');131 expect(invoker.command).to.eq('init');132 expect(invoker.args).to.deep.eq([]);133 expect(invoker.flags).to.deep.eq([]);134 });135 it('mdb repo init', function () {136 invoker.parse(['', 'mdb', 'repo', 'init']);137 expect(invoker.entity).to.eq('repo');138 expect(invoker.command).to.eq('init');139 expect(invoker.args).to.deep.eq([]);140 expect(invoker.flags).to.deep.eq([]);141 });142 it('mdb config domain newname', function () {143 invoker.parse(['', 'mdb', 'config', 'domain', 'newname']);144 expect(invoker.entity).to.eq('config');145 expect(invoker.command).to.eq('config');146 expect(invoker.args).to.deep.eq(['domain', 'newname']);147 expect(invoker.flags).to.deep.eq([]);148 });149 it('mdb config domain --unset', function () {150 invoker.parse(['', 'mdb', 'config', 'domain', '--unset']);151 expect(invoker.entity).to.eq('config');152 expect(invoker.command).to.eq('config');153 expect(invoker.args).to.deep.eq(['domain']);154 expect(invoker.flags).to.deep.eq(['--unset']);155 });156 it('mdb publish', function () {157 invoker.parse(['', 'mdb', 'publish']);158 expect(invoker.entity).to.eq('');159 expect(invoker.command).to.eq('publish');160 expect(invoker.args).to.deep.eq([]);161 expect(invoker.flags).to.deep.eq([]);162 });163 it('mdb publish -t --ftp', function () {164 invoker.parse(['', 'mdb', 'publish', '-t', '--ftp']);165 expect(invoker.entity).to.eq('');166 expect(invoker.command).to.eq('publish');167 expect(invoker.args).to.deep.eq([]);168 expect(invoker.flags).to.deep.eq(['-t', '--ftp']);169 });170 it('mdb frontend publish', function () {171 invoker.parse(['', 'mdb', 'frontend', 'publish']);172 expect(invoker.entity).to.eq('frontend');173 expect(invoker.command).to.eq('publish');174 expect(invoker.args).to.deep.eq([]);175 expect(invoker.flags).to.deep.eq([]);176 });177 it('mdb backend publish', function () {178 invoker.parse(['', 'mdb', 'backend', 'publish']);179 expect(invoker.entity).to.eq('backend');180 expect(invoker.command).to.eq('publish');181 expect(invoker.args).to.deep.eq([]);182 expect(invoker.flags).to.deep.eq([]);183 });184 it('mdb frontend publish -t --ftp', function () {185 invoker.parse(['', 'mdb', 'frontend', 'publish', '-t', '--ftp']);186 expect(invoker.entity).to.eq('frontend');187 expect(invoker.command).to.eq('publish');188 expect(invoker.args).to.deep.eq([]);189 expect(invoker.flags).to.deep.eq(['-t', '--ftp']);190 });191 it('mdb delete', function () {192 invoker.parse(['', 'mdb', 'delete']);193 expect(invoker.entity).to.eq('');194 expect(invoker.command).to.eq('delete');195 expect(invoker.args).to.deep.eq([]);196 expect(invoker.flags).to.deep.eq([]);197 });198 it('mdb frontend delete', function () {199 invoker.parse(['', 'mdb', 'frontend', 'delete']);200 expect(invoker.entity).to.eq('frontend');201 expect(invoker.command).to.eq('delete');202 expect(invoker.args).to.deep.eq([]);203 expect(invoker.flags).to.deep.eq([]);204 });205 it('mdb backend delete', function () {206 invoker.parse(['', 'mdb', 'backend', 'delete']);207 expect(invoker.entity).to.eq('backend');208 expect(invoker.command).to.eq('delete');209 expect(invoker.args).to.deep.eq([]);210 expect(invoker.flags).to.deep.eq([]);211 });212 it('mdb ls', function () {213 invoker.parse(['', 'mdb', 'ls']);214 expect(invoker.entity).to.eq('');215 expect(invoker.command).to.eq('ls');216 expect(invoker.args).to.deep.eq([]);217 expect(invoker.flags).to.deep.eq([]);218 });219 it('mdb frontend ls', function () {220 invoker.parse(['', 'mdb', 'frontend', 'ls']);221 expect(invoker.entity).to.eq('frontend');222 expect(invoker.command).to.eq('ls');223 expect(invoker.args).to.deep.eq([]);224 expect(invoker.flags).to.deep.eq([]);225 });226 it('mdb backend ls', function () {227 invoker.parse(['', 'mdb', 'backend', 'ls']);228 expect(invoker.entity).to.eq('backend');229 expect(invoker.command).to.eq('ls');230 expect(invoker.args).to.deep.eq([]);231 expect(invoker.flags).to.deep.eq([]);232 });233 it('mdb database ls', function () {234 invoker.parse(['', 'mdb', 'database', 'ls']);235 expect(invoker.entity).to.eq('database');236 expect(invoker.command).to.eq('ls');237 expect(invoker.args).to.deep.eq([]);238 expect(invoker.flags).to.deep.eq([]);239 });240 it('mdb get', function () {241 invoker.parse(['', 'mdb', 'get']);242 expect(invoker.entity).to.eq('');243 expect(invoker.command).to.eq('get');244 expect(invoker.args).to.deep.eq([]);245 expect(invoker.flags).to.deep.eq([]);246 });247 it('mdb orders', function () {248 invoker.parse(['', 'mdb', 'orders']);249 expect(invoker.entity).to.eq('order');250 expect(invoker.command).to.eq('ls');251 expect(invoker.args).to.deep.eq([]);252 expect(invoker.flags).to.deep.eq([]);253 });254 it('mdb order ls', function () {255 invoker.parse(['', 'mdb', 'order', 'ls']);256 expect(invoker.entity).to.eq('order');257 expect(invoker.command).to.eq('ls');258 expect(invoker.args).to.deep.eq([]);259 expect(invoker.flags).to.deep.eq([]);260 });261 it('mdb database info', function () {262 invoker.parse(['', 'mdb', 'database', 'info']);263 expect(invoker.entity).to.eq('database');264 expect(invoker.command).to.eq('info');265 expect(invoker.args).to.deep.eq([]);266 expect(invoker.flags).to.deep.eq([]);267 });268 it('mdb database delete', function () {269 invoker.parse(['', 'mdb', 'database', 'delete']);270 expect(invoker.entity).to.eq('database');271 expect(invoker.command).to.eq('delete');272 expect(invoker.args).to.deep.eq([]);273 expect(invoker.flags).to.deep.eq([]);274 });275 it('mdb backend kill', function () {276 invoker.parse(['', 'mdb', 'backend', 'kill']);277 expect(invoker.entity).to.eq('backend');278 expect(invoker.command).to.eq('kill');279 expect(invoker.args).to.deep.eq([]);280 expect(invoker.flags).to.deep.eq([]);281 });282 it('mdb backend destroy', function () {283 invoker.parse(['', 'mdb', 'backend', 'destroy']);284 expect(invoker.entity).to.eq('backend');285 expect(invoker.command).to.eq('destroy');286 expect(invoker.args).to.deep.eq([]);287 expect(invoker.flags).to.deep.eq([]);288 });289 it('mdb backend info', function () {290 invoker.parse(['', 'mdb', 'backend', 'info']);291 expect(invoker.entity).to.eq('backend');292 expect(invoker.command).to.eq('info');293 expect(invoker.args).to.deep.eq([]);294 expect(invoker.flags).to.deep.eq([]);295 });296 it('mdb backend logs', function () {297 invoker.parse(['', 'mdb', 'backend', 'logs']);298 expect(invoker.entity).to.eq('backend');299 expect(invoker.command).to.eq('logs');300 expect(invoker.args).to.deep.eq([]);301 expect(invoker.flags).to.deep.eq([]);302 });303 it('mdb rename', function () {304 invoker.parse(['', 'mdb', 'rename']);305 expect(invoker.entity).to.eq('');306 expect(invoker.command).to.eq('rename');307 expect(invoker.args).to.deep.eq([]);308 expect(invoker.flags).to.deep.eq([]);309 });310 it('mdb rename newname', function () {311 invoker.parse(['', 'mdb', 'rename', 'newname']);312 expect(invoker.entity).to.eq('');313 expect(invoker.command).to.eq('rename');314 expect(invoker.args).to.deep.eq(['newname']);315 expect(invoker.flags).to.deep.eq([]);316 });317 });...

Full Screen

Full Screen

propertyValue.js

Source:propertyValue.js Github

copy

Full Screen

...9 var val = {}, name = {};10 subject._super = methods.method();11 12 // act13 invoker(name, val, "i");14 15 // assert16 strictEqual(subject.parser("234"), 234);17});18testUtils.testWithUtils("value", "has cached", false, function(methods, classes, subject, invoker) {19 // arrange20 // act21 // assert22 strictEqual(subject._cachedValue = {}, invoker());23});24testUtils.testWithUtils("value", "no cached", false, function(methods, classes, subject, invoker) {25 // arrange26 subject.getValue = function () {27 return "XYZ";28 };29 30 // act31 // assert32 strictEqual("XYZ", invoker());33 strictEqual(subject._cachedValue, "XYZ");34});35testUtils.testWithUtils("value", "raw, has cached", false, function(methods, classes, subject, invoker) {36 // arrange37 // act38 // assert39 strictEqual(subject._unAlteredCachedValue = {}, invoker(true));40});41testUtils.testWithUtils("value", "raw, no cached", false, function(methods, classes, subject, invoker) {42 // arrange43 subject.getValue = function () {44 return "XYZ";45 };46 47 // act48 // assert49 strictEqual("XYZ", invoker(true));50 strictEqual(subject._unAlteredCachedValue, "XYZ");51});52testUtils.testWithUtils("getValue", null, false, function(methods, classes, subject, invoker) {53 // arrange54 // act55 // assert56 strictEqual(subject._value = {}, invoker());57});58testUtils.testWithUtils("getBindingStrategyOptions", "has strategy 0", false, function(methods, classes, subject, invoker) {59 // arrange60 subject.primed = methods.method();61 subject.renderContext = {62 $this: {63 $bindingStrategy: 064 }65 };66 67 // act68 // assert69 strictEqual(undefined, invoker());70});71testUtils.testWithUtils("getBindingStrategyOptions", "has strategy 1", false, function(methods, classes, subject, invoker) {72 // arrange73 subject.primed = methods.method();74 subject.renderContext = {75 $this: {76 $bindingStrategy: 177 }78 };79 80 // act81 // assert82 ok(invoker().trackPartialObservable);83 ok(!invoker().forceObserve);84});85testUtils.testWithUtils("getBindingStrategyOptions", "has strategy 2", false, function(methods, classes, subject, invoker) {86 // arrange87 subject.primed = methods.method();88 subject.renderContext = {89 $this: {90 $bindingStrategy: 291 }92 };93 94 // act95 // assert96 ok(!invoker().trackPartialObservable);97 ok(invoker().forceObserve);98});99testUtils.testWithUtils("getBindingStrategyOptions", "no strategy", false, function(methods, classes, subject, invoker) {100 // arrange101 subject.primed = methods.method();102 subject.renderContext = {$this: {}};103 var result1 = invoker();104 subject.renderContext.$this.$bindingStrategy = wipeout.settings.bindingStrategy;105 106 // act107 // assert108 ok(wipeout.settings.hasOwnProperty("bindingStrategy"));109 deepEqual(result1, invoker());110});111testUtils.testWithUtils("buildGetter", "has getter", false, function(methods, classes, subject, invoker) {112 // arrange113 // act114 // assert115 strictEqual(subject._getter = {}, invoker());116});117testUtils.testWithUtils("buildGetter", "no filter", false, function(methods, classes, subject, invoker) {118 // arrange119 subject.value = methods.method([], "'hello shane'");120 121 // act122 strictEqual(invoker(), subject._getter);123 124 // assert125 strictEqual(subject._getter(), "hello shane");126});127testUtils.testWithUtils("buildGetter", "invalid filter", false, function(methods, classes, subject, invoker) {128 // arrange129 subject.value = methods.method([], "'hello shane' => invalid-filter");130 131 // assert132 // act133 throws(function () {134 invoker();135 });136});137testUtils.testWithUtils("buildGetter", "good filter, no to child part", false, function(methods, classes, subject, invoker) {138 // arrange139 wo.filters["good-filter"] = {};140 subject.value = methods.method([], "'hello shane', 'another hello' => good-filter");141 142 // assert143 // act144 strictEqual(invoker()(), "hello shane");145 146 delete wo.filters["good-filter"];147});148testUtils.testWithUtils("buildGetter", "good filter, with to child part", false, function(methods, classes, subject, invoker) {149 // arrange150 var op = {};151 wo.filters["good-filter"] = {152 downward: methods.method(['hello shane', 'another hello'], op)153 };154 subject.value = methods.method([], "'hello shane', 'another hello' => good-filter");155 156 // assert157 // act158 strictEqual(invoker()(), op);159 160 delete wo.filters["good-filter"];161});162testUtils.testWithUtils("getter", "no parser", false, function(methods, classes, subject, invoker) {163 // arrange164 var op = {}, getterArgs = {};165 subject.getParser = function () {};166 subject.primed = methods.method();167 subject.buildGetter = methods.method([], {168 apply: methods.method([null, getterArgs], op)169 });170 subject.renderContext = {171 asGetterArgs: methods.method([], getterArgs)172 };173 174 // act175 // assert176 strictEqual(op, invoker()());177});178testUtils.testWithUtils("getter", "with parser", false, function(methods, classes, subject, invoker) {179 // arrange180 var op = {}, val = {};181 subject.name = {};182 subject.value = methods.method([true], val);183 subject.primed = methods.method();184 subject.renderContext = {};185 var parser = methods.method([val, subject.name, subject.renderContext], op);186 subject.getParser = methods.method([], parser);187 188 // act189 // assert190 strictEqual(op, invoker()());191});192testUtils.testWithUtils("getter", "xml parser", false, function(methods, classes, subject, invoker) {193 // arrange194 var op = {}, val = {};195 subject.renderContext = {};196 subject.name = {};197 subject._value = val;198 subject.primed = methods.method();199 var parser = methods.method([val, subject.name, subject.renderContext], op);200 parser.useRawXmlValue = true;201 subject.getParser = methods.method([], parser);202 203 // act204 // assert205 strictEqual(op, invoker()());206});207testUtils.testWithUtils("canSet", "", false, function(methods, classes, subject, invoker) {208 // arrange209 var po = {};210 subject.getParser = methods.method([po], false);211 subject.buildSetter = methods.method([po], true);212 213 // act214 // assert215 ok(invoker(po));216});217testUtils.testWithUtils("getParser", "primed, has parser", false, function(methods, classes, subject, invoker) {218 // arrange219 var po = subject.propertyOwner = {};220 subject.primed = methods.method();221 subject.parser = {}222 223 // act224 // assert225 strictEqual(subject.parser, invoker());226});227testUtils.testWithUtils("getParser", "primed, has global parser", false, function(methods, classes, subject, invoker) {228 // arrange229 subject.primed = methods.method();230 subject.propertyOwner = new (wipeout.base.bindable.extend(function () {this._super();}))();231 subject.propertyOwner.constructor.addGlobalParser("aaa", "s");232 subject.name = "aaa";233 234 // act235 // assert236 strictEqual(wo.parsers.s , invoker());237});238testUtils.testWithUtils("buildSetter", "has setter", false, function(methods, classes, subject, invoker) {239 // arrange240 // act241 // assert242 strictEqual(subject._setter = {}, invoker());243});244testUtils.testWithUtils("buildSetter", "no filter", false, function(methods, classes, subject, invoker) {245 // arrange246 var ctxt = {asGetterArgs: function() { return [this]; }};247 subject.value = methods.method([], "$context.val");248 249 // act250 strictEqual(invoker(), subject._setter);251 subject._setter(ctxt, "hello shane");252 253 // assert254 strictEqual(ctxt.val, "hello shane");255});256testUtils.testWithUtils("buildSetter", "invalid filter", false, function(methods, classes, subject, invoker) {257 // arrange258 subject.value = methods.method([], "$context.val => invalid-filter");259 260 // assert261 // act262 throws(function () {263 invoker();264 });265});266testUtils.testWithUtils("buildSetter", "good filter, no to child part", false, function(methods, classes, subject, invoker) {267 // arrange268 var ctxt = {asGetterArgs: function() { return [this]; }}, val = {};269 wo.filters["good-filter"] = {};270 subject.value = methods.method([], "$context.val, 'another hello' => good-filter");271 272 // act273 ok(invoker()(ctxt, val))274 275 // assert276 strictEqual(ctxt.val, val);277 278 delete wo.filters["good-filter"];279});280testUtils.testWithUtils("buildSetter", "good filter, with to child part", false, function(methods, classes, subject, invoker) {281 // arrange282 var ctxt = {asGetterArgs: function() { return [this, null, null, null, null]; }}, input = {}, output = {};283 wo.filters["good-filter"] = {284 upward: methods.method([input, 'another hello'], output)285 };286 subject.value = methods.method([], "$context.val, 'another hello' => good-filter");287 288 // act289 ok(invoker()(ctxt, input));290 291 // assert292 strictEqual(ctxt.val, output);293 294 delete wo.filters["good-filter"];295});296testUtils.testWithUtils("buildSetter", "cannot set", false, function(methods, classes, subject, invoker) {297 // arrange298 subject.value = methods.method([], "$context");299 300 // act301 ok(!invoker());302 303 // assert304 strictEqual(subject._setter, null);305});306testUtils.testWithUtils("setter", "cannot set", false, function(methods, classes, subject, invoker) {307 // arrange308 var op = {};309 subject.canSet = methods.method([op], false);310 subject.value = methods.method();311 312 // act313 // assert314 throws(function () {315 invoker()(null);316 });317});318testUtils.testWithUtils("setter", "", false, function(methods, classes, subject, invoker) {319 // arrange320 var po = {}, val = {}, op = {};321 subject.renderContext = {};322 subject.canSet = methods.method([], true);323 subject.buildSetter = methods.method([], methods.method([subject.renderContext, val]));324 325 // act326 // assert327 invoker()(val);328});329testUtils.testWithUtils("watch", "not caching. Other logic tested in integration tests", false, function(methods, classes, subject, invoker) {330 // arrange331 // act332 // assert333 throws(function () {334 invoker();335 });336});337testUtils.testWithUtils("prime", "already caching", false, function(methods, classes, subject, invoker) {338 // arrange339 subject._caching = true;340 341 // act342 // assert343 throws(function () {344 invoker();345 });346});347testUtils.testWithUtils("prime", "not caching", false, function(methods, classes, subject, invoker) {348 // arrange 349 var tmp;350 351 // act352 var output = invoker({}, {}, function () {353 tmp = subject._caching354 });355 356 // assert357 ok(tmp instanceof Array);358 ok(!subject._caching);359});360testUtils.testWithUtils("replace$model", "no $model, with strings and comments", true, function(methods, classes, subject, invoker) {361 // arrange362 var input1 = "//$model\n/*$model*/", input2 = "'$model'\n\"$model\"";363 364 // act365 var output = invoker(input1 + input2);366 367 // assert368 strictEqual("\n" + input2, output);369});370testUtils.testWithUtils("replace$model", "var $model", true, function(methods, classes, subject, invoker) {371 // arrange372 // act373 // assert374 throws(function () {375 invoker("var $model;");376 });377 throws(function () {378 invoker(" var $model;");379 });380});381testUtils.testWithUtils("replace$model", "$model", true, function (methods, classes, subject, invoker) {382 // arrange383 var input = "$model"384 385 // act386 var output = invoker(input);387 388 // assert389 strictEqual("$this.model", output);390});391testUtils.testWithUtils("replace$model", ", $model", true, function (methods, classes, subject, invoker) {392 // arrange393 var input = ", $model"394 395 // act396 var output = invoker(input);397 398 // assert399 strictEqual(", $this.model", output);400});401testUtils.testWithUtils("replace$model", "x$model", true, function (methods, classes, subject, invoker) {402 // arrange403 var input = "x$model"404 405 // act406 var output = invoker(input);407 408 // assert409 strictEqual(input, output);410});411testUtils.testWithUtils("replace$model", "x.$model", true, function (methods, classes, subject, invoker) {412 // arrange413 var input = "x.$model"414 415 // act416 var output = invoker(input);417 418 // assert419 strictEqual(input, output);420});421testUtils.testWithUtils("replace$model", "$modelx", true, function (methods, classes, subject, invoker) {422 // arrange423 var input = "$modelx"424 425 // act426 var output = invoker(input);427 428 // assert429 strictEqual(input, output);430});431testUtils.testWithUtils("replace$model", "{$model: 33}", true, function (methods, classes, subject, invoker) {432 // arrange433 var input = "{$model: 33}"434 435 // act436 var output = invoker(input);437 438 // assert439 strictEqual(input, output);440});441testUtils.testWithUtils("replace$model", "{$model : 33}", true, function (methods, classes, subject, invoker) {442 // arrange443 var input = "{$model : 33}"444 445 // act446 var output = invoker(input);447 448 // assert449 strictEqual(input, output);...

Full Screen

Full Screen

jquery-polyglot.language.switcher.js

Source:jquery-polyglot.language.switcher.js Github

copy

Full Screen

1/*! @license Polyglot Language Switcher 2 - v1.0.0 - 2015-02-202 * https://github.com/ixtendo/Polyglot-Language-Switcher-2/3 *4 * Copyright (c) 2015 Ixtendo;5 * Licensed under the MIT license */6 (function ($) {7 var getOptions = function (invoker, options) {8 var $invoker = $(invoker);9 if (!options) {10 options = {};11 }12 $.each($.fn.polyglotLanguageSwitcher.defaults, function (prop) {13 var propData = $invoker.data(prop);14 if (propData) {15 options[prop] = propData;16 }17 });18 return options;19 };20 $.fn.polyglotLanguageSwitcher = function (options) {21 var getSetting = function (settings, setting) {22 return $.isFunction(settings[setting]) ? settings[setting].call(settings) : settings[setting];23 };24 var triggerEvent = function (evt, settings) {25 var invoker = settings._model.invoker;26 var $invoker = $(invoker);27 switch (evt.type) {28 case 'opening':29 settings._model.status = 'opening';30 $invoker.trigger($.Event('popupOpening', {target: evt.target, invoker: invoker}));31 break;32 case 'opened':33 settings._model.status = 'opened';34 var $popup = $(evt.target);35 if (!settings._model.documentClickHandler) {36 settings._model.documentClickHandler = $(document).on('click', function (e) {37 if ($(e.target).closest($popup).length === 0) {38 closePopup($popup, settings);39 }40 });41 }42 if (!settings._model.documentKeyHandler) {43 settings._model.documentKeyHandler = $(document).on('keydown', function (e) {44 if (e.keyCode === 27) {45 closePopup($popup, settings);46 }47 });48 }49 $invoker.trigger($.Event('popupOpened', {target: evt.target, invoker: invoker}));50 break;51 case 'closing':52 settings._model.status = 'closing';53 $invoker.trigger($.Event('popupClosing', {target: evt.target, invoker: invoker}));54 break;55 case 'closed':56 settings._model.status = 'closed';57 if (settings._model.documentClickHandler) {58 $(document).off('click', settings._model.documentClickHandler);59 settings._model.documentClickHandler = null;60 }61 if (settings._model.documentKeyHandler) {62 $(document).off('keydown', settings._model.documentKeyHandler);63 settings._model.documentKeyHandler = null;64 }65 $invoker.trigger($.Event('popupClosed', {target: evt.target, invoker: invoker}));66 break;67 }68 };69 var buildUI = function (settings) {70 var invoker = settings._model.invoker;71 var animEffect = settings.animEffect;72 var gridColumns = getSetting(settings, 'gridColumns');73 var selectedLang = getSetting(settings, 'selectedLang');74 var $popup = $('<div class="pls-language-container-scrollable"><table class="pls-language-container"><tbody><tr></tr></tbody></table></div>').hide();75 if (animEffect === 'slide') {76 $popup.slideUp(0);77 }78 var $popupTr = $popup.find('tr');79 var $languages = $(invoker).find('li');80 var langPerColumn = Math.round($languages.length / gridColumns);81 var $selectedLang;82 var columnLanguages = [];83 $languages.each(function (index) {84 var $li = $(this);85 var $a = $li.children('a');86 var lang = $a.data('langId');87 if (selectedLang === lang) {88 $selectedLang = $a.addClass('pls-selected-locale').clone();89 }90 columnLanguages.push($li);91 if (((index + 1) % langPerColumn) === 0) {92 $popupTr.append($('<td></td>').append($('<ul></ul>').append(columnLanguages)));93 columnLanguages = [];94 }95 });96 if (columnLanguages.length > 0) {97 $popupTr.append($('<td></td>').append($('<ul></ul>').append(columnLanguages)));98 columnLanguages = [];99 }100 if (!$selectedLang) {101 var $firstLi = $languages.first();102 $selectedLang = $firstLi.children('a').addClass('pls-selected-locale').clone();103 }104 $(invoker).empty().append($selectedLang).append($popup);105 };106 var openPopup = function ($popup, settings) {107 var animEffect = settings.animEffect;108 var animSpeed = settings.animSpeed;109 if (settings._model.status === 'closed') {110 triggerEvent({type: 'opening', target: $popup.get()}, settings);111 if (animEffect === 'fade') {112 $popup.fadeIn(animSpeed, function () {113 triggerEvent({type: 'opened', target: $popup.get()}, settings);114 });115 } else if (animEffect === 'slide') {116 $popup.slideDown(animSpeed, function () {117 triggerEvent({type: 'opened', target: $popup.get()}, settings);118 });119 }120 }121 };122 var closePopup = function ($popup, settings) {123 var animEffect = getSetting(settings, 'animEffect');124 var animSpeed = getSetting(settings, 'animSpeed');125 if (settings._model.status === 'opened') {126 triggerEvent({type: 'closing', target: $popup.get()}, settings);127 if (animEffect === 'fade') {128 $popup.fadeOut(animSpeed, function () {129 triggerEvent({type: 'closed', target: $popup.get()}, settings);130 });131 } else if (animEffect === 'slide') {132 $popup.slideUp(animSpeed, function () {133 triggerEvent({type: 'closed', target: $popup.get()}, settings);134 });135 }136 }137 };138 var addEventsListeners = function (settings) {139 var invoker = settings._model.invoker;140 var $popup = $(invoker).children('.pls-language-container-scrollable');141 var openMode = getSetting(settings, 'openMode');142 if (openMode === 'click') {143 $(invoker).children('a').on('click', function () {144 openPopup($popup, settings);145 return false;146 });147 } else if (openMode === 'hover') {148 var hoverTimeout = getSetting(settings, 'hoverTimeout');149 $(invoker).children('a').hover(function () {150 clearTimeout(settings._model.closePopupTimeout);151 settings._model.closePopupTimeout = -1;152 openPopup($popup, settings);153 }, function () {154 if (settings._model.closePopupTimeout < 0) {155 settings._model.closePopupTimeout = setTimeout(function () {156 closePopup($popup, settings);157 }, hoverTimeout);158 }159 });160 $popup.hover(function () {161 clearTimeout(settings._model.closePopupTimeout);162 settings._model.closePopupTimeout = -1;163 }, function () {164 if (settings._model.closePopupTimeout < 0) {165 settings._model.closePopupTimeout = setTimeout(function () {166 closePopup($popup, settings);167 }, hoverTimeout);168 }169 });170 } else {171 throw 'Open mode \'' + openMode + '\' not supported';172 }173 };174 return this.each(function () {175 var invoker = this;176 var settings = $.extend({177 _model: {178 invoker: invoker,179 status: 'closed',180 closePopupTimeout: -1,181 documentClickHandler: null,182 documentKeyHandler: null183 }184 }, $.fn.polyglotLanguageSwitcher.defaults, getOptions(this, options));185 buildUI(settings);186 addEventsListeners(settings);187 });188 };189 $.fn.polyglotLanguageSwitcher.defaults = {190 openMode: 'hover',191 hoverTimeout: 200,192 animSpeed: 200,193 animEffect: 'fade',194 gridColumns: 1,195 selectedLang: function () {196 return $('html').attr('lang');197 }198 }...

Full Screen

Full Screen

invoker.spec.js

Source:invoker.spec.js Github

copy

Full Screen

1/**2 * @author NHN. FE Development Team <dl_javascript@nhn.com>3 * @fileoverview Test cases of "src/js/invoker.js"4 */5import Invoker from '@/invoker';6import Command from '@/interface/command';7import { Promise } from '@/util';8describe('Invoker', () => {9 let invoker, cmd;10 beforeEach(() => {11 invoker = new Invoker();12 cmd = new Command({13 execute: jasmine.createSpy().and.returnValue(Promise.resolve()),14 undo: jasmine.createSpy().and.returnValue(Promise.resolve()),15 });16 });17 it('"redo()" should call "command.execute" again', (done) => {18 invoker19 .execute(cmd)20 .then(() => invoker.undo())21 .then(() => {22 cmd.execute.calls.reset();23 return invoker.redo();24 })25 .then(() => {26 expect(cmd.execute).toHaveBeenCalled();27 done();28 });29 });30 it('should call the "command.executeCallback" after invoke', (done) => {31 const spyCallback = jasmine.createSpy();32 cmd.setExecuteCallback(spyCallback);33 invoker.execute(cmd).then(() => {34 expect(spyCallback).toHaveBeenCalled();35 done();36 });37 });38 it('should call the "command.undoCallback" after undo', (done) => {39 const spyCallback = jasmine.createSpy();40 cmd.setUndoCallback(spyCallback);41 invoker42 .execute(cmd)43 .then(() => invoker.undo())44 .then(() => {45 expect(spyCallback).toHaveBeenCalled();46 done();47 });48 });49 describe('invoker.customEvents', () => {50 let spyEvents;51 beforeEach(() => {52 spyEvents = {53 undoStackChanged: jasmine.createSpy(),54 redoStackChanged: jasmine.createSpy(),55 };56 });57 it(58 '"invoke()" should fire a event - ' + ' "pushUndoStack" (when redoStack is empty before)"',59 (done) => {60 invoker.on(spyEvents);61 invoker.execute(cmd).then(() => {62 expect(spyEvents.undoStackChanged).toHaveBeenCalledWith(1);63 expect(spyEvents.redoStackChanged).not.toHaveBeenCalled();64 done();65 });66 }67 );68 it(69 '"invoke()" should fire events - ' +70 ' "pushUndoStack", "clearRedoStack" (when redoStack is not empty before)',71 (done) => {72 invoker.pushRedoStack({});73 invoker.on(spyEvents);74 invoker.execute(cmd).then(() => {75 expect(spyEvents.undoStackChanged).toHaveBeenCalledWith(1);76 expect(spyEvents.redoStackChanged).toHaveBeenCalledWith(0);77 done();78 });79 }80 );81 it(82 '"undo()" should fire a event - ' + ' "pushRedoStack" (when undoStack is not empty after)',83 (done) => {84 invoker85 .execute(cmd)86 .then(() => invoker.execute(cmd))87 .then(() => {88 invoker.on(spyEvents);89 return invoker.undo();90 })91 .then(() => {92 expect(spyEvents.undoStackChanged).not.toHaveBeenCalled();93 expect(spyEvents.redoStackChanged).toHaveBeenCalledWith(1);94 done();95 });96 }97 );98 it(99 '"undo()" should fire events - ' +100 ' "pushRedoStack", "emptyUndoStack" (when undoStack is empty after)',101 (done) => {102 invoker103 .execute(cmd)104 .then(() => {105 invoker.on(spyEvents);106 return invoker.undo();107 })108 .then(() => {109 expect(spyEvents.redoStackChanged).toHaveBeenCalledWith(1);110 expect(spyEvents.undoStackChanged).toHaveBeenCalledWith(0);111 done();112 });113 }114 );115 it(116 '"redo()" should fire a event - ' + ' "pushUndoStack" (when redoStack is not empty after)',117 (done) => {118 invoker119 .execute(cmd)120 .then(() => invoker.execute(cmd))121 .then(() => invoker.undo())122 .then(() => invoker.undo())123 .then(() => {124 invoker.on(spyEvents);125 return invoker.redo();126 })127 .then(() => {128 expect(spyEvents.undoStackChanged).toHaveBeenCalledWith(1);129 expect(spyEvents.redoStackChanged).not.toHaveBeenCalled();130 done();131 });132 }133 );134 it(135 '"redo()" should fire events - ' +136 ' "pushUndoStack", "emptyRedoStack" (when undoStack is empty after)',137 (done) => {138 invoker139 .execute(cmd)140 .then(() => invoker.undo())141 .then(() => {142 invoker.on(spyEvents);143 return invoker.redo(cmd);144 })145 .then(() => {146 expect(spyEvents.undoStackChanged).toHaveBeenCalledWith(1);147 expect(spyEvents.redoStackChanged).toHaveBeenCalledWith(0);148 done();149 });150 }151 );152 });...

Full Screen

Full Screen

body.js

Source:body.js Github

copy

Full Screen

1/*-----------------------------------------------2//////////////// vk.com/d2jscripts //////////////3/////////////////////////////////////////////////4Панель показывает куллдаун скилов и манакост, 5так же позволяет сотворить заклинание кликом по иконке6Автор: vk.com/exieros7/////////////////////////////////////////////////8-----------------------End---------------------*/9var Config10try{ Game.Panels.InvokerPanel.DeleteAsync(0) }catch(e){}11for (i in Game.Subscribes.InvokerPanel)12 try{ GameEvents.Unsubscribe( Game.Subscribes.InvokerPanel[i] ) }catch(e){}13Game.Subscribes.InvokerPanel = []14Game.Subscribes.InvokerPanel.push( GameEvents.Subscribe('game_newmap', RefreshIPS) )15Game.Subscribes.InvokerPanel.push( GameEvents.Subscribe('player_connect_full', RefreshIPS) )16Game.Subscribes.InvokerPanel.push( GameEvents.Subscribe('player_connect', RefreshIPS) )17Game.Subscribes.InvokerPanel.push( GameEvents.Subscribe('dota_player_pick_hero', RefreshIPS) )18Game.Subscribes.InvokerPanel.push( GameEvents.Subscribe('dota_player_update_hero_selection', RefreshIPS) )19function RefreshIPS(){20 var MyID = Game.GetLocalPlayerID()21 try{ Game.Panels.InvokerPanel.DeleteAsync(0) }catch(e){}22 for (i in Game.Subscribes.InvokerPanel)23 try{ GameEvents.Unsubscribe( Game.Subscribes.InvokerPanel[i] ) }catch(e){}24 Game.Subscribes.InvokerPanel = []25}26InvokerPanelF = function(){27 var MyID = Game.GetLocalPlayerID()28 if ( MyID==-1 ){29 InvokerPanel.checked = false30 try{ Game.Panels.InvokerPanel.DeleteAsync(0) }catch(e){}31 for (i in Game.Subscribes.InvokerPanel)32 try{ GameEvents.Unsubscribe( Game.Subscribes.InvokerPanel[i] ) }catch(e){}33 Game.Subscribes.InvokerPanel = []34 return35 }36 if ( Players.GetPlayerSelectedHero(MyID) != 'npc_dota_hero_invoker' ){37 //Game.ScriptLogMsg('InvokerPanel: Not Invoker', '#ff0000')38 InvokerPanel.checked = false39 try{ Game.Panels.InvokerPanel.DeleteAsync(0) }catch(e){}40 for (i in Game.Subscribes.InvokerPanel)41 try{ GameEvents.Unsubscribe( Game.Subscribes.InvokerPanel[i] ) }catch(e){}42 Game.Subscribes.InvokerPanel = []43 return44 }45 if (InvokerPanel.checked){46 Game.GetFile('Invokerpanel/invokerpanel.xml', function(a){47 Game.Panels.InvokerPanel = $.CreatePanel( 'Panel', Game.GetMainHUD(), 'InvokerPanelMain' )48 Game.Panels.InvokerPanel.BLoadLayoutFromString( a, false, false )49 GameUI.MovePanel(Game.Panels.InvokerPanel,function(p){50 var position = p.style.position.split(' ')51 Config.MainPanel.x = position[0]52 Config.MainPanel.y = position[1]53 Game.SaveConfig('Invokerpanel/config.conf', Config)54 })55 Game.GetConfig('Invokerpanel/config.conf',function(a){56 Config = a[0]57 Game.Panels.InvokerPanel.style.position = Config.MainPanel.x + ' ' + Config.MainPanel.y + ' 0'58 Game.Panels.InvokerPanel.style.flowChildren = Config.MainPanel.flow59 })60 try{Game.AddCommand( '__InvokerPanel_Rotate', function(){61 if (Game.Panels.InvokerPanel.Children()[0].style.flowChildren == 'right')62 Game.Panels.InvokerPanel.Children()[0].style.flowChildren = 'down'63 else64 Game.Panels.InvokerPanel.Children()[0].style.flowChildren = 'right'65 Config.MainPanel.flow = Game.Panels.InvokerPanel.style.flowChildren66 Game.SaveConfig('Invokerpanel/config.conf', Config)67 }, '',0 )}catch(e){}68 })69 Game.ScriptLogMsg('Script enabled: InvokerPanel', '#00ff00')70 }else{71 try{ Game.Panels.InvokerPanel.DeleteAsync(0) }catch(e){}72 for (i in Game.Subscribes.InvokerPanel)73 try{ GameEvents.Unsubscribe( Game.Subscribes.InvokerPanel[i] ) }catch(e){}74 Game.Subscribes.InvokerPanel = []75 }76}77 78var Temp = $.CreatePanel( "Panel", $('#scripts'), "Invokerpanel" )79Temp.SetPanelEvent( 'onactivate', InvokerPanelF )80Temp.BLoadLayoutFromString( '<root><styles><include src="s2r://panorama/styles/dotastyles.vcss_c" /><include src="s2r://panorama/styles/magadan.vcss_c" /></styles><Panel><ToggleButton class="CheckBox" id="Invokerpanel" text="InvokerPanelV"/></Panel></root>', false, false)81var InvokerPanel = $.GetContextPanel().FindChildTraverse( 'Invokerpanel' ).Children()[0]...

Full Screen

Full Screen

obj.js

Source:obj.js Github

copy

Full Screen

...9 // arrange10 var subject = [];11 12 // act 13 invoker([1,2,3,4], function(i, j){this.push({val:i, name:j});}, subject);14 15 // assert 16 strictEqual(subject.length, 4);17 strictEqual(subject[0].name, 0);18 strictEqual(subject[0].val, 1);19 strictEqual(subject[1].name, 1);20 strictEqual(subject[1].val, 2);21 strictEqual(subject[2].name, 2);22 strictEqual(subject[2].val, 3);23 strictEqual(subject[3].name, 3);24 strictEqual(subject[3].val, 4);25});26testUtils.testWithUtils("enumerateObj", null, true, function(methods, classes, subject, invoker) {27 // arrange28 var subject = [];29 30 // act 31 invoker({"a":1,"b": 2,"c": 3,"d": 4}, function(i, j){this.push({val:i, name:j});}, subject);32 33 // assert 34 strictEqual(subject.length, 4);35 strictEqual(subject[0].name, "a");36 strictEqual(subject[0].val, 1);37 strictEqual(subject[1].name, "b");38 strictEqual(subject[1].val, 2);39 strictEqual(subject[2].name, "c");40 strictEqual(subject[2].val, 3);41 strictEqual(subject[3].name, "d");42 strictEqual(subject[3].val, 4);43});44testUtils.testWithUtils("trim", "", true, function(methods, classes, subject, invoker) {45 // arrange46 var string = "JKHVJKHVJKHVH";47 48 // act 49 // assert50 strictEqual(invoker(" \n\r\t" + string + " \n\r\t"), string);51});52testUtils.testWithUtils("trimToLower", "", true, function(methods, classes, subject, invoker) {53 // arrange54 var string = "JKHVJKHVJKHVH";55 56 // act 57 // assert58 strictEqual(invoker(" \n\r\t" + string + " \n\r\t"), string.toLowerCase());59});60testUtils.testWithUtils("camelCase", "", true, function(methods, classes, subject, invoker) {61 // arrange 62 // act 63 // assert64 strictEqual(invoker("hello-one"), "helloOne");65 strictEqual(invoker("-hello-one"), "HelloOne");66 strictEqual(invoker("hello-one-"), "helloOne");67 strictEqual(invoker(null), null);68});69testUtils.testWithUtils("parseBool", "", true, function(methods, classes, subject, invoker) {70 // arrange 71 // act 72 // assert 73 strictEqual(invoker("sdasd"), true); 74 strictEqual(invoker("true"), true); 75 strictEqual(invoker("0"), false); 76 strictEqual(invoker(0), false); 77 strictEqual(invoker(""), false); 78 strictEqual(invoker("FalSe"), false); 79});80testUtils.testWithUtils("getObject", "", true, function(methods, classes, subject, invoker) {81 // arrange82 var ctxt = {a:{b:{c:{d:{}}}}};83 84 // act 85 // assert 86 strictEqual(invoker("a.b.c.d", ctxt), ctxt.a.b.c.d);87});88testUtils.testWithUtils("setObject", "", true, function(methods, classes, subject, invoker) {89 // arrange90 var ctxt = {a:{b:{c:{d:{}}}}}, obj = {};91 92 // act93 invoker("a.b.c.d", ctxt, obj);94 95 // assert 96 strictEqual(obj, ctxt.a.b.c.d);97});98testUtils.testWithUtils("splitPropertyName", "", true, function(methods, classes, subject, invoker) {99 // arrange 100 // act 101 // assert 102 deepEqual(invoker("a.b.c[3].t"), ["a", "b", "c", 3, "t"]);103});104testUtils.testWithUtils("joinPropertyName", "", true, function(methods, classes, subject, invoker) {105 // arrange 106 // act 107 // assert 108 deepEqual(invoker(["a", "b", "c", 3, "t"]), "a.b.c[3].t");109});110testUtils.testWithUtils("copyArray", "", true, function(methods, classes, subject, invoker) {111 // arrange112 var expected = [{}, {}, {}];113 114 // act 115 var actual = invoker(expected);116 117 // assert 118 strictEqual(actual.length, expected.length);119 for(var i = 0, ii = actual.length; i < ii; i++)120 strictEqual(actual[i], expected[i]); 121});122testUtils.testWithUtils("extend", "", true, function(methods, classes, subject, invoker) {123 // arrange124 var obj1 = {};125 var obj2 = {aaa:{}};126 127 // act128 var out = invoker(obj1, obj2);129 130 // assert 131 strictEqual(out, obj1);132 strictEqual(out.aaa, obj2.aaa);...

Full Screen

Full Screen

merge-hook.js

Source:merge-hook.js Github

copy

Full Screen

1/* @flow */2import { remove } from 'shared/util'3import { createFnInvoker } from './update-listeners'4export function mergeVNodeHook (def: Object, hookKey: string, hook: Function) {5 let invoker6 const oldHook = def[hookKey]7 function wrappedHook () {8 hook.apply(this, arguments)9 // important: remove merged hook to ensure it's called only once10 // and prevent memory leak11 remove(invoker.fns, wrappedHook)12 }13 if (!oldHook) {14 // no existing hook15 invoker = createFnInvoker([wrappedHook])16 } else {17 /* istanbul ignore if */18 if (oldHook.fns && oldHook.merged) {19 // already a merged invoker20 invoker = oldHook21 invoker.fns.push(wrappedHook)22 } else {23 // existing plain hook24 invoker = createFnInvoker([oldHook, wrappedHook])25 }26 }27 invoker.merged = true28 def[hookKey] = invoker...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright['chromium'].launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: 'google.png' });7 await browser.close();8})();9const playwright = require('playwright');10(async () => {11 const browser = await playwright['chromium'].launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({ path: 'google.png' });15 await browser.close();16})();17const playwright = require('playwright');18(async () => {19 const browser = await playwright['chromium'].launch();20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.screenshot({ path: 'google.png' });23 await browser.close();24})();25const playwright = require('playwright');26(async () => {27 const browser = await playwright['chromium'].launch();28 const context = await browser.newContext();29 const page = await context.newPage();30 await page.screenshot({ path: 'google.png' });31 await browser.close();32})();33const playwright = require('playwright');34(async () => {35 const browser = await playwright['chromium'].launch();36 const context = await browser.newContext();37 const page = await context.newPage();38 await page.screenshot({ path: 'google.png' });39 await browser.close();40})();41const playwright = require('playwright');42(async () => {43 const browser = await playwright['chromium'].launch();44 const context = await browser.newContext();45 const page = await context.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright['chromium'].launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: 'example.png' });7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.screenshot({ path: 'example.png' });6 await browser.close();7})();8const playwright = require('playwright');9(async () => {10 const browser = await playwright.chromium.launch();11 const page = await browser.newPage();12 await page.screenshot({ path: 'example.png' });13 await browser.close();14})();15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const page = await browser.newPage();19 await page.screenshot({ path: 'example.png' });20 await browser.close();21})();22const playwright = require('playwright');23(async () => {24 const browser = await playwright.chromium.launch();25 const page = await browser.newPage();26 await page.screenshot({ path: 'example.png' });27 await browser.close();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launch();32 const page = await browser.newPage();33 await page.screenshot({ path: 'example.png' });34 await browser.close();35})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.screenshot({ path: 'google.png' });6 await browser.close();7})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const { chromium } = playwright;3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: 'google.png' });8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 const title = await page.title();6 console.log(title);7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const page = await browser.newPage();13 const title = await page.title();14 console.log(title);15 await browser.close();16})();17const { chromium } = require('playwright');18(async () => {19 const browser = await chromium.launch();20 const page = await browser.newPage();21 const title = await page.title();22 console.log(title);23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const page = await browser.newPage();29 const title = await page.title();30 console.log(title);31 await browser.close();32})();33const { chromium } = require('playwright');34(async () => {35 const browser = await chromium.launch();36 const page = await browser.newPage();37 const title = await page.title();38 console.log(title);39 await browser.close();40})();41const { chromium } = require('playwright');42(async () => {43 const browser = await chromium.launch();44 const page = await browser.newPage();45 const title = await page.title();46 console.log(title);47 await browser.close();48})();49const { chromium } = require('playwright');50(async () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const { invoker } = playwright;3(async () => {4 const browser = await invoker.launch('chromium');5 const page = await invoker.newPage(browser);6 await invoker.close(browser);7})();8const playwright = require('playwright');9const { invoker } = playwright;10(async () => {11 const browser = await invoker.launch('chromium');12 const page = await invoker.newPage(browser);13 await invoker.close(browser);14})();15const playwright = require('playwright');16const { invoker } = playwright;17(async () => {18 const browser = await invoker.launch('chromium');19 const page = await invoker.newPage(browser);20 await invoker.close(browser);21})();22const playwright = require('playwright');23const { invoker } = playwright;24(async () => {25 const browser = await invoker.launch('chromium');26 const page = await invoker.newPage(browser);27 await invoker.close(browser);28})();29const playwright = require('playwright');30const { invoker } = playwright;31(async () => {32 const browser = await invoker.launch('chromium');33 const page = await invoker.newPage(browser);34 await invoker.close(browser);35})();36const playwright = require('playwright');37const { invoker } = playwright;38(async () => {39 const browser = await invoker.launch('chromium');40 const page = await invoker.newPage(browser);41 await invoker.close(browser);42})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const { chromium } = playwright;3const browser = await chromium.launch();4const context = await browser.newContext();5const page = await context.newPage();6const invoker = page._delegate;7console.log(result);8const playwright = require('playwright');9const { chromium } = playwright;10const browser = await chromium.launch();11const context = await browser.newContext();12const page = await context.newPage();13const invoker = page._delegate;14console.log(result);15const playwright = require('playwright');16const { chromium } = playwright;17const browser = await chromium.launch();18const context = await browser.newContext();19const page = await context.newPage();20const invoker = page._delegate;21console.log(result);22const playwright = require('playwright');23const { chromium } = playwright;24const browser = await chromium.launch();25const context = await browser.newContext();26const page = await context.newPage();27const invoker = page._delegate;28console.log(result);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium, firefox, webkit } = require('playwright');2const { PlaywrightInvoker } = require('@playwright/test/lib/server/playwrightInvoker');3const { test } = require('@playwright/test');4test.describe('test', () => {5 test('test', async ({ browserName }) => {6 const browserType = { chromium, firefox, webkit }[browserName];7 const playwrightInvoker = new PlaywrightInvoker(browserType);8 const browser = await playwrightInvoker.invoke('launch');9 const context = await playwrightInvoker.invoke('newContext', browser);10 const page = await playwrightInvoker.invoke('newPage', context);11 await browser.close();12 });13});14{15 "scripts": {16 },17 "devDependencies": {18 }19}20module.exports = {21 use: {22 viewport: { width: 1280, height: 720 },23 },24 {25 use: {26 },27 },28 {29 use: {30 },31 },32 {33 use: {34 },35 },36};37 FAIL test.js (15.677 s)

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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