Best JavaScript code snippet using playwright-internal
spec.js
Source:spec.js
...87 $third = $steps.eq(2);88 // when89 $form.stepy();90 // then91 expect($first).not.toBeHidden();92 expect($second).toBeHidden();93 expect($third).toBeHidden();94 });95 it ('should focus the first field', function() {96 // given97 var $form = $('#stepy');98 // when99 $form.stepy();100 // then101 expect($form.children('fieldset').first().find(':input:enabled:visible:first')).toBeFocused();102 });103 it ('should have the navigation buttons', function() {104 // given105 var $form = $('#stepy'),106 $steps = $form.children(), 107 $first = $steps.eq(0),108 $second = $steps.eq(1),109 $third = $steps.eq(2);110 // when111 $form.stepy();112 // then113 expect($first).toContain('p.stepy-buttons');114 expect($second).toContain('p.stepy-buttons');115 expect($third).toContain('p.stepy-buttons');116 $first = $first.children('p.stepy-buttons');117 $second = $second.children('p.stepy-buttons');118 $third = $third.children('p.stepy-buttons');119 expect($first).not.toContain('.button-back');120 expect($first).toContain('.button-next');121 expect($second).toContain('.button-back');122 expect($second).toContain('.button-next');123 expect($third).toContain('.button-back');124 expect($third).not.toContain('.button-next');125 expect($third).toContain('input.finish');126 });127 it ('should have default label on navigation buttons', function() {128 // given129 var $form = $('#stepy'),130 $steps = $form.children(), 131 $first = $steps.eq(0),132 $second = $steps.eq(1),133 $third = $steps.eq(2);134 // when135 $form.stepy();136 // then137 var $firstNext = $first.find('.button-next'),138 $secondBack = $second.find('.button-back'),139 $secondNext = $second.find('.button-next'),140 $thirdBack = $third.find('.button-back');141 expect($firstNext).toHaveHtml('Next >');142 expect($secondBack).toHaveHtml('< Back');143 expect($secondNext).toHaveHtml('Next >');144 expect($thirdBack).toHaveHtml('< Back');145 });146 it ('should not include the finish button', function() {147 // given148 var $form = $('#stepy');149 // when150 $form.stepy({ finishButton: false });151 // then152 expect($form.children().eq(2)).not.toContain('input.finish');153 });154 it ('should have titleClick disabled', function() {155 // given156 var $form = $('#stepy').stepy(),157 $steps = $form.children(), 158 $first = $steps.eq(0),159 $second = $steps.eq(1),160 $third = $steps.eq(2);161 // when162 $('#stepy-titles').children('li').eq(1);163 // then164 expect($first).not.toBeHidden();165 expect($second).toBeHidden();166 expect($third).toBeHidden();167 });168 it ('should forward to second step', function() {169 // given170 var $form = $('#stepy').stepy(),171 $steps = $form.children(), 172 $first = $steps.eq(0),173 $second = $steps.eq(1),174 $third = $steps.eq(2);175 // when176 $steps.first().find('.button-next').click();177 // then178 expect($first).toBeHidden();179 expect($second).not.toBeHidden();180 expect($third).toBeHidden();181 });182 it ('should forward to third step', function() {183 // given184 var $form = $('#stepy').stepy(),185 $steps = $form.children(), 186 $first = $steps.eq(0),187 $second = $steps.eq(1),188 $third = $steps.eq(2);189 // when190 $steps.eq(0).find('.button-next').click();191 $steps.eq(1).find('.button-next').click();192 // then193 expect($first).toBeHidden();194 expect($second).toBeHidden();195 expect($third).not.toBeHidden();196 });197 it ('should backward to second step', function() {198 // given199 var $form = $('#stepy').stepy(),200 $steps = $form.children(), 201 $first = $steps.eq(0),202 $second = $steps.eq(1),203 $third = $steps.eq(2);204 $steps.eq(0).find('.button-next').click();205 $steps.eq(1).find('.button-next').click();206 // when207 $steps.eq(2).find('.button-back').click();208 // then209 expect($first).toBeHidden();210 expect($second).not.toBeHidden();211 expect($third).toBeHidden();212 });213 it ('should backward to first step', function() {214 // given215 var $form = $('#stepy').stepy(),216 $steps = $form.children(), 217 $first = $steps.eq(0),218 $second = $steps.eq(1),219 $third = $steps.eq(2);220 $steps.eq(0).find('.button-next').click();221 $steps.eq(1).find('.button-next').click();222 // when223 $steps.eq(2).find('.button-back').click();224 $steps.eq(1).find('.button-back').click();225 // then226 expect($first).not.toBeHidden();227 expect($second).toBeHidden();228 expect($third).toBeHidden();229 });230 it ('should call back callback', function() {231 // given232 var $form = $('#stepy').stepy({ back: function() { this.addClass('my-class'); } }),233 $steps = $form.children(), 234 $first = $steps.eq(0),235 $second = $steps.eq(1),236 $third = $steps.eq(2);237 $steps.eq(0).find('.button-next').click();238 // when239 $steps.eq(1).find('.button-back').click();240 // then241 expect($form).toHaveClass('my-class');242 expect($first).not.toBeHidden();243 expect($second).toBeHidden();244 expect($third).toBeHidden();245 });246 it ('should call next callback', function() {247 // given248 var $form = $('#stepy').stepy({ next: function() { this.addClass('my-class'); } }),249 $steps = $form.children(), 250 $first = $steps.eq(0),251 $second = $steps.eq(1),252 $third = $steps.eq(2);253 // when254 $steps.eq(0).find('.button-next').click();255 // then256 expect($form).toHaveClass('my-class');257 expect($first).toBeHidden();258 expect($second).not.toBeHidden();259 expect($third).toBeHidden();260 });261 it ('should call finish callback', function() {262 // given263 var $form = $('#stepy').stepy({ finish: function() { this.addClass('my-class'); } }),264 $steps = $form.children(), 265 $first = $steps.eq(0),266 $second = $steps.eq(1),267 $third = $steps.eq(2);268 $steps.eq(1).find('.button-next').click();269 $form.submit (function(evt) {270 evt.preventDefault();271 });272 // when273 $steps.eq(2).find('input.finish').click();274 // then275 expect($form).toHaveClass('my-class');276 expect($first).toBeHidden();277 expect($second).toBeHidden();278 expect($third).not.toBeHidden();279 });280 it ('should have custom label on navigation buttons', function() {281 // given282 var $form = $('#stepy'),283 $steps = $form.children(), 284 $first = $steps.eq(0),285 $second = $steps.eq(1),286 $third = $steps.eq(2);287 // when288 $form.stepy({ backLabel: '<<', nextLabel: '>>' });289 // then290 var $firstNext = $first.find('.button-next'),291 $secondBack = $second.find('.button-back'),292 $secondNext = $second.find('.button-next'),293 $thirdBack = $third.find('.button-back');294 expect($firstNext).toHaveHtml('>>');295 expect($secondBack).toHaveHtml('<<');296 expect($secondNext).toHaveHtml('>>');297 expect($thirdBack).toHaveHtml('<<');298 });299 it ('should display error when exists invalid fields', function() {300 // given301 var $form = $('#stepy').stepy({ validate: true }),302 $steps = $form.children(), 303 $first = $steps.eq(0),304 $second = $steps.eq(1),305 $third = $steps.eq(2);306 $form.validate({307 errorPlacement: function(error, element) {308 $('#stepy div.stepy-error').append(error);309 }, rules: {310 'password': 'required'311 }, messages: {312 'password': { required: 'Password field is requerid!' }313 }314 });315 // when316 $first.find('.button-next').click();317 // then318 expect($form.children('.stepy-error')).toContain('label.error');319 expect($first).toBeHidden();320 expect($second).not.toBeHidden();321 expect($third).toBeHidden();322 });323 it ('should block step when exists invalid fields', function() {324 // given325 var $form = $('#stepy').stepy({ block: true, validate: true }),326 $steps = $form.children(), 327 $first = $steps.eq(0),328 $second = $steps.eq(1),329 $third = $steps.eq(2);330 $form.validate({331 errorPlacement: function(error, element) {332 $('#stepy div.stepy-error').append(error);333 }, rules: {334 'password': 'required'335 }, messages: {336 'password': { required: 'Password field is requerid!' }337 }338 });339 // when340 $first.find('.button-next').click();341 // then342 expect($form.children('.stepy-error')).toContain('label.error');343 expect($first).not.toBeHidden();344 expect($second).toBeHidden();345 expect($third).toBeHidden();346 });347 it ('should not block step when not exists invalid fields', function() {348 // given349 var $form = $('#stepy').stepy({ block: true, validate: true }),350 $steps = $form.children(), 351 $first = $steps.eq(0),352 $second = $steps.eq(1),353 $third = $steps.eq(2);354 $form.validate({355 errorPlacement: function(error, element) {356 $('#stepy div.stepy-error').append(error);357 }, rules: {358 'password': 'required'359 }, messages: {360 'password': { required: 'Password field is requerid!' }361 }362 });363 $form.find('input[name="password"]').val('password');364 // when365 $first.find('.button-next').click();366 // then367 expect($form.children('.stepy-error')).not.toContain('label.error');368 expect($first).toBeHidden();369 expect($second).not.toBeHidden();370 expect($third).toBeHidden();371 });372 it ('should block step with custom icon error when exists invalid fields', function() {373 // given374 var $form = $('#stepy').stepy({ block: true, errorImage: true, validate: true }),375 $steps = $form.children(), 376 $first = $steps.eq(0),377 $second = $steps.eq(1),378 $third = $steps.eq(2);379 $form.validate({380 errorPlacement: function(error, element) {381 $('#stepy div.stepy-error').append(error);382 }, rules: {383 'password': 'required'384 }, messages: {385 'password': { required: 'Password field is requerid!' }386 }387 });388 // when389 $first.find('.button-next').click();390 // then391 expect($('#stepy-titles').children('li').eq(0)).toHaveClass('error-image');392 expect($form.children('.stepy-error')).toContain('label.error');393 expect($first).not.toBeHidden();394 expect($second).toBeHidden();395 expect($third).toBeHidden();396 });397 it ('should not display description', function() {398 // given399 var $form = $('#stepy');400 // when401 $form.stepy({ description: false });402 var $menus = $('#stepy-titles').children('li'),403 $first = $menus.eq(0),404 $second = $menus.eq(1),405 $third = $menus.eq(2);406 // then407 expect($first).not.toContain('span');408 expect($second).not.toContain('span');409 expect($third).not.toContain('span');410 });411 it ('should not display legend', function() {412 // given413 var $form = $('#stepy'),414 $steps = $form.children(), 415 $first = $steps.eq(0),416 $second = $steps.eq(1),417 $third = $steps.eq(2);418 // when419 $form.stepy({ legend: false });420 // then421 expect($first.children('legend')).toBeHidden();422 expect($second.children('legend')).toBeHidden();423 expect($third.children('legend')).toBeHidden();424 });425 it ('should have titleClick enabled', function() {426 // given427 var $form = $('#stepy').stepy({ titleClick: true }),428 $steps = $form.children(), 429 $first = $steps.eq(0),430 $second = $steps.eq(1),431 $third = $steps.eq(2);432 // when433 $('#stepy-titles').children('li').eq(2).click();434 // then435 expect($first).toBeHidden();436 expect($second).toBeHidden();437 expect($third).not.toBeHidden();438 });439 it ('should block step when exists invalid fields using titleClick', function() {440 // given441 var $form = $('#stepy').stepy({ block: true, titleClick: true, validate: true }),442 $steps = $form.children(), 443 $first = $steps.eq(0),444 $second = $steps.eq(1),445 $third = $steps.eq(2);446 $form.validate({447 errorPlacement: function(error, element) {448 $('#stepy div.stepy-error').append(error);449 }, rules: {450 'password': 'required'451 }, messages: {452 'password': { required: 'Password field is requerid!' }453 }454 });455 // when456 $('#stepy-titles').children('li').eq(2).click();457 // then458 expect($form.children('.stepy-error')).toContain('label.error');459 expect($first).not.toBeHidden();460 expect($second).toBeHidden();461 expect($third).toBeHidden();462 });463 it ('should block step with errorImage when exists invalid fields using titleClick', function() {464 // given465 var $form = $('#stepy').stepy({ block: true, errorImage: true, titleClick: true, validate: true }),466 $steps = $form.children(), 467 $first = $steps.eq(0),468 $second = $steps.eq(1),469 $third = $steps.eq(2),470 $titles = $('#stepy-titles');471 $form.validate({472 errorPlacement: function(error, element) {473 $('#stepy div.stepy-error').append(error);474 }, rules: {475 'password': 'required'476 }, messages: {477 'password': { required: 'Password field is requerid!' }478 }479 });480 // when481 $titles.children('li').eq(2).click();482 // then483 expect($titles.children('li').eq(0)).toHaveClass('error-image');484 expect($form.children('.stepy-error')).toContain('label.error');485 expect($first).not.toBeHidden();486 expect($second).toBeHidden();487 expect($third).toBeHidden();488 });489 it ('should move titles to target', function() {490 // given491 var $target = $('<div id="target"></div>').appendTo('body');492 // when493 $('#stepy').stepy({ titleTarget: '#target' });494 var $menus = $target.children('#stepy-titles').children('li'),495 $first = $menus.eq(0),496 $second = $menus.eq(1),497 $third = $menus.eq(2);498 // then499 expect($first.children('div')).toHaveHtml('Step 1');500 expect($second.children('div')).toHaveHtml('Step 2');501 expect($third.children('div')).toHaveHtml('Step 3');502 $target.remove();503 });504 it ('should have titleClick enabled', function() {505 // given506 var $form = $('#stepy').stepy({ titleClick: true }),507 $steps = $form.children(), 508 $first = $steps.eq(0),509 $second = $steps.eq(1),510 $third = $steps.eq(2);511 // when512 $('#stepy-titles').children('li').eq(2).click();513 // then514 expect($first).toBeHidden();515 expect($second).toBeHidden();516 expect($third).not.toBeHidden();517 });518 519 it ('should move titles to target and works titleClick', function() {520 // given521 var $target = $('<div id="target"></div>').appendTo('body');522 // when523 var $form = $('#stepy').stepy({ titleClick: true, titleTarget: '#target' }),524 $steps = $form.children(), 525 $first = $steps.eq(0),526 $second = $steps.eq(1),527 $third = $steps.eq(2);528 $target.children('#stepy-titles').children('li').eq(2).click();529 // then530 expect($first).toBeHidden();531 expect($second).toBeHidden();532 expect($third).not.toBeHidden();533 $target.remove();534 });535 it ('should be hidden the finish button', function() {536 // given537 var $form = $('#stepy'),538 $steps = $form.children(), 539 $third = $steps.eq(2);540 // when541 $form.stepy();542 // then543 expect($third.find('input.finish')).toBeHidden();544 });545 it ('should be visible the finish button', function() {546 // given547 var $form = $('#stepy').stepy(),548 $steps = $form.children(), 549 $second = $steps.eq(1),550 $third = $steps.eq(2);551 // when552 $second.find('.button-next').click();553 // then554 expect($third.find('input.finish')).not.toBeHidden();555 });556 it ('should forward step with enter', function() {557 // given558 var $form = $('#stepy').stepy(),559 $steps = $form.children(), 560 $first = $steps.eq(0),561 $second = $steps.eq(1),562 $third = $steps.eq(2),563 $password = $form.find('input[name="password"]').val('password'),564 evt = jQuery.Event('keypress');565 evt.which = 13;566 evt.keyCode = 13;567 // when568 $password.trigger(evt);569 // then570 expect($first).toBeHidden();571 expect($second).not.toBeHidden();572 expect($third).toBeHidden();573 });574 it ('should submit on last step with enter', function() {575 // given576 var $form = $('#stepy').stepy({ finish: function() { this.addClass('my-class'); } }),577 $steps = $form.children(), 578 $first = $steps.eq(0);579 $second = $steps.eq(1);580 $third = $steps.eq(2),581 $site = $form.find('input[name="site"]'),582 evt = jQuery.Event('keypress');583 evt.which = 13;584 evt.keyCode = 13;585 $form.submit (function(evt) {586 evt.preventDefault();587 });588 $second.find('.button-next').click();589 // when590 $site.trigger(evt);591 // then592 expect($first).toBeHidden();593 expect($second).toBeHidden();594 expect($third).not.toBeHidden();595 expect($form).toHaveClass('my-class');596 });597 it ('should focus the first field on next step', function() {598 // given599 var $form = $('#stepy').stepy(),600 $steps = $form.children(), 601 $first = $steps.eq(0),602 $second = $steps.eq(1);603 // when604 $first.find('.button-next').click();605 // then606 expect($second.find(':input:enabled:visible:first')).toBeFocused();607 });608 it ('should focus the first field on back step', function() {609 // given610 var $form = $('#stepy').stepy(),611 $steps = $form.children(), 612 $first = $steps.eq(0),613 $second = $steps.eq(1);614 // when615 $first.find('.button-next').click();616 $second.find('.button-back').click();617 // then618 expect($first.find(':input:enabled:visible:first')).toBeFocused();619 });620 it ('should focus on next step with enter', function() {621 // given622 var $form = $('#stepy').stepy(),623 $steps = $form.children(), 624 $second = $steps.eq(1);625 evt = jQuery.Event('keypress');626 evt.which = 13;627 evt.keyCode = 13;628 // when629 $('input[name="email"]').trigger(evt);630 // then631 expect($second.find(':input:enabled:visible:first')).toBeFocused();632 });633 it ('should return the correct index on next callback with enter', function() {634 // given635 var $email = $('input[name="email"]'),636 evt = jQuery.Event('keypress');637 evt.which = 13;638 evt.keyCode = 13;639 $('#stepy').stepy({ next: function(index) { $email.val(index); } });640 // when641 $email.trigger(evt);642 // then643 expect($email).toHaveValue(2);644 });645 it ('should return the correct index on next callback', function() {646 // given647 var $email = $('input[name="email"]'),648 $form = $('#stepy').stepy({ next: function(index) { $email.val(index); } }),649 $steps = $form.children(), 650 $first = $steps.eq(0);651 // when652 $first.find('.button-next').click();653 // then654 expect($email).toHaveValue(2);655 });656 it ('should return the correct index on back callback', function() {657 // given658 var $email = $('input[name="email"]'),659 $form = $('#stepy').stepy({ back: function(index) { $email.val(index); } }),660 $steps = $form.children(),661 $second = $steps.eq(1);662 // when663 $second.find('.button-back').click();664 // then665 expect($email).toHaveValue(1);666 });667 it ('should return the correct index on next title callback', function() {668 // given669 var $email = $('input[name="email"]');670 $('#stepy').stepy({ next: function(index) { $email.val(index); }, titleClick: true });671 // when672 $('#stepy-titles').children('li').eq(1).click();673 // then674 expect($email).toHaveValue(2);675 });676 it ('should return the correct index on back title callback', function() {677 // given678 var $email = $('input[name="email"]');679 $('#stepy').stepy({ back: function(index) { $email.val(index); }, titleClick: true });680 var $titles = $('#stepy-titles').children('li');681 $titles.eq(1).click();682 // when683 $titles.eq(0).click();684 // then685 expect($email).toHaveValue(1);686 });687 it ('should return the correct index on next-select title callback', function() {688 // given689 var $email = $('input[name="email"]');690 $('#stepy').stepy({ select: function(index) { $email.val(index); }, titleClick: true });691 var $titles = $('#stepy-titles').children('li');692 // when693 $titles.eq(1).click();694 // then695 expect($email).toHaveValue(2);696 });697 it ('should return the correct index on back-select callback', function() {698 // given699 var $email = $('input[name="email"]');700 $('#stepy').stepy({ select: function(index) { $email.val(index); }, titleClick: true });701 var $titles = $('#stepy-titles').children('li');702 $titles.eq(1).click();703 // when704 $titles.eq(0).click();705 // then706 expect($email).toHaveValue(1);707 });708 it ('should return the correct index on next-select with invalid fields', function() {709 // given710 var $email = $('input[name="email"]'),711 $form = $('#stepy').stepy({ block: true, select: function(index) { $email.val(index); }, validate: true }),712 $steps = $form.children(), 713 $first = $steps.eq(0);714 $form.validate({ rules: { 'email': 'required' }, messages: { 'email': { required: '--' } } });715 // when716 $first.find('.button-next').click();717 // then718 expect($email).toHaveValue(1);719 });720 it ('should return the correct index on far next-select title with invalid fields', function() {721 // given722 var $email = $('input[name="email"]').val('1'),723 $form = $('#stepy').stepy({ block: true, select: function(index) { $email.val(index); }, validate: true }),724 $titles = $('#stepy-titles').children('li');725 $form.validate({ rules: { 'email': 'required' }, messages: { 'email': { required: '--' } } });726 // when727 $titles.eq(2).click();728 // then729 expect($email).toHaveValue(1);730 });731 it ('should be chainable the function step', function() {732 // given733 var $form = $('#stepy').stepy(),734 className = 'my-class';735 // when736 $form.stepy('step', 2).addClass(className);737 // then738 expect($form).toHaveClass(className);739 });740 it ('should be chainable the function step', function() {741 // given742 var $form = $('#stepy').stepy(),743 className = 'my-class';744 // when745 $form.stepy('step', 2).addClass(className);746 // then747 expect($form).toHaveClass(className);748 });749 it ('should go to step 2 using function step', function() {750 // given751 var $form = $('#stepy').stepy(),752 $steps = $form.children(), 753 $first = $steps.eq(0),754 $second = $steps.eq(1),755 $third = $steps.eq(2);756 // when757 $form.stepy('step', 2);758 // then759 expect($first).toBeHidden();760 expect($second).not.toBeHidden();761 expect($third).toBeHidden();762 });763 it ('should valid checkable field even when it is hidden (ignore overrided)', function() {764 // given765 var $form = $('#stepy').stepy({ block: true, validate: true }),766 $steps = $form.children(), 767 $first = $steps.eq(0),768 $second = $steps.eq(1),769 $third = $steps.eq(2);770 $form.validate({771 errorPlacement: function(error, element) {772 $('#stepy div.stepy-error').append(error);773 }, rules: {774 'checked': 'required'775 }, messages: {776 'checked': { required: 'Checked field is requerid!' }777 }778 });779 var $checked = $('input[name="checked"]');780 // when781 $checked.click();782 $first.find('.button-next').click();783 $checked.click();784 $second.find('.button-next').click();785 // then786 expect($form.children('.stepy-error')).toContain('label.error');787 expect($first).not.toBeHidden();788 expect($second).toBeHidden();789 expect($third).toBeHidden();790 });...
tests.js
Source:tests.js
...140 expect($('#homeButton')).toExist();141 });142 143 it("should not have any buttons in view", function() {144 expect($('#editButton')).toBeHidden();145 expect($('#friendButton')).toBeHidden();146 expect($('#unfriendButton')).toBeHidden();147 });148 149 it("should not have anything in mainContent", function() {150 expect($('#mainContent')).toBeEmpty();151 });152 153 setFixtures(sandbox());154 $('#sandbox').append(readFixtures("profilefixture.html"));155 var userData = {156 "username": "MrPeanutbutter",157 "phone": "6041234567",158 "friends": [159 {160 "username": "cat",161 "phone": "",162 "id": 21,163 "email": ""164 },165 {166 "username": "shaybeau",167 "phone": "6047654324",168 "id": 6,169 "email": "shayshay@email.com"170 }171 ],172 "id": 20,173 "email": "peanutbutter@isoneword.com"174 };175 176 profileInfo.loadLoggedInData(userData);177 });178 179 it("should have only edit button visible", function() {180 expect($('#editButton')).toBeVisible();181 expect($('#friendButton')).toBeHidden();182 expect($('#unfriendButton')).toBeHidden(); 183 });184 185 it("should have things in mainContent", function() {186 expect($('#mainContent')).not.toBeEmpty();187 });188 189 afterEach(function(){190 profileInfo.clearProfile();191 192 it("should have things that exist still", function() {193 expect($('#homeButton')).toExist();194 });195 196 it("should not have any buttons in view anymore", function() {197 expect($('#editButton')).toBeHidden();198 expect($('#friendButton')).toBeHidden();199 expect($('#unfriendButton')).toBeHidden();200 });201 202 it("should not have anything anymore in mainContent", function() {203 expect($('#mainContent')).toBeEmpty();204 });205 }); 206});207describe("Friend profile view", function() {208 209 var profileInfo;210 211 beforeEach(function() {212 213 profileInfo = new ProfileInfo();214 215 it("should have things that exist", function() {216 expect($('#homeButton')).toExist();217 });218 219 it("should not have any buttons in view", function() {220 expect($('#editButton')).toBeHidden();221 expect($('#friendButton')).toBeHidden();222 expect($('#unfriendButton')).toBeHidden();223 });224 225 it("should not have anything in mainContent", function() {226 expect($('#mainContent')).toBeEmpty();227 });228 229 setFixtures(sandbox());230 $('#sandbox').append(readFixtures("profilefixture.html"));231 232 var friendData = {233 "username": "MrPeanutbutter",234 "phone": "6041234567",235 "id": 20,236 "email": "peanutbutter@isoneword.com"237 };238 239 profileInfo.loadFriendData(friendData);240 });241 242 it("should have only unfriend button visible", function() {243 expect($('#editButton')).toBeHidden();244 expect($('#friendButton')).toBeHidden();245 expect($('#unfriendButton')).toBeVisible(); 246 });247 248 it("should have things in mainContent", function() {249 expect($('#mainContent')).not.toBeEmpty();250 });251 252 afterEach(function(){253 profileInfo.clearProfile();254 it("should have things that exist still", function() {255 expect($('#editButton')).toExist();256 });257 258 it("should not have any buttons in view anymore", function() {259 expect($('#editButton')).toBeHidden();260 expect($('#friendButton')).toBeHidden();261 expect($('#unfriendButton')).toBeHidden();262 });263 264 it("should not have anything anymore in mainContent", function() {265 expect($('#mainContent')).toBeEmpty();266 });267 });268 269});270describe("Stranger profile view", function() {271 272 var profileInfo;273 274 beforeEach(function() {275 276 profileInfo = new ProfileInfo();277 278 setFixtures(sandbox());279 $('#sandbox').append(readFixtures("profilefixture.html"));280 281 it("should have things that exist", function() {282 expect($('#editButton')).toExist();283 });284 285 it("should not have any buttons in view", function() {286 expect($('#editButton')).toBeHidden();287 expect($('#friendButton')).toBeHidden();288 expect($('#unfriendButton')).toBeHidden();289 });290 291 it("should not have anything in mainContent", function() {292 expect($('#mainContent')).toBeEmpty();293 });294 295 296 var username = "MrPeanutbutter";297 profileInfo.loadStrangerData(username);298 });299 300 it("should have only friend button visible", function() {301 expect($('#editButton')).toBeHidden();302 expect($('#friendButton')).toBeVisible();303 expect($('#unfriendButton')).toBeHidden(); 304 });305 306 it("should have things in mainContent", function() {307 expect($('#mainContent')).not.toBeEmpty();308 });309 310 afterEach(function(){311 profileInfo.clearProfile();312 it("should have things that exist still", function() {313 expect($('#editButton')).toExist();314 });315 316 it("should not have any buttons in view anymore", function() {317 expect($('#editButton')).toBeHidden();318 expect($('#friendButton')).toBeHidden();319 expect($('#unfriendButton')).toBeHidden();320 });321 322 it("should not have anything anymore in mainContent", function() {323 expect($('#mainContent')).toBeEmpty();324 });325 }); 326});327// ***********************************************************328// Testing editing user profile329describe("Edit User Profile", function(){330 var userId, uname, mail, phonenum;331 beforeEach(function(){332 userId = 6;333 uname = "shaybeau";334 mail = "shayshay@email.com";335 phonenum = "1234567890";336 setFixtures(sandbox());337 $('#sandbox').append(readFixtures("editprofilefixture.html"));338 LetsDoThis.Session.getInstance().setUserId(userId);339 LetsDoThis.Session.getInstance().setUserInfo({id:userId, username:uname, email:mail, phone:phonenum});340 });341 342 // Home and back have page redirects, so can't be tested343 344 it("loads current data correctly", function(){345 loadCurrentData();346 expect($('#editUsername')).toHaveValue(uname);347 expect($('#editEmail')).toHaveValue(mail);348 expect($('#editPhone')).toHaveValue(phonenum);349 });350 351 it("clears profile properly", function() {352 clearProfile();353 354 it("should not have any buttons in view anymore", function() {355 expect($('#editButton')).toBeHidden();356 expect($('#friendButton')).toBeHidden();357 expect($('#unfriendButton')).toBeHidden();358 });359 360 it("should not have anything anymore in mainContent", function() {361 expect($('#mainContent')).toBeEmpty();362 });363 });364 365 it("can make a call to send edit profile requests to server", function() {366 spyOn(window, "updateUserInfo");367 var editedUsername = "sheabo";368 var editedEmail = "email@shayshay.com";369 var editedPhone = "9080706050";370 editUserData(editedUsername, editedEmail, editedPhone);371 expect(window.updateUserInfo).toHaveBeenCalled();...
accordion.js
Source:accordion.js
...17 it('should default to the active tab', function() {18 $(document).foundation();19 expect($('#panel1')).toBeVisible();20 expect($('#panel2-1')).toBeVisible();21 expect($('#panel2-2')).toBeHidden();22 expect($('#panel2')).toBeHidden();23 expect($('#panel3')).toBeHidden();24 });25 it('should switch to the clicked section', function() {26 $(document).foundation();27 $('#panel2').prev().click();28 expect($('#panel1')).toBeHidden();29 expect($('#panel2-1')).toBeHidden();30 expect($('#panel2-2')).toBeHidden();31 expect($('#panel2')).toBeVisible();32 expect($('#panel3')).toBeHidden();33 });34 });35 describe('embedded grid accordion', function() {36 beforeEach(function() {37 document.body.innerHTML = __html__['spec/accordion/grid.html'];38 });39 it('should switch to the clicked section', function() {40 $(document).foundation();41 $('#panel1c').prev().click();42 expect($('#panel1c')).toBeVisible();43 expect($('#panel2c')).toBeHidden();44 expect($('#panel3c')).toBeHidden();45 expect($('#panel4c')).toBeHidden();46 expect($('#panel5c')).toBeHidden();47 expect($('#panel6c')).toBeHidden();48 $('#panel4c').prev().click();49 expect($('#panel1c')).toBeHidden();50 expect($('#panel2c')).toBeHidden();51 expect($('#panel3c')).toBeHidden();52 expect($('#panel4c')).toBeVisible();53 expect($('#panel5c')).toBeHidden();54 expect($('#panel6c')).toBeHidden();55 });56 });57 describe('multi-expand accordion', function() {58 beforeEach(function() {59 document.body.innerHTML = __html__['spec/accordion/multiexpand.html'];60 });61 it('should default to the active panel', function() {62 $(document).foundation('accordion', { multi_expand: true });63 expect($('#panel1')).toBeHidden();64 expect($('#panel2')).toBeVisible();65 expect($('#panel3')).toBeHidden();66 });67 it('should open the clicked section, leaving previous active panels open', function() {68 $(document).foundation('accordion', { multi_expand: true });69 $('#panel3').prev().click();70 expect($('#panel1')).toBeHidden();71 expect($('#panel2')).toBeVisible();72 expect($('#panel3')).toBeVisible();73 });74 });...
Using AI Code Generation
1const { test, expect } = require('@playwright/test');2test('test', async ({ page }) => {3 await expect(page.locator('text=Get started')).toBeHidden();4});5 expect(received).toBeHidden()6 6 | test('test', async ({ page }) => {7 > 8 | await expect(page.locator('text=Get started')).toBeHidden();8 9 | });9 at Object.toBeHidden (test.js:8:50)
Using AI Code Generation
1const { test, expect } = require("@playwright/test");2test("test", async ({ page }) => {3 await expect(page.locator("text=Get Started")).toBeHidden();4});5const { test, expect } = require("@playwright/test");6test("test", async ({ page }) => {7 await expect(page.locator("text=Get Started")).toBeHidden();8});9const { test, expect } = require("@playwright/test");10test("test", async ({ page }) => {11 await expect(page.locator("text=Get Started")).toBeHidden();12});13const { test, expect } = require("@playwright/test");14test("test", async ({ page }) => {15 await expect(page.locator("text=Get Started")).toBeHidden();16});17const { test, expect } = require("@playwright/test");18test("test", async ({ page }) => {19 await expect(page.locator("text=Get Started")).toBeHidden();20});21const { test, expect } = require("@playwright/test");22test("test", async ({ page }) => {23 await expect(page.locator("text=Get Started")).toBeHidden();24});25const { test, expect } = require("@playwright/test");26test("test", async ({ page }) => {27 await expect(page.locator("text=Get Started")).toBeHidden();28});29const { test, expect } = require("@playwright/test");30test("test", async ({ page }) => {31 await expect(page.locator("text=Get Started")).toBeHidden();
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.
Get 100 minutes of automation test minutes FREE!!