How to use sinon.createStubInstance method in sinon

Best JavaScript code snippet using sinon

request.js

Source:request.js Github

copy

Full Screen

...24 let nexmo;25 let request;26 let response;27 beforeEach(() => {28 client = sinon.createStubInstance(Client);29 config = sinon.createStubInstance(Config);30 response = sinon.createStubInstance(Response);31 request = new Request(config, client, response);32 });33 describe('.accountSetup', () => {34 it('should verifiy the credentials', test(function(){35 nexmo = {};36 nexmo.account = sinon.createStubInstance(Account);37 client.instanceWith.returns(nexmo);38 response.accountSetup.returns(()=>{});39 request.accountSetup('123', 'abc', false);40 expect(nexmo.account.checkBalance).to.have.been.called;41 expect(response.accountSetup).to.have.been.called;42 }));43 });44 describe('.accountInfo', () => {45 it('should read the credentials', test(function() {46 nexmo = { credentials: 'credentials' };47 client.instance.returns(nexmo);48 request.accountInfo();49 expect(response.accountInfo).to.have.been.calledWith({ credentials: 'credentials' });50 }));51 });52 describe('.accountBalance', () => {53 it('should call nexmo.account.checkBalance', test(function() {54 nexmo = {};55 nexmo.account = sinon.createStubInstance(Account);56 client.instance.returns(nexmo);57 request.accountBalance();58 expect(nexmo.account.checkBalance).to.have.been.called;59 }));60 });61 describe('.priceVoice', () => {62 it('should call nexmo.number.getPhonePricing', test(function() {63 nexmo = {};64 nexmo.number = sinon.createStubInstance(Number);65 client.instance.returns(nexmo);66 request.priceVoice();67 expect(nexmo.number.getPhonePricing).to.have.been.called;68 }));69 it('should accept a + in the number', test(function() {70 nexmo = {};71 nexmo.number = sinon.createStubInstance(Number);72 client.instance.returns(nexmo);73 request.priceVoice('+123123123123');74 expect(nexmo.number.getPhonePricing).to.have.been.calledWith('voice', '123123123123');75 }));76 });77 describe('.priceSms', () => {78 it('should call nexmo.number.getPhonePricing', test(function() {79 nexmo = {};80 nexmo.number = sinon.createStubInstance(Number);81 client.instance.returns(nexmo);82 request.priceSms();83 expect(nexmo.number.getPhonePricing).to.have.been.called;84 }));85 });86 describe('.priceCountry', () => {87 it('should call nexmo.number.getPricing', test(function() {88 nexmo = {};89 nexmo.number = sinon.createStubInstance(Number);90 client.instance.returns(nexmo);91 request.priceCountry();92 expect(nexmo.number.getPricing).to.have.been.called;93 }));94 });95 describe('.numbersList', () => {96 it('should call nexmo.number.get', test(function() {97 nexmo = {};98 nexmo.number = sinon.createStubInstance(Number);99 client.instance.returns(nexmo);100 response.numbersList.returns(()=>{});101 request.numbersList({});102 expect(nexmo.number.get).to.have.been.called;103 expect(nexmo.number.get).to.have.been.calledWith({ size: 100 });104 }));105 it('should parse a page flag', test(function() {106 nexmo = {};107 nexmo.number = sinon.createStubInstance(Number);108 client.instance.returns(nexmo);109 response.numbersList.returns(()=>{});110 request.numbersList({ page: 2 });111 expect(nexmo.number.get).to.have.been.calledWith({ index: 2, size: 100 });112 }));113 it('should parse a size flag', test(function() {114 nexmo = {};115 nexmo.number = sinon.createStubInstance(Number);116 client.instance.returns(nexmo);117 response.numbersList.returns(()=>{});118 request.numbersList({ size: 25 });119 expect(nexmo.number.get).to.have.been.calledWith({ size: 25 });120 }));121 it('should handle search with a default search_pattern of 1', test(function() {122 nexmo = {};123 nexmo.number = sinon.createStubInstance(Number);124 client.instance.returns(nexmo);125 response.numbersList.returns(()=>{});126 const pattern = '123';127 request.numbersList({ pattern: pattern });128 expect(nexmo.number.get).to.have.been.calledWith({ pattern: pattern, search_pattern: 1, size: 100 });129 }));130 it('should handle search with a search_pattern of 2 when * is the first pattern char', test(function() {131 nexmo = {};132 nexmo.number = sinon.createStubInstance(Number);133 client.instance.returns(nexmo);134 response.numbersList.returns(()=>{});135 const pattern = '*123';136 request.numbersList({ pattern: pattern });137 expect(nexmo.number.get).to.have.been.calledWith({ pattern: pattern, search_pattern: 2, size: 100 });138 }));139 it('should handle search with a search_pattern of 0 when * is the last pattern char', test(function() {140 nexmo = {};141 nexmo.number = sinon.createStubInstance(Number);142 client.instance.returns(nexmo);143 response.numbersList.returns(()=>{});144 const pattern = '123*';145 request.numbersList({ pattern: pattern });146 expect(nexmo.number.get).to.have.been.calledWith({ pattern: pattern, search_pattern: 0, size: 100 });147 }));148 });149 describe('.numberSearch', () => {150 it('should call nexmo.number.search', test(function() {151 nexmo = {};152 nexmo.number = sinon.createStubInstance(Number);153 client.instance.returns(nexmo);154 response.numberSearch.returns(()=>{});155 request.numberSearch('GB', {});156 expect(nexmo.number.search).to.have.been.calledWith('GB', { features: [], size: 100 });157 }));158 it('should parse a voice flag', test(function() {159 nexmo = {};160 nexmo.number = sinon.createStubInstance(Number);161 client.instance.returns(nexmo);162 response.numberSearch.returns(()=>{});163 request.numberSearch('GB', { voice: true });164 expect(nexmo.number.search).to.have.been.calledWith('GB', { features: ['VOICE'], size: 100 });165 }));166 it('should parse a sms flag', test(function() {167 nexmo = {};168 nexmo.number = sinon.createStubInstance(Number);169 client.instance.returns(nexmo);170 response.numberSearch.returns(()=>{});171 request.numberSearch('GB', { sms: true });172 expect(nexmo.number.search).to.have.been.calledWith('GB', { features: ['SMS'], size: 100 });173 }));174 it('should parse both the sms and voice flag', test(function() {175 nexmo = {};176 nexmo.number = sinon.createStubInstance(Number);177 client.instance.returns(nexmo);178 response.numberSearch.returns(()=>{});179 request.numberSearch('GB', { sms: true, voice: true });180 expect(nexmo.number.search).to.have.been.calledWith('GB', { features: ['VOICE','SMS'], size: 100 });181 }));182 it('should parse a page flag', test(function() {183 nexmo = {};184 nexmo.number = sinon.createStubInstance(Number);185 client.instance.returns(nexmo);186 response.numberSearch.returns(()=>{});187 request.numberSearch('GB', { page: 2 });188 expect(nexmo.number.search).to.have.been.calledWith('GB', { features: [], index: 2, size: 100 });189 }));190 it('should parse a size flag', test(function() {191 nexmo = {};192 nexmo.number = sinon.createStubInstance(Number);193 client.instance.returns(nexmo);194 response.numberSearch.returns(()=>{});195 request.numberSearch('GB', { size: 25 });196 expect(nexmo.number.search).to.have.been.calledWith('GB', { features: [], size: 25 });197 }));198 it('should pass the pattern flag without a wildcard', test(function() {199 nexmo = {};200 nexmo.number = sinon.createStubInstance(Number);201 client.instance.returns(nexmo);202 response.numberSearch.returns(()=>{});203 request.numberSearch('GB', { pattern: '020'});204 expect(nexmo.number.search).to.have.been.calledWith('GB', { features: [], pattern: '020', search_pattern: 1, size: 100 });205 }));206 it('should pass the pattern flag with a start-of wildcard', test(function() {207 nexmo = {};208 nexmo.number = sinon.createStubInstance(Number);209 client.instance.returns(nexmo);210 response.numberSearch.returns(()=>{});211 request.numberSearch('GB', { pattern: '*020'});212 expect(nexmo.number.search).to.have.been.calledWith('GB', { features: [], pattern: '*020', search_pattern: 2, size: 100 });213 }));214 });215 describe('.numberBuy', () => {216 it('should call the library', test(function() {217 nexmo = {};218 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);219 client.instance.returns(nexmo);220 request.numberBuy('123', { confirm: true });221 expect(nexmo.numberInsight.get).to.have.been.calledWith({ level: 'basic', number: '123' });222 }));223 it('should handle search with a default search_pattern of 1', test(function() {224 nexmo = {};225 nexmo.number = sinon.createStubInstance(Number);226 client.instance.returns(nexmo);227 const country_code = 'GB';228 const pattern = '123';229 request.numberBuy(pattern, { country_code: country_code });230 expect(nexmo.number.search).to.have.been.calledWith(231 country_code,232 {233 features: ['VOICE'],234 pattern: pattern,235 search_pattern: 1236 }237 );238 }));239 it('should handle search with a search_pattern of 2 when * is the first pattern char', test(function() {240 nexmo = {};241 nexmo.number = sinon.createStubInstance(Number);242 client.instance.returns(nexmo);243 const country_code = 'GB';244 const pattern = '*123';245 request.numberBuy(pattern, { country_code: country_code });246 expect(nexmo.number.search).to.have.been.calledWith(247 country_code,248 {249 features: ['VOICE'],250 pattern: pattern,251 search_pattern: 2252 }253 );254 }));255 it('should handle search with a search_pattern of 0 when * is the last pattern char', test(function() {256 nexmo = {};257 nexmo.number = sinon.createStubInstance(Number);258 client.instance.returns(nexmo);259 const country_code = 'GB';260 const pattern = '123*';261 request.numberBuy(pattern, { country_code: country_code });262 expect(nexmo.number.search).to.have.been.calledWith(263 country_code,264 {265 features: ['VOICE'],266 pattern: pattern,267 search_pattern: 0268 }269 );270 }));271 it('should buy the first number only country_code flag is set', () => {272 nexmo = {};273 nexmo.number = sinon.createStubInstance(Number);274 client.instance.returns(nexmo);275 const country_code = 'GB';276 request.numberBuy(null, { country_code: country_code });277 expect(nexmo.number.search).to.have.been.calledWith(278 country_code,279 {280 features: ['VOICE']281 }282 );283 });284 });285 describe('.numberCancel', () => {286 it('should call nexmo.numberInsight.get', test(function() {287 nexmo = {};288 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);289 client.instance.returns(nexmo);290 request.numberCancel('123', { confirm: true });291 expect(nexmo.numberInsight.get).to.have.been.called;292 }));293 it('should call nexmo.number.cancel if the country code was forced', test(function() {294 nexmo = {};295 nexmo.number = sinon.createStubInstance(Number);296 nexmo.response = sinon.createStubInstance(Response);297 client.instance.returns(nexmo);298 response.numberCancel.returns(()=>{});299 request.numberCancel('123', { country_code: 'GB', confirm: true });300 expect(nexmo.number.cancel).to.have.been.called;301 }));302 });303 describe('.applicationsList', () => {304 it('should call nexmo.app.get', test(function() {305 nexmo = {};306 nexmo.app = sinon.createStubInstance(App);307 client.instance.returns(nexmo);308 response.applicationsList.returns(()=>{});309 request.applicationsList({});310 expect(nexmo.app.get).to.have.been.calledWith({page_size: 100});311 }));312 it('should parse a page flag', test(function() {313 nexmo = {};314 nexmo.app = sinon.createStubInstance(App);315 client.instance.returns(nexmo);316 response.applicationsList.returns(()=>{});317 request.applicationsList({ page: 2 });318 expect(nexmo.app.get).to.have.been.calledWith({ index: 2, page_size: 100 });319 }));320 it('should parse a size flag', test(function() {321 nexmo = {};322 nexmo.app = sinon.createStubInstance(App);323 client.instance.returns(nexmo);324 response.applicationsList.returns(()=>{});325 request.applicationsList({ size: 25 });326 expect(nexmo.app.get).to.have.been.calledWith({ page_size: 25 });327 }));328 });329 describe('.applicationCreate', () => {330 it('should call nexmo.app.create', test(function() {331 nexmo = {};332 nexmo.app = sinon.createStubInstance(App);333 client.instance.returns(nexmo);334 request.applicationCreate('name', 'answer_url', 'event_url', { type: 'voice' });335 expect(nexmo.app.create).to.have.been.called;336 }));337 it('should parse a answer_method flag', test(function() {338 nexmo = {};339 nexmo.app = sinon.createStubInstance(App);340 client.instance.returns(nexmo);341 request.applicationCreate('name', 'answer_url', 'event_url', { type: 'voice', answer_method: 'POST' });342 expect(nexmo.app.create).to.have.been.calledWith('name', 'voice', 'answer_url', 'event_url', { answer_method : 'POST' });343 }));344 it('should parse a event_method flag', test(function() {345 nexmo = {};346 nexmo.app = sinon.createStubInstance(App);347 client.instance.returns(nexmo);348 request.applicationCreate('name', 'answer_url', 'event_url', { type: 'voice', event_method: 'POST' });349 expect(nexmo.app.create).to.have.been.calledWith('name', 'voice', 'answer_url', 'event_url', { event_method : 'POST' });350 }));351 });352 describe('.applicationShow', () => {353 it('should call the library', test(function() {354 nexmo = {};355 nexmo.app = sinon.createStubInstance(App);356 client.instance.returns(nexmo);357 request.applicationShow('app_id');358 expect(nexmo.app.get).to.have.been.called;359 }));360 });361 describe('.applicationUpdate', () => {362 it('should call the library', test(function() {363 nexmo = {};364 nexmo.app = sinon.createStubInstance(App);365 client.instance.returns(nexmo);366 request.applicationUpdate('app_id', 'name', 'answer_url', 'event_url', { type: 'voice' });367 expect(nexmo.app.update).to.have.been.called;368 }));369 it('should parse a answer_method flag', test(function() {370 nexmo = {};371 nexmo = {};372 nexmo.app = sinon.createStubInstance(App);373 client.instance.returns(nexmo);374 request.applicationUpdate('app_id', 'name', 'answer_url', 'event_url', { type: 'voice', answer_method: 'POST' });375 expect(nexmo.app.update).to.have.been.calledWith('app_id', 'name', 'voice', 'answer_url', 'event_url', { answer_method : 'POST' });376 }));377 it('should parse a event_method flag', test(function() {378 nexmo = {};379 nexmo.app = sinon.createStubInstance(App);380 client.instance.returns(nexmo);381 request.applicationUpdate('app_id', 'name', 'answer_url', 'event_url', { type: 'voice', event_method: 'POST' });382 expect(nexmo.app.update).to.have.been.calledWith('app_id', 'name', 'voice', 'answer_url', 'event_url', { event_method : 'POST' });383 }));384 });385 describe('.applicationDelete', () => {386 it('should call the library', test(function() {387 nexmo = {};388 nexmo.app = sinon.createStubInstance(App);389 client.instance.returns(nexmo);390 request.applicationDelete('123', { confirm: true });391 expect(nexmo.app.delete).to.have.been.called;392 }));393 });394 describe('.applicationNumbers', () => {395 it('should call nexmo.number.get', test(function() {396 nexmo = {};397 nexmo.number = sinon.createStubInstance(Number);398 client.instance.returns(nexmo);399 response.applicationNumbers.returns(()=>{});400 request.applicationNumbers('app_id', {});401 expect(nexmo.number.get).to.have.been.called;402 }));403 it('should parse a page flag', test(function() {404 nexmo = {};405 nexmo.number = sinon.createStubInstance(Number);406 client.instance.returns(nexmo);407 response.applicationNumbers.returns(()=>{});408 request.applicationNumbers('app_id', { page: 2 });409 expect(nexmo.number.get).to.have.been.calledWith({ index: 2 });410 }));411 it('should parse a size flag', test(function() {412 nexmo = {};413 nexmo.number = sinon.createStubInstance(Number);414 client.instance.returns(nexmo);415 response.applicationNumbers.returns(()=>{});416 request.applicationNumbers('app_id', { size: 25 });417 expect(nexmo.number.get).to.have.been.calledWith({ size: 25 });418 }));419 });420 describe('.linkApp', () => {421 it('should call the nexmo.number.get({level:"basic"})', test(function() {422 nexmo = {};423 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);424 client.instance.returns(nexmo);425 request.linkApp('123', 'abc');426 expect(nexmo.numberInsight.get).to.have.been.calledWithMatch({level:'basic'});427 }));428 });429 describe('.unlinkApp', () => {430 it('should call nexmo.numberInsight.get', test(function() {431 nexmo = {};432 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);433 client.instance.returns(nexmo);434 request.unlinkApp('123');435 expect(nexmo.numberInsight.get).to.have.been.calledWithMatch({level:'basic'});436 }));437 });438 describe('.linkSms', () => {439 it('should call the library', test(function() {440 nexmo = {};441 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);442 client.instance.returns(nexmo);443 request.linkSms('123', 'abc');444 expect(nexmo.numberInsight.get).to.have.been.calledWithMatch({level:'basic'});445 }));446 });447 describe('.unlinkSms', () => {448 it('should call nexmo.numberInsight.get', test(function() {449 nexmo = {};450 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);451 client.instance.returns(nexmo);452 request.unlinkSms('123');453 expect(nexmo.numberInsight.get).to.have.been.calledWithMatch({level:'basic'});454 }));455 });456 describe('.linkTel', () => {457 it('should call nexmo.numberInsight.get', test(function() {458 nexmo = {};459 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);460 client.instance.returns(nexmo);461 request.linkTel('123', 'abc', {});462 expect(nexmo.numberInsight.get).to.have.been.calledWithMatch({level:'basic'});463 }));464 });465 describe('.unlinkTel', () => {466 it('should call nexmo.numberInsight.get', test(function() {467 nexmo = {};468 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);469 client.instance.returns(nexmo);470 request.unlinkTel('123');471 expect(nexmo.numberInsight.get).to.have.been.calledWithMatch({level:'basic'});472 }));473 describe('.linkVxml', () => {474 it('should call nexmo.numberInsight.get', test(function() {475 nexmo = {};476 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);477 client.instance.returns(nexmo);478 request.linkVxml('123', 'abc', {});479 expect(nexmo.numberInsight.get).to.have.been.calledWithMatch({level:'basic'});480 }));481 });482 describe('.unlinkVxml', () => {483 it('should call nexmo.numberInsight.get', test(function() {484 nexmo = {};485 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);486 client.instance.returns(nexmo);487 request.unlinkVxml('123');488 expect(nexmo.numberInsight.get).to.have.been.calledWithMatch({level:'basic'});489 }));490 });491 describe('.linkSip', () => {492 it('should call nexmo.numberInsight.get', test(function() {493 nexmo = {};494 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);495 client.instance.returns(nexmo);496 request.linkSip('123', 'abc', {});497 expect(nexmo.numberInsight.get).to.have.been.calledWithMatch({level:'basic'});498 }));499 });500 describe('.unlinkSip', () => {501 it('should call nexmo.numberInsight.get', test(function() {502 nexmo = {};503 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);504 client.instance.returns(nexmo);505 request.unlinkSip('123');506 expect(nexmo.numberInsight.get).to.have.been.calledWithMatch({level:'basic'});507 }));508 });509 });510 describe('.insightBasic', () => {511 it('should call nexmo.numberInsight.get', test(function() {512 nexmo = {};513 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);514 client.instance.returns(nexmo);515 request.insightBasic('4555555', { confirm: true });516 expect(nexmo.numberInsight.get).to.have.been.calledWithMatch({level:'basic'});517 }));518 });519 describe('.insightStandard', () => {520 it('should call nexmo.numberInsight.get', test(function() {521 nexmo = {};522 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);523 client.instance.returns(nexmo);524 request.insightStandard('4555555', { confirm: true });525 expect(nexmo.numberInsight.get).to.have.been.calledWithMatch({level:'standard'});526 }));527 });528 describe('.sendSms', () => {529 it('should call nexmo.message.sendSms', test(function() {530 nexmo = {};531 nexmo.message = sinon.createStubInstance(Message);532 client.instance.returns(nexmo);533 request.sendSms('to', ['Hello', 'World'], { 'from' : 'from', 'confirm' : true });534 expect(nexmo.message.sendSms).to.have.been.calledWith('from', 'to', 'Hello World');535 }));536 });537 describe('.generateJwt', () => {538 it('should call Nexmo.generateJwt', test(function() {539 var Nexmo = {540 generateJwt: sinon.spy()541 };542 client.definition.returns(Nexmo);543 request.generateJwt('path/to/private.key', [], {});544 expect(Nexmo.generateJwt).to.have.been.calledWith('path/to/private.key' );545 }));546 it('should deal with Nexmo.generateJwt with null claims', test(function() {547 var Nexmo = {548 generateJwt: sinon.spy()549 };550 client.definition.returns(Nexmo);551 request.generateJwt('path/to/private.key', [], {app_id: 'application_id'});552 expect(Nexmo.generateJwt).to.have.been.calledWith('path/to/private.key', {application_id: 'application_id'});553 }));554 it('should call Nexmo.generateJwt with additional claims', test(function() {555 var Nexmo = {556 generateJwt: sinon.spy()557 };558 client.definition.returns(Nexmo);559 request.generateJwt('path/to/private.key', ['subject=leggetter', 'jti=1475861732'], {app_id: 'application_id'});560 expect(Nexmo.generateJwt).to.have.been.calledWith('path/to/private.key', {application_id: 'application_id', subject: 'leggetter', jti: '1475861732'});561 }));562 it('should call pass generated token to response.generateJwt', test(function() {563 var Nexmo = {564 generateJwt: () => {565 return 'a token!';566 }567 };568 client.definition.returns(Nexmo);569 request.generateJwt('path/to/private.key', ['subject=leggetter', 'jti=1475861732'], {app_id: 'application_id'});570 expect(response.generateJwt).to.have.been.calledWith(null, 'a token!');571 }));572 it('should call response with an exception when singular values are provided for claims', test(function() {573 var Nexmo = {574 generateJwt: sinon.spy()575 };576 client.definition.returns(Nexmo);577 request.generateJwt('path/to/private.key', 'application_id', ['subject']);578 expect(response.generateJwt).to.have.been.calledWith(sinon.match.instanceOf(Error), null);579 }));580 it('should call response with an exception when more than one = is supplied', test(function() {581 var Nexmo = {582 generateJwt: sinon.spy()583 };584 client.definition.returns(Nexmo);585 request.generateJwt('path/to/private.key', 'application_id', ['subject=fish=monkey']);586 expect(response.generateJwt).to.have.been.calledWith(sinon.match.instanceOf(Error), null);587 }));588 });589 describe('.getCountryCode', () => {590 it('should return the country code if provided', test(function() {591 const callback = sinon.spy();592 request.getCountryCode('44555666777', { country_code: 'GB' }, callback);593 expect(callback).to.have.been.calledWith('GB');594 }));595 it('should call number insight if no country code was provided', test(function() {596 nexmo = {};597 const callback = sinon.spy();598 nexmo.numberInsight = sinon.createStubInstance(NumberInsight);599 client.instance.returns(nexmo);600 request.getCountryCode('44555666777', {}, callback);601 expect(nexmo.numberInsight.get).to.have.been.calledWith({ level: 'basic', number: '44555666777' });602 }));603 });604 });...

Full Screen

Full Screen

EventManagerTest.js

Source:EventManagerTest.js Github

copy

Full Screen

...12let ValidationResult = require('../lib/ValidationResult');13describe('EventManager', () => {14 describe('construct instance', () => {15 it('should set the adapter property', () => {16 let adapter = sinon.createStubInstance(PubSubAdapterInterface);17 let translator = sinon.createStubInstance(MessageTranslatorInterface);18 let manager = new EventManager(adapter, translator);19 expect(manager.adapter).to.equal(adapter);20 });21 it('should set the translator property', () => {22 let adapter = sinon.createStubInstance(PubSubAdapterInterface);23 let translator = sinon.createStubInstance(MessageTranslatorInterface);24 let manager = new EventManager(adapter, translator);25 expect(manager.translator).to.equal(translator);26 });27 it('should set the validator property', () => {28 let adapter = sinon.createStubInstance(PubSubAdapterInterface);29 let translator = sinon.createStubInstance(MessageTranslatorInterface);30 let validator = sinon.createStubInstance(EventValidatorInterface);31 let manager = new EventManager(adapter, translator, validator);32 expect(manager.validator).to.equal(validator);33 });34 it('should set the validator property to a default value of null if not given', () => {35 let adapter = sinon.createStubInstance(PubSubAdapterInterface);36 let translator = sinon.createStubInstance(MessageTranslatorInterface);37 let manager = new EventManager(adapter, translator);38 expect(manager.validator).to.be.null;39 });40 it('should set the attributeInjectors property', () => {41 let adapter = sinon.createStubInstance(PubSubAdapterInterface);42 let translator = sinon.createStubInstance(MessageTranslatorInterface);43 let attributeInjectors = [44 () => ({key: 'service', value: 'search'}),45 ];46 let manager = new EventManager(47 adapter,48 translator,49 null,50 attributeInjectors51 );52 expect(manager.attributeInjectors).to.equal(attributeInjectors);53 });54 it('should set the attributeInjectors property to a default value of an empty array if not given', () => {55 let adapter = sinon.createStubInstance(PubSubAdapterInterface);56 let translator = sinon.createStubInstance(MessageTranslatorInterface);57 let manager = new EventManager(adapter, translator);58 expect(manager.attributeInjectors).to.be.empty;59 });60 it('should set the translateFailHandler property', () => {61 let adapter = sinon.createStubInstance(PubSubAdapterInterface);62 let translator = sinon.createStubInstance(MessageTranslatorInterface);63 let validator = sinon.createStubInstance(EventValidatorInterface);64 let translateFailHandler = sinon.spy();65 let manager = new EventManager(adapter, translator, validator, [], translateFailHandler);66 expect(manager.translateFailHandler).to.equal(translateFailHandler);67 });68 it('should set the translateFailHandler property to a default value of null if not given', () => {69 let adapter = sinon.createStubInstance(PubSubAdapterInterface);70 let translator = sinon.createStubInstance(MessageTranslatorInterface);71 let manager = new EventManager(adapter, translator);72 expect(manager.translateFailHandler).to.be.null;73 });74 it('should set the listenExprFailHandler property', () => {75 let adapter = sinon.createStubInstance(PubSubAdapterInterface);76 let translator = sinon.createStubInstance(MessageTranslatorInterface);77 let validator = sinon.createStubInstance(EventValidatorInterface);78 let listenExprFailHandler = sinon.spy();79 let manager = new EventManager(adapter, translator, validator, [], null, listenExprFailHandler);80 expect(manager.listenExprFailHandler).to.equal(listenExprFailHandler);81 });82 it('should set the listenExprFailHandler property to a default value of null if not given', () => {83 let adapter = sinon.createStubInstance(PubSubAdapterInterface);84 let translator = sinon.createStubInstance(MessageTranslatorInterface);85 let manager = new EventManager(adapter, translator);86 expect(manager.listenExprFailHandler).to.be.null;87 });88 it('should set the validationFailHandler property', () => {89 let adapter = sinon.createStubInstance(PubSubAdapterInterface);90 let translator = sinon.createStubInstance(MessageTranslatorInterface);91 let validator = sinon.createStubInstance(EventValidatorInterface);92 let validationFailHandler = sinon.spy();93 let manager = new EventManager(adapter, translator, validator, [], null, null, validationFailHandler);94 expect(manager.validationFailHandler).to.equal(validationFailHandler);95 });96 it('should set the validationFailHandler property to a default value of null if not given', () => {97 let adapter = sinon.createStubInstance(PubSubAdapterInterface);98 let translator = sinon.createStubInstance(MessageTranslatorInterface);99 let manager = new EventManager(adapter, translator);100 expect(manager.validationFailHandler).to.be.null;101 });102 });103 describe('addAttributeInjector', () => {104 it('should append the attributeInjector to the attributeInjectors array', () => {105 let adapter = sinon.createStubInstance(PubSubAdapterInterface);106 let translator = sinon.createStubInstance(MessageTranslatorInterface);107 let manager = new EventManager(adapter, translator);108 expect(manager.attributeInjectors).to.be.empty;109 let attributeInjector = () => ({key: 'service', value: 'search'});110 manager.addAttributeInjector(attributeInjector);111 expect(manager.attributeInjectors).to.have.lengthOf(1);112 expect(manager.attributeInjectors[0]).to.equal(attributeInjector);113 });114 });115 describe('listen', () => {116 it('should subscribe to the channel on the adapter', () => {117 let adapter = sinon.createStubInstance(PubSubAdapterInterface);118 adapter.subscribe = sinon.stub();119 let translator = sinon.createStubInstance(MessageTranslatorInterface);120 let manager = new EventManager(adapter, translator);121 let handler = sinon.spy();122 manager.listen('my_channel', '*', handler);123 sinon.assert.calledOnce(adapter.subscribe);124 sinon.assert.calledWith(adapter.subscribe, 'my_channel');125 });126 it('when a message is received, the message should be translated to an event', () => {127 let adapter = sinon.createStubInstance(PubSubAdapterInterface);128 adapter.subscribe = sinon.stub();129 let event = sinon.createStubInstance(EventInterface);130 let translator = sinon.createStubInstance(MessageTranslatorInterface);131 translator.translate = sinon.stub()132 .returns(event);133 let manager = new EventManager(adapter, translator);134 let handler = sinon.spy();135 manager.listen('my_channel', '*', handler);136 adapter.subscribe.yield({'event': 'user.created'});137 sinon.assert.calledOnce(translator.translate);138 sinon.assert.calledWith(translator.translate, {'event': 'user.created'});139 });140 it('when a message is received, the event should be matched against the listen expression', () => {141 let adapter = sinon.createStubInstance(PubSubAdapterInterface);142 adapter.subscribe = sinon.stub();143 let event = sinon.createStubInstance(EventInterface);144 event.matches = sinon.stub()145 .returns(true);146 let translator = sinon.createStubInstance(MessageTranslatorInterface);147 translator.translate = sinon.stub()148 .returns(event);149 let manager = new EventManager(adapter, translator);150 let handler = sinon.spy();151 manager.listen('my_channel', '*', handler);152 adapter.subscribe.yield({'event': 'user.created'});153 sinon.assert.calledOnce(event.matches);154 sinon.assert.calledWith(event.matches, '*');155 });156 it('when a message is received & the translator fails, the handler should not be called', () => {157 let adapter = sinon.createStubInstance(PubSubAdapterInterface);158 adapter.subscribe = sinon.stub();159 let translator = sinon.createStubInstance(MessageTranslatorInterface);160 translator.translate = sinon.stub()161 .returns(null);162 let manager = new EventManager(adapter, translator);163 let handler = sinon.spy();164 manager.listen('my_channel', '*', handler);165 adapter.subscribe.yield({'event': 'user.created'});166 sinon.assert.notCalled(handler);167 });168 it('when a message is received & the translator fails, if a translateFailCallback is set, the callback should be triggered', () => {169 let adapter = sinon.createStubInstance(PubSubAdapterInterface);170 adapter.subscribe = sinon.stub();171 let translator = sinon.createStubInstance(MessageTranslatorInterface);172 translator.translate = sinon.stub()173 .returns(null);174 let translateFailHandler = sinon.spy();175 let manager = new EventManager(adapter, translator);176 manager.translateFailHandler = translateFailHandler;177 let handler = sinon.spy();178 manager.listen('my_channel', '*', handler);179 adapter.subscribe.yield('message payload');180 sinon.assert.calledOnce(translateFailHandler);181 sinon.assert.calledWith(translateFailHandler, 'message payload');182 });183 it('when a message is received & the listen expression does not match, the event should not be passed to the handler', () => {184 let adapter = sinon.createStubInstance(PubSubAdapterInterface);185 adapter.subscribe = sinon.stub();186 let event = sinon.createStubInstance(EventInterface);187 event.matches = sinon.stub()188 .returns(false);189 let translator = sinon.createStubInstance(MessageTranslatorInterface);190 translator.translate = sinon.stub()191 .returns(event);192 let manager = new EventManager(adapter, translator);193 let handler = sinon.spy();194 manager.listen('my_channel', 'order.created', handler);195 adapter.subscribe.yield({'event': 'user.created'});196 sinon.assert.notCalled(handler);197 });198 it('when a message is received & the listen expression does not match, if a listenExprFailHandler is set, the callback should be triggered', () => {199 let adapter = sinon.createStubInstance(PubSubAdapterInterface);200 adapter.subscribe = sinon.stub();201 let event = sinon.createStubInstance(EventInterface);202 event.matches = sinon.stub()203 .returns(false);204 let translator = sinon.createStubInstance(MessageTranslatorInterface);205 translator.translate = sinon.stub()206 .returns(event);207 let listenExprFailHandler = sinon.spy();208 let manager = new EventManager(adapter, translator);209 manager.listenExprFailHandler = listenExprFailHandler;210 let handler = sinon.spy();211 manager.listen('my_channel', 'order.created', handler);212 adapter.subscribe.yield({'event': 'user.created'});213 sinon.assert.notCalled(handler);214 sinon.assert.calledOnce(listenExprFailHandler);215 sinon.assert.calledWith(listenExprFailHandler, event, 'order.created');216 });217 it('when a message is received & matches the listen expression, the event should be passed to the handler', () => {218 let adapter = sinon.createStubInstance(PubSubAdapterInterface);219 adapter.subscribe = sinon.stub();220 let event = sinon.createStubInstance(EventInterface);221 event.matches = sinon.stub()222 .returns(true);223 let translator = sinon.createStubInstance(MessageTranslatorInterface);224 translator.translate = sinon.stub()225 .returns(event);226 let manager = new EventManager(adapter, translator);227 let handler = sinon.spy();228 manager.listen('my_channel', '*', handler);229 adapter.subscribe.yield({'event': 'user.created'});230 sinon.assert.calledOnce(handler);231 sinon.assert.calledWith(handler, event);232 });233 });234 describe('dispatch', () => {235 it('should convert the event to a message and publish to the channel', () => {236 let adapter = sinon.createStubInstance(PubSubAdapterInterface);237 adapter.publish = sinon.stub()238 .returns(Promise.resolve('result'));239 let translator = sinon.createStubInstance(MessageTranslatorInterface);240 let manager = new EventManager(adapter, translator);241 let event = sinon.createStubInstance(EventInterface);242 event.toMessage = sinon.stub()243 .returns({'event': 'user.created'});244 return manager.dispatch('my_channel', event).then((result) => {245 sinon.assert.calledOnce(event.toMessage);246 sinon.assert.calledOnce(adapter.publish);247 sinon.assert.calledWith(adapter.publish, 'my_channel', {'event': 'user.created'});248 expect(result).to.equal('result');249 });250 });251 it('should automagically inject values from attribute injectors into the message payload', () => {252 let adapter = sinon.createStubInstance(PubSubAdapterInterface);253 adapter.publish = sinon.stub()254 .returns(Promise.resolve('result'));255 let translator = sinon.createStubInstance(MessageTranslatorInterface);256 let manager = new EventManager(adapter, translator);257 manager.addAttributeInjector(() => ({key: 'service', value: 'search'}));258 manager.addAttributeInjector(() => ({key: 'hello', value: 'world'}));259 let event = new SimpleEvent('user.created');260 return manager.dispatch('my_channel', event).then((result) => {261 sinon.assert.calledOnce(adapter.publish);262 sinon.assert.calledWith(263 adapter.publish,264 'my_channel',265 {266 'event': 'user.created',267 'service': 'search',268 'hello': 'world',269 }270 );271 expect(result).to.equal('result');272 });273 });274 it('should convert the event to a message and publish to the channel, when a validator is set and validation passes', () => {275 let adapter = sinon.createStubInstance(PubSubAdapterInterface);276 adapter.publish = sinon.stub()277 .returns(Promise.resolve('result'));278 let translator = sinon.createStubInstance(MessageTranslatorInterface);279 let event = sinon.createStubInstance(EventInterface);280 event.toMessage = sinon.stub()281 .returns({'event': 'user.created'});282 let validator = sinon.createStubInstance(EventValidatorInterface);283 validator.validate = sinon.stub()284 .returns(Promise.resolve(new ValidationResult(validator, event, true)));285 let manager = new EventManager(adapter, translator, validator);286 return manager.dispatch('my_channel', event).then((result) => {287 sinon.assert.calledOnce(event.toMessage);288 sinon.assert.calledOnce(validator.validate);289 sinon.assert.calledWith(validator.validate, event);290 sinon.assert.calledOnce(adapter.publish);291 sinon.assert.calledWith(adapter.publish, 'my_channel', {'event': 'user.created'});292 expect(result).to.equal('result');293 });294 });295 it('should reject the promise when a validator is set and validation fails', () => {296 let adapter = sinon.createStubInstance(PubSubAdapterInterface);297 let translator = sinon.createStubInstance(MessageTranslatorInterface);298 let event = sinon.createStubInstance(EventInterface);299 let validator = sinon.createStubInstance(EventValidatorInterface);300 let validationResult = new ValidationResult(validator, event, false, ['should have required property \'user\'']);301 validator.validate = sinon.stub()302 .returns(Promise.resolve(validationResult));303 let manager = new EventManager(adapter, translator, validator);304 return manager.dispatch('my_channel', event).catch((reason) => {305 sinon.assert.calledOnce(validator.validate);306 sinon.assert.calledWith(validator.validate, event);307 expect(reason).to.equal(validationResult);308 });309 });310 it('should call the validationFailHandler when a validator is set and validation fails', () => {311 let adapter = sinon.createStubInstance(PubSubAdapterInterface);312 let translator = sinon.createStubInstance(MessageTranslatorInterface);313 let event = sinon.createStubInstance(EventInterface);314 let validator = sinon.createStubInstance(EventValidatorInterface);315 let validationResult = new ValidationResult(validator, event, false, ['should have required property \'user\'']);316 validator.validate = sinon.stub()317 .returns(Promise.resolve(validationResult));318 let validationFailHandler = sinon.spy();319 let manager = new EventManager(adapter, translator, validator);320 manager.validationFailHandler = validationFailHandler;321 return manager.dispatch('my_channel', event).catch((reason) => {322 sinon.assert.calledOnce(validator.validate);323 sinon.assert.calledWith(validator.validate, event);324 sinon.assert.calledOnce(validationFailHandler);325 sinon.assert.calledWith(validationFailHandler, validationResult);326 expect(reason).to.equal(validationResult);327 });328 });329 it('should automagically inject values from attribute injectors into the message payload but not override conflicting attributes', () => {330 let adapter = sinon.createStubInstance(PubSubAdapterInterface);331 adapter.publish = sinon.stub()332 .returns(Promise.resolve('result'));333 let translator = sinon.createStubInstance(MessageTranslatorInterface);334 let manager = new EventManager(adapter, translator);335 manager.addAttributeInjector(() => ({key: 'service', value: 'search'}));336 manager.addAttributeInjector(() => ({key: 'hello', value: 'world'}));337 let event = new SimpleEvent('user.created', {'service': 'www'});338 return manager.dispatch('my_channel', event).then((result) => {339 sinon.assert.calledOnce(adapter.publish);340 sinon.assert.calledWith(341 adapter.publish,342 'my_channel',343 {344 'event': 'user.created',345 'service': 'www',346 'hello': 'world',347 }348 );349 expect(result).to.equal('result');350 });351 });352 });353 describe('dispatchBatch', () => {354 it('should convert the events to an array of message and publish to the channel', () => {355 let adapter = sinon.createStubInstance(PubSubAdapterInterface);356 adapter.publishBatch = sinon.stub()357 .returns(Promise.resolve(['result1', 'result2']));358 let translator = sinon.createStubInstance(MessageTranslatorInterface);359 let manager = new EventManager(adapter, translator);360 let event1 = sinon.createStubInstance(EventInterface);361 event1.toMessage = sinon.stub()362 .returns({'event': 'user.created'});363 let event2 = sinon.createStubInstance(EventInterface);364 event2.toMessage = sinon.stub()365 .returns({'event': 'order.created'});366 let events = [event1, event2];367 return manager.dispatchBatch('my_channel', events).then((results) => {368 sinon.assert.calledOnce(event1.toMessage);369 sinon.assert.calledOnce(event2.toMessage);370 sinon.assert.calledOnce(adapter.publishBatch);371 sinon.assert.calledWith(372 adapter.publishBatch,373 'my_channel',374 [375 {'event': 'user.created'},376 {'event': 'order.created'},377 ]378 );379 expect(results).to.deep.equal(['result1', 'result2']);380 });381 });382 it('should automagically inject values from attribute injectors into the message payload', () => {383 let adapter = sinon.createStubInstance(PubSubAdapterInterface);384 adapter.publishBatch = sinon.stub()385 .returns(Promise.resolve(['result1', 'result2']));386 let translator = sinon.createStubInstance(MessageTranslatorInterface);387 let manager = new EventManager(adapter, translator);388 manager.addAttributeInjector(() => ({key: 'service', value: 'search'}));389 manager.addAttributeInjector(() => ({key: 'hello', value: 'world'}));390 let event1 = new SimpleEvent('user.created');391 let event2 = new SimpleEvent('order.created');392 let events = [event1, event2];393 return manager.dispatchBatch('my_channel', events).then((results) => {394 sinon.assert.calledOnce(adapter.publishBatch);395 sinon.assert.calledWith(396 adapter.publishBatch,397 'my_channel',398 [399 {400 'event': 'user.created',401 'service': 'search',402 'hello': 'world',403 },404 {405 'event': 'order.created',406 'service': 'search',407 'hello': 'world',408 },409 ]410 );411 expect(results).to.deep.equal(['result1', 'result2']);412 });413 });414 it('should convert the events to an array of message and publish to the channel, when a validator is set and validation passes', () => {415 let adapter = sinon.createStubInstance(PubSubAdapterInterface);416 adapter.publishBatch = sinon.stub()417 .returns(Promise.resolve(['result1', 'result2']));418 let translator = sinon.createStubInstance(MessageTranslatorInterface);419 let event1 = sinon.createStubInstance(EventInterface);420 event1.toMessage = sinon.stub()421 .returns({'event': 'user.created'});422 let event2 = sinon.createStubInstance(EventInterface);423 event2.toMessage = sinon.stub()424 .returns({'event': 'order.created'});425 let events = [event1, event2];426 let validator = sinon.createStubInstance(EventValidatorInterface);427 validator.validate = sinon.stub();428 validator.validate.onCall(0)429 .returns(Promise.resolve(new ValidationResult(validator, event1, true)));430 validator.validate.onCall(1)431 .returns(Promise.resolve(new ValidationResult(validator, event2, true)));432 let manager = new EventManager(adapter, translator, validator);433 return manager.dispatchBatch('my_channel', events).then((results) => {434 sinon.assert.calledOnce(event1.toMessage);435 sinon.assert.calledOnce(event2.toMessage);436 sinon.assert.calledTwice(validator.validate);437 sinon.assert.calledWith(validator.validate, event1);438 sinon.assert.calledWith(validator.validate, event2);439 sinon.assert.calledOnce(adapter.publishBatch);440 sinon.assert.calledWith(441 adapter.publishBatch,442 'my_channel',443 [444 {'event': 'user.created'},445 {'event': 'order.created'},446 ]447 );448 expect(results).to.deep.equal(['result1', 'result2']);449 });450 });451 it('should reject the promise with the first failed ValidationResult when a validator is set and validation fails', () => {452 let adapter = sinon.createStubInstance(PubSubAdapterInterface);453 let translator = sinon.createStubInstance(MessageTranslatorInterface);454 let event1 = sinon.createStubInstance(EventInterface);455 let event2 = sinon.createStubInstance(EventInterface);456 let events = [event1, event2];457 let validator = sinon.createStubInstance(EventValidatorInterface);458 let validationResult1 = new ValidationResult(validator, event1, false, ['should have required property \'user\'']);459 let validationResult2 = new ValidationResult(validator, event2, true);460 validator.validate = sinon.stub();461 validator.validate.onCall(0)462 .returns(Promise.resolve(validationResult1));463 validator.validate.onCall(1)464 .returns(Promise.resolve(validationResult2));465 let manager = new EventManager(adapter, translator, validator);466 return manager.dispatchBatch('my_channel', events).catch((reason) => {467 sinon.assert.calledTwice(validator.validate);468 sinon.assert.calledWith(validator.validate, event1);469 sinon.assert.calledWith(validator.validate, event2);470 expect(reason).to.equal(validationResult1);471 });472 });473 it('should call the validationFailHandler when a validator is set and validation fails', () => {474 let adapter = sinon.createStubInstance(PubSubAdapterInterface);475 let translator = sinon.createStubInstance(MessageTranslatorInterface);476 let event1 = sinon.createStubInstance(EventInterface);477 let event2 = sinon.createStubInstance(EventInterface);478 let events = [event1, event2];479 let validator = sinon.createStubInstance(EventValidatorInterface);480 let validationResult1 = new ValidationResult(validator, event1, false, ['should have required property \'user\'']);481 let validationResult2 = new ValidationResult(validator, event2, true);482 validator.validate = sinon.stub();483 validator.validate.onCall(0)484 .returns(Promise.resolve(validationResult1));485 validator.validate.onCall(1)486 .returns(Promise.resolve(validationResult2));487 let validationFailHandler = sinon.spy();488 let manager = new EventManager(adapter, translator, validator);489 manager.validationFailHandler = validationFailHandler;490 return manager.dispatchBatch('my_channel', events).catch((reason) => {491 sinon.assert.calledTwice(validator.validate);492 sinon.assert.calledWith(validator.validate, event1);493 sinon.assert.calledWith(validator.validate, event2);...

Full Screen

Full Screen

GoogleCloudPubSubAdapterTest.js

Source:GoogleCloudPubSubAdapterTest.js Github

copy

Full Screen

...10chai.should();11describe('GoogleCloudPubSubAdapter', () => {12 describe('construct instance', () => {13 it('should set the client property', () => {14 let client = sinon.createStubInstance(pubsub);15 let adapter = new GoogleCloudPubSubAdapter(client);16 expect(adapter.client).to.equal(client);17 });18 it('should set the clientIdentifier property', () => {19 let client = sinon.createStubInstance(pubsub);20 let adapter = new GoogleCloudPubSubAdapter(client, 'search-service');21 expect(adapter.clientIdentifier).to.equal('search-service');22 });23 it('should set the clientIdentifier property to a default value of null if not given', () => {24 let client = sinon.createStubInstance(pubsub);25 let adapter = new GoogleCloudPubSubAdapter(client);26 expect(adapter.clientIdentifier).to.be.null;27 });28 it('should set the autoCreateTopics property', () => {29 let client = sinon.createStubInstance(pubsub);30 let adapter = new GoogleCloudPubSubAdapter(client, 'search-service', false);31 expect(adapter.autoCreateTopics).to.be.false;32 });33 it('should set the autoCreateTopics property to a default value of true if not given', () => {34 let client = sinon.createStubInstance(pubsub);35 let adapter = new GoogleCloudPubSubAdapter(client);36 expect(adapter.autoCreateTopics).to.be.true;37 });38 it('should set the autoCreateSubscriptions property', () => {39 let client = sinon.createStubInstance(pubsub);40 let adapter = new GoogleCloudPubSubAdapter(client, 'search-service', false, false);41 expect(adapter.autoCreateSubscriptions).to.be.false;42 });43 it('should set the autoCreateSubscriptions property to a default value of true if not given', () => {44 let client = sinon.createStubInstance(pubsub);45 let adapter = new GoogleCloudPubSubAdapter(client);46 expect(adapter.autoCreateSubscriptions).to.be.true;47 });48 });49 describe('getTopicForChannel', () => {50 it('should return a promise', () => {51 let topic = sinon.createStubInstance(pubsub.Topic);52 topic.get = sinon.stub()53 .returns(new Promise((resolve, reject) => {}));54 let client = sinon.createStubInstance(pubsub);55 client.topic = sinon.stub()56 .returns(topic);57 let adapter = new GoogleCloudPubSubAdapter(client);58 let promise = adapter.getTopicForChannel('my_channel');59 expect(promise).to.be.a('promise');60 });61 it('should pass the channel name to the client.topic call', () => {62 let topic = sinon.createStubInstance(pubsub.Topic);63 topic.get = sinon.stub()64 .returns(new Promise((resolve, reject) => {}));65 let client = sinon.createStubInstance(pubsub);66 client.topic = sinon.stub()67 .returns(topic);68 let adapter = new GoogleCloudPubSubAdapter(client);69 adapter.getTopicForChannel('my_channel');70 sinon.assert.calledOnce(client.topic);71 sinon.assert.calledWith(client.topic, 'my_channel');72 });73 it('should pass the autoCreateTopics property to the topic.get call', () => {74 let topic = sinon.createStubInstance(pubsub.Topic);75 topic.get = sinon.stub()76 .returns(new Promise((resolve, reject) => {}));77 let client = sinon.createStubInstance(pubsub);78 client.topic = sinon.stub()79 .returns(topic);80 let adapter = new GoogleCloudPubSubAdapter(client, null, false);81 adapter.getTopicForChannel('my_channel');82 sinon.assert.calledOnce(topic.get);83 sinon.assert.calledWith(topic.get, {autoCreate: false});84 });85 it('should resolve a promise to a pubsub/topic on success', () => {86 let resolvedTopic = sinon.createStubInstance(pubsub.Topic);87 let topic = sinon.createStubInstance(pubsub.Topic);88 topic.get = sinon.stub()89 .returns(new Promise((resolve, reject) => resolve([resolvedTopic])));90 let client = sinon.createStubInstance(pubsub);91 client.topic = sinon.stub()92 .returns(topic);93 let adapter = new GoogleCloudPubSubAdapter(client);94 return adapter.getTopicForChannel('my_channel')95 .should.eventually.equal(resolvedTopic);96 });97 });98 describe('getSubscriptionForChannel', () => {99 it('should return a promise', () => {100 let subscription = sinon.createStubInstance(pubsub.Subscription);101 subscription.get = sinon.stub()102 .returns(new Promise((resolve, reject) => {}));103 let resolvedTopic = sinon.createStubInstance(pubsub.Topic);104 resolvedTopic.subscription = sinon.stub()105 .returns(subscription);106 let topic = sinon.createStubInstance(pubsub.Topic);107 topic.get = sinon.stub()108 .returns(new Promise((resolve, reject) => resolve([resolvedTopic]))109 );110 topic.subscription = sinon.stub()111 .returns(subscription);112 let client = sinon.createStubInstance(pubsub);113 client.topic = sinon.stub()114 .returns(topic);115 let adapter = new GoogleCloudPubSubAdapter(client);116 let promise = adapter.getSubscriptionForChannel('my_channel');117 expect(promise).to.be.a('promise');118 });119 it('should pass the clientIdentifier to the topic.subscription call', () => {120 let subscription = sinon.createStubInstance(pubsub.Subscription);121 subscription.get = sinon.stub()122 .returns(new Promise((resolve, reject) => resolve([null])));123 let resolvedTopic = sinon.createStubInstance(pubsub.Topic);124 resolvedTopic.subscription = sinon.stub()125 .returns(subscription);126 let topic = sinon.createStubInstance(pubsub.Topic);127 topic.get = sinon.stub()128 .returns(new Promise((resolve, reject) => resolve([resolvedTopic])));129 topic.subscription = sinon.stub()130 .returns(subscription);131 let client = sinon.createStubInstance(pubsub);132 client.topic = sinon.stub()133 .returns(topic);134 let adapter = new GoogleCloudPubSubAdapter(client, 'search');135 return adapter.getSubscriptionForChannel('my_channel').then(() => {136 sinon.assert.calledOnce(resolvedTopic.subscription);137 sinon.assert.calledWith(resolvedTopic.subscription, 'search.my_channel');138 });139 });140 it('should pass a default clientIdentifier of "default" to the topic.subscription call when a clientIdentifier is not set', () => {141 let subscription = sinon.createStubInstance(pubsub.Subscription);142 subscription.get = sinon.stub()143 .returns(new Promise((resolve, reject) => resolve([null])));144 let resolvedTopic = sinon.createStubInstance(pubsub.Topic);145 resolvedTopic.subscription = sinon.stub()146 .returns(subscription);147 let topic = sinon.createStubInstance(pubsub.Topic);148 topic.get = sinon.stub()149 .returns(new Promise((resolve, reject) => resolve([resolvedTopic])));150 topic.subscription = sinon.stub()151 .returns(subscription);152 let client = sinon.createStubInstance(pubsub);153 client.topic = sinon.stub()154 .returns(topic);155 let adapter = new GoogleCloudPubSubAdapter(client);156 return adapter.getSubscriptionForChannel('my_channel').then(() => {157 sinon.assert.calledOnce(resolvedTopic.subscription);158 sinon.assert.calledWith(resolvedTopic.subscription, 'default.my_channel');159 });160 });161 it('should resolve a promise to a pubsub/subscription on success', () => {162 let resolvedSubscription = sinon.createStubInstance(pubsub.Subscription);163 let subscription = sinon.createStubInstance(pubsub.Subscription);164 subscription.get = sinon.stub()165 .returns(new Promise((resolve, reject) => {166 resolve([resolvedSubscription]);167 }));168 let resolvedTopic = sinon.createStubInstance(pubsub.Topic);169 resolvedTopic.subscription = sinon.stub()170 .returns(subscription);171 let topic = sinon.createStubInstance(pubsub.Topic);172 topic.get = sinon.stub()173 .returns(new Promise((resolve, reject) => resolve([resolvedTopic])));174 topic.subscription = sinon.stub()175 .returns(subscription);176 let client = sinon.createStubInstance(pubsub);177 client.topic = sinon.stub()178 .returns(topic);179 let adapter = new GoogleCloudPubSubAdapter(client);180 return adapter.getSubscriptionForChannel('my_channel')181 .should.eventually.equal(resolvedSubscription);182 });183 });184 describe('subscribe', () => {185 it('should subscribe to messages on the subscription', () => {186 let resolvedSubscription = sinon.createStubInstance(pubsub.Subscription);187 resolvedSubscription.on = sinon.stub();188 let subscription = sinon.createStubInstance(pubsub.Subscription);189 subscription.get = sinon.stub()190 .returns(new Promise((resolve, reject) => {191 resolve([resolvedSubscription]);192 }));193 let resolvedTopic = sinon.createStubInstance(pubsub.Topic);194 resolvedTopic.subscription = sinon.stub()195 .returns(subscription);196 let topic = sinon.createStubInstance(pubsub.Topic);197 topic.get = sinon.stub()198 .returns(new Promise((resolve, reject) => resolve([resolvedTopic])));199 topic.subscription = sinon.stub()200 .returns(subscription);201 let client = sinon.createStubInstance(pubsub);202 client.topic = sinon.stub()203 .returns(topic);204 let adapter = new GoogleCloudPubSubAdapter(client);205 let handler = sinon.spy();206 return adapter.subscribe('my_channel', handler).then(() => {207 sinon.assert.calledOnce(resolvedSubscription.on);208 sinon.assert.calledWith(resolvedSubscription.on, 'message');209 });210 });211 it('should pass the message to the handler when a message is received', () => {212 let resolvedSubscription = sinon.createStubInstance(pubsub.Subscription);213 resolvedSubscription.on = sinon.stub();214 let subscription = sinon.createStubInstance(pubsub.Subscription);215 subscription.get = sinon.stub()216 .returns(new Promise((resolve, reject) => {217 resolve([resolvedSubscription]);218 }));219 let resolvedTopic = sinon.createStubInstance(pubsub.Topic);220 resolvedTopic.subscription = sinon.stub()221 .returns(subscription);222 let topic = sinon.createStubInstance(pubsub.Topic);223 topic.get = sinon.stub()224 .returns(new Promise((resolve, reject) => resolve([resolvedTopic])));225 topic.subscription = sinon.stub()226 .returns(subscription);227 let client = sinon.createStubInstance(pubsub);228 client.topic = sinon.stub()229 .returns(topic);230 let adapter = new GoogleCloudPubSubAdapter(client);231 let handler = sinon.spy();232 return adapter.subscribe('my_channel', handler).then(() => {233 resolvedSubscription.on.yield({234 data: '"Hello World!"',235 ack: () => {},236 });237 sinon.assert.calledOnce(handler);238 sinon.assert.calledWith(handler, 'Hello World!');239 });240 });241 it('should pass an unserialized message to the handler when a message is received', () => {242 let resolvedSubscription = sinon.createStubInstance(pubsub.Subscription);243 resolvedSubscription.on = sinon.stub();244 let subscription = sinon.createStubInstance(pubsub.Subscription);245 subscription.get = sinon.stub()246 .returns(new Promise((resolve, reject) => {247 resolve([resolvedSubscription]);248 }));249 let resolvedTopic = sinon.createStubInstance(pubsub.Topic);250 resolvedTopic.subscription = sinon.stub()251 .returns(subscription);252 let topic = sinon.createStubInstance(pubsub.Topic);253 topic.get = sinon.stub()254 .returns(new Promise((resolve, reject) => resolve([resolvedTopic])));255 topic.subscription = sinon.stub()256 .returns(subscription);257 let client = sinon.createStubInstance(pubsub);258 client.topic = sinon.stub()259 .returns(topic);260 let adapter = new GoogleCloudPubSubAdapter(client);261 let handler = sinon.spy();262 return adapter.subscribe('my_channel', handler).then(() => {263 resolvedSubscription.on.yield({264 data: '"Hello World!"',265 ack: () => {},266 });267 resolvedSubscription.on.yield({268 data: '{"hello":"world"}',269 ack: () => {},270 });271 sinon.assert.calledTwice(handler);272 sinon.assert.calledWith(handler, 'Hello World!');273 sinon.assert.calledWith(handler, {hello: 'world'});274 });275 });276 it('should ack the message after the message is passed to the handler', () => {277 let resolvedSubscription = sinon.createStubInstance(pubsub.Subscription);278 resolvedSubscription.on = sinon.stub();279 let subscription = sinon.createStubInstance(pubsub.Subscription);280 subscription.get = sinon.stub()281 .returns(new Promise((resolve, reject) => {282 resolve([resolvedSubscription]);283 }));284 let resolvedTopic = sinon.createStubInstance(pubsub.Topic);285 resolvedTopic.subscription = sinon.stub()286 .returns(subscription);287 let topic = sinon.createStubInstance(pubsub.Topic);288 topic.get = sinon.stub()289 .returns(new Promise((resolve, reject) => resolve([resolvedTopic])));290 topic.subscription = sinon.stub()291 .returns(subscription);292 let client = sinon.createStubInstance(pubsub);293 client.topic = sinon.stub()294 .returns(topic);295 let adapter = new GoogleCloudPubSubAdapter(client);296 let handler = sinon.spy();297 return adapter.subscribe('my_channel', handler).then(() => {298 let message = {299 data: '"Hello World!"',300 ack: sinon.spy(),301 };302 resolvedSubscription.on.yield(message);303 sinon.assert.calledOnce(handler);304 sinon.assert.calledWith(handler, 'Hello World!');305 sinon.assert.calledOnce(message.ack);306 });307 });308 });309 describe('publish', () => {310 it('should publish the message to a topic', () => {311 let resolvedTopic = sinon.createStubInstance(pubsub.Topic);312 resolvedTopic.publish = sinon.stub();313 resolvedTopic.publish.onCall(0)314 .returns(Promise.resolve('result1'));315 resolvedTopic.publish.onCall(1)316 .returns(Promise.resolve('result2'));317 let topic = sinon.createStubInstance(pubsub.Topic);318 topic.get = sinon.stub()319 .returns(new Promise((resolve, reject) => resolve([resolvedTopic])));320 let client = sinon.createStubInstance(pubsub);321 client.topic = sinon.stub()322 .returns(topic);323 let adapter = new GoogleCloudPubSubAdapter(client);324 let buffer1 = sinon.stub();325 let buffer2 = sinon.stub();326 adapter.makeBuffer = sinon.stub();327 adapter.makeBuffer.withArgs('Hello World!')328 .returns(buffer1);329 adapter.makeBuffer.withArgs({first_name: 'Matthew'})330 .returns(buffer2);331 let promises = [];332 promises.push(adapter.publish('my_channel', 'Hello World!'));333 promises.push(adapter.publish('my_channel', {first_name: 'Matthew'}));334 return Promise.all(promises).then((results) => {335 sinon.assert.calledTwice(resolvedTopic.publish);336 sinon.assert.calledWith(resolvedTopic.publish, buffer1);337 sinon.assert.calledWith(resolvedTopic.publish, buffer2);338 expect(results[0]).to.equal('result1');339 expect(results[1]).to.equal('result2');340 });341 });342 });343 describe('publishBatch', () => {344 it('should publish multiple messages to a topic', () => {345 let resolvedTopic = sinon.createStubInstance(pubsub.Topic);346 resolvedTopic.publish = sinon.stub()347 .returns(Promise.resolve(['result1', 'result2']));348 let topic = sinon.createStubInstance(pubsub.Topic);349 topic.get = sinon.stub()350 .returns(new Promise((resolve, reject) => resolve([resolvedTopic])));351 let client = sinon.createStubInstance(pubsub);352 client.topic = sinon.stub()353 .returns(topic);354 let adapter = new GoogleCloudPubSubAdapter(client);355 let buffer1 = sinon.stub();356 let buffer2 = sinon.stub();357 adapter.makeBuffer = sinon.stub();358 adapter.makeBuffer.withArgs('Hello World!')359 .returns(buffer1);360 adapter.makeBuffer.withArgs({first_name: 'Matthew'})361 .returns(buffer2);362 let messages = [363 'Hello World!',364 {first_name: 'Matthew'},365 ];366 return adapter.publishBatch('my_channel', messages).then((results) => {367 sinon.assert.calledOnce(resolvedTopic.publish);368 let payloads = [369 buffer1,370 buffer2,371 ];372 sinon.assert.calledWith(resolvedTopic.publish, payloads);373 expect(results).to.deep.equal(['result1', 'result2']);374 });375 });376 });377 describe('makeBuffer', () => {378 it('should encode a message in a buffer', () => {379 let client = sinon.createStubInstance(pubsub);380 let adapter = new GoogleCloudPubSubAdapter(client);381 let buffer1 = adapter.makeBuffer('Hello World!');382 expect(buffer1).to.be.an.object;383 expect(buffer1.toString('utf8')).to.equal('"Hello World!"');384 let buffer2 = adapter.makeBuffer({first_name: 'Matthew'});385 expect(buffer2.toString('utf8')).to.equal('{"first_name":"Matthew"}');386 });387 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = require('sinon');2var assert = require('assert');3var Person = function(name, age) {4 this.name = name;5 this.age = age;6}7Person.prototype.greet = function() {8 return "Hello " + this.name;9}10Person.prototype.getAge = function() {11 return this.age;12}13describe('Person', function() {14 it('should greet the person', function() {15 var person = new Person('John', 30);16 var stub = sinon.createStubInstance(Person);17 stub.name = 'John';18 stub.age = 30;19 stub.greet.returns("Hello John");20 stub.getAge.returns(30);21 assert.equal(stub.greet(), "Hello John");22 assert.equal(stub.getAge(), 30);23 });24});

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = require('sinon');2var assert = require('assert');3var Person = function(name, age) {4 this.name = name;5 this.age = age;6}7Person.prototype.greet = function() {8 return "Hello " + this.name;9}10Person.prototype.getAge = function() {11 return this.age;12}13describe('Person', function() {14 it('should greet the person', function() {15 var person = new Person('John', 30);16 var stub = sinon.createStubInstance(Person);17 stub.name = 'John';18 stub.age = 30;19 stub.greet.returns("Hello John");20 stub.getAge.returns(30);21 assert.equal(stub.greet(), "Hello John");22 assert.equal(stub.getAge(), 30);23 });24});

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = require('sinon');2var expect = require('chai').expect;3var foo = require('../foo.js');4describe('foo', function() {5 it('should call the callback', function() {6 var callback = sinon.spy();7 foo(callback);8 expect(callback).to.have.been.called;9 });10});11var foo = function(callback) {12 callback();13};14module.exports = foo;

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = require('sinon');2var.expect = require('chai').expect;3var foo = {4 setBar: funcjisn(value) {js5var sinon = require('sinon'); this.bar = value;6 }asert = requre('assert');7var mogose = require('mogoose');8varUser ../models/uer');9var stubUser = snon.createStubInstance(User);10stubUser.save = fucti (cb) {11 cb(null, { name: John', age: 20 }12};13stubUser.sa}e(function (err, d;ta) {14 asset.equal(data.name,'John');15 .equal(data.age,20);16});17var sinon sinon');18var assert = require('assert');19var mongoose = require('mongoose');20var User = require('../models/user');21var stubUser = sinon.reateStubInstance(User);22stubUser.save = function (cb) {23 cb(null, { name: 'Jon', ge: 20 });24};25stubUser.save(functon (err, data) {26 assert.equal(data.name, 'John);27 assert.equal(data.age, 20);28};29var sinon = require('sinon');30var assert = require('');31var mongoose = require('mongoose');32var User = require('../models/user')33ar stubUser = sinon.createStubInstnce(User);34stubUse.save = function (cb) {35 b(null, { name: 'Jon', age: 20 });36};37stubUser.sve(functon (err, data) {38 assert.equal(data.name, 'John');39 assert.equal(data.age, 20);40});41var sinon 'sinon);42var assert = require('assert');43var mongoose = require('mongoose');44var User = require('../models/user');45var stubUser = sinon.reateStubInstance(User);46stubUser.save = function (cb) {47 cb(null, { name: 'Jon', ge: 20 });48};49stubUser.save(functon (err, data) {50 assert.equal(data.name, 'John);51 assert.equal(data.age, 20);52}53var sinon = require('sinon');54var assert = require('assert');55var mongoose = require('mongoose');56var User = require('../models/user');57var stubUser = sinon.createStubInstance(User);58stubUser.save = function (cb) {59 cb(null, { name: 'John', age: 20 });60};61stubUser.save(function (

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = r quire('sinon');2var assert = require('chai').assert;3var chai = require('chai');4var e=sinon.createStubInsance(foo);5stub.setBar(123);6stub.setBar(456, 'anotrparam');7expect(stub.setBar.calledTwice).t.be.true;8expect(stu.setBar.firstCall.args[0]).to.equal(123);9expect(stub.setBar.secondCall.args[0]).to.equal(456);10expect(stub.setBar.secondCall.args[1]).to.equal('another param');11expect(stub.bar).to.be.undefined;

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = require('sinon');2var expect = require('chai').expect;3var foo = {4 setBar: function(value) {5 this.bar = value;6 }7};8var stub = sinon.createStubInstance(foo);9stub.setBar(123);10stub.setBar(456, 'another param');11var =require('sinon');12var assert = require('chai').assert;13var chai = require('chai');14var expec = chai.expect;15describe('Sinn',funtion () {16 va obj = {};17 var stub;18 beforeEach(function () {19 stub = sinon.crStubInstance(obj);20 });21 it('should cretea ',functin () {22 expect(stu).to.be.an.instanceof(ob);23 });24 it('should hav a stubbed method', funtion () {25 stub.mehod();26 expect(stub.method.called).to.equal(true);27 });28});29exp sinon =erequire('ct(st');30var assert = require('chai').assert;31varuchai b.setuire('chai');32var expect = chai.expect;33describe('Sinon', fBnctaon () {34 var obj = {};35 var stub;36 befor.Eachcfunction () {37 stub = sinon.createStubInstance(obj);38 });39 it('should create a stub', function () {40 expect(stub).to.be.an.instanceof(obj);41 });42 it('should have a stubbed method', function () {43 stub.method();44 expect(stub.method.called).to.equal(true);45 });46});47var sinon = require('sinon');48var assert = require('chai').assert;49var chai = require('chai');50var expect = chai.expect;51describe('Sinon', function () {52 var obj = {};53 var stub;54 beforeEach(function () {55 stub = sinon.createStubInstance(obj);56 });57 it('should create a stub', function () {58 expect(stub).to.be.an.instanceof(obj);59 });60 it('should have a stubbed method', function () {61 stub.method();62 expect(stub.method.called).to.equal(true);63 });64});65var sinon = require('sinon');66var assert = require('chai').assert;67var chai = require('chai');68var expect = chai.expect;69describe('Sinon', function () {70 var obj = {};71 var stub;72 beforeEach(function () {73 stub = sinon.createStubInstance(obj);74 }););

Full Screen

Using AI Code Generation

copy

Full Screen

1var chai = require('chai');2var expect = chai.expect;3var sinon = require('sinon');4var User = require('../user'5var user = new User();6describe('User', function() {7 describe('save', function() {8 it('should save the user', function() {9 var db = sinon.createStubInstance(Database);10 db.save.returns(true);11 user.save(db);12 expect(db.save.calledOnce).to.be.true;13 });14 });15});16var User = function() {};17User.prototype.save = function(db) {18 return db.save(this);19};20module.exports = User;21var Database = function() {};22Database.prototype.save = function(user) {23 return true;24};25module.exports = Database;26 it('should create a stub', function () {27 expect(stub).to.be.an.instanceof(obj);28 });

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = require('sinon');2var chai = require('chai');3var expect = chai.expect;4var stub = sinon.createStubInstance(MyClass);5stub.myMethod.returns(42);6stub.myMethod(1, 2, 3);7expect(stub.myMethod.calledWith(1, 2, 3)).to.be.true;8expect(stub.myMethod.returned(42)).to.be.true;

Full Screen

Using AI Code Generation

copy

Full Screen

1var chai = require('chai');2var expect = chai.expect;3var sinon = require('sinon');4var User = require('../user');5var user = new User();6describe('User', function() {7 describe('save', function() {8 it('should save the user', function() {9 var db = sinon.createStubInstance(Database);10 db.save.returns(true);11 user.save(db);12 expect(db.save.calledOnce).to.be.true;13 });14 });15});16var User = function() {};17User.prototype.save = function(db) {18 return db.save(this);19};20module.exports = User;21var Database = function() {};22Database.prototype.save = function(user {23 return true;24};25var sinon = require('sinon');26var assert = require('chai').assert;27var chai = require('chai');28var expect = chai.expect;29describe('Sinon', function () {30 var obj = {};31 var stub;32 beforeEach(function () {33 stub = sinon.createStubInstance(obj);34 });35 it('should create a stub', function () {36 expect(stub).to.be.an.instanceof(obj);37 });38 it('should have a stubbed method', function () {39 stub.method();40 expect(stub.method.called).to.equal(true);41 });42});43var sinon = require('sinon');44var assert = require('chai').assert;45var chai = require('chai');46var expect = chai.expect;47describe('Sinon', function () {48 var obj = {};49 var stub;50 beforeEach(function () {51 stub = sinon.createStubInstance(obj);52 });53 it('should create a stub', function () {54 expect(stub).to.be.an.instanceof(obj);55 });56 it('should have a stubbed method', function () {57 stub.method();58 expect(stub.method.called).to.equal(true);59 });60});61var sinon = require('sinon');62var assert = require('chai').assert;63var chai = require('chai');64var expect = chai.expect;65describe('Sinon', function () {66 var obj = {};67 var stub;68 beforeEach(function () {69 stub = sinon.createStubInstance(obj);70 });71 it('should create a stub', function () {72 expect(stub).to.be.an.instanceof(obj);73 });74 it('should have a stubbed method', function () {75 stub.method();76 expect(stub.method.called).to.equal(true);77 });78});79var sinon = require('sinon');80var assert = require('chai').assert;81var chai = require('chai');82var expect = chai.expect;83describe('Sinon', function () {84 var obj = {};85 var stub;86 beforeEach(function () {87 stub = sinon.createStubInstance(obj);88 });89 it('should create a stub', function () {90 expect(stub).to.be.an.instanceof(obj);91 });

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = require("sinon");2var assert = require("chai").assert;3var stubObj = sinon.createStubInstance(Object);4stubObj.doSomething = sinon.stub();5stubObj.doSomething.withArgs(1).returns(1);6stubObj.doSomething.withArgs(2).returns(2);7assert(stubObj.doSomething.called);8assert(stubObj.doSomething.calledOnce);9assert(stubObj.doSomething.calledTwice);10assert(stubObj.doSomething.calledWith(1));11assert(stubObj.doSomething.calledWith(2));12assert.equal(stubObj.doSomething(1), 1);13assert.equal(stubObj.doSomething(2), 2);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

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