Best JavaScript code snippet using playwright-internal
buttons.spec.js
Source: buttons.spec.js
...22 //model -> UI23 it('should work correctly with default model values', function() {24 $scope.model = false;25 var btn = compileButton('<button ng-model="model" uib-btn-checkbox>click</button>', $scope);26 expect(btn).not.toHaveClass('active');27 $scope.model = true;28 $scope.$digest();29 expect(btn).toHaveClass('active');30 });31 it('should bind custom model values', function() {32 $scope.model = 1;33 var btn = compileButton('<button ng-model="model" uib-btn-checkbox btn-checkbox-true="1" btn-checkbox-false="0">click</button>', $scope);34 expect(btn).toHaveClass('active');35 $scope.model = 0;36 $scope.$digest();37 expect(btn).not.toHaveClass('active');38 });39 //UI-> model40 it('should toggle default model values on click', function() {41 $scope.model = false;42 var btn = compileButton('<button ng-model="model" uib-btn-checkbox>click</button>', $scope);43 btn.click();44 expect($scope.model).toEqual(true);45 expect(btn).toHaveClass('active');46 btn.click();47 expect($scope.model).toEqual(false);48 expect(btn).not.toHaveClass('active');49 });50 it('should toggle custom model values on click', function() {51 $scope.model = 0;52 var btn = compileButton('<button ng-model="model" uib-btn-checkbox btn-checkbox-true="1" btn-checkbox-false="0">click</button>', $scope);53 btn.click();54 expect($scope.model).toEqual(1);55 expect(btn).toHaveClass('active');56 btn.click();57 expect($scope.model).toEqual(0);58 expect(btn).not.toHaveClass('active');59 });60 it('should monitor true / false value changes - issue 666', function() {61 $scope.model = 1;62 $scope.trueVal = 1;63 var btn = compileButton('<button ng-model="model" uib-btn-checkbox btn-checkbox-true="trueVal">click</button>', $scope);64 expect(btn).toHaveClass('active');65 expect($scope.model).toEqual(1);66 $scope.model = 2;67 $scope.trueVal = 2;68 $scope.$digest();69 expect(btn).toHaveClass('active');70 expect($scope.model).toEqual(2);71 });72 it('should not toggle when disabled - issue 4013', function() {73 $scope.model = 1;74 $scope.falseVal = 0;75 var btn = compileButton('<button disabled ng-model="model" uib-btn-checkbox btn-checkbox-true="falseVal">click</button>', $scope);76 expect(btn).not.toHaveClass('active');77 expect($scope.model).toEqual(1);78 btn.click();79 expect(btn).not.toHaveClass('active');80 $scope.$digest();81 expect(btn).not.toHaveClass('active');82 });83 describe('setting buttonConfig', function() {84 var uibButtonConfig, originalActiveClass, originalToggleEvent;85 beforeEach(inject(function(_uibButtonConfig_) {86 uibButtonConfig = _uibButtonConfig_;87 originalActiveClass = uibButtonConfig.activeClass;88 originalToggleEvent = uibButtonConfig.toggleEvent;89 uibButtonConfig.activeClass = false;90 uibButtonConfig.toggleEvent = false;91 }));92 afterEach(function() {93 // return it to the original value94 uibButtonConfig.activeClass = originalActiveClass;95 uibButtonConfig.toggleEvent = originalToggleEvent;96 });97 it('should use default config when buttonConfig.activeClass and buttonConfig.toggleEvent is false', function() {98 $scope.model = false;99 var btn = compileButton('<button ng-model="model" uib-btn-checkbox>click</button>', $scope);100 expect(btn).not.toHaveClass('active');101 $scope.model = true;102 $scope.$digest();103 expect(btn).toHaveClass('active');104 });105 it('should be able to use a different active class', function() {106 uibButtonConfig.activeClass = 'foo';107 $scope.model = false;108 var btn = compileButton('<button ng-model="model" uib-btn-checkbox>click</button>', $scope);109 expect(btn).not.toHaveClass('foo');110 $scope.model = true;111 $scope.$digest();112 expect(btn).toHaveClass('foo');113 });114 it('should be able to use a different toggle event', function() {115 uibButtonConfig.toggleEvent = 'mouseenter';116 $scope.model = false;117 var btn = compileButton('<button ng-model="model" uib-btn-checkbox>click</button>', $scope);118 expect(btn).not.toHaveClass('active');119 btn.trigger('mouseenter');120 $scope.$digest();121 expect(btn).toHaveClass('active');122 });123 });124 });125 describe('radio', function() {126 var compileButtons = function(markup, scope) {127 var el = $compile('<div>'+markup+'</div>')(scope);128 scope.$digest();129 return el.find('button');130 };131 it('should expose the controller to the view', inject(function($templateCache) {132 var btn = compileButtons('<button ng-model="model" uib-btn-radio="1">{{buttons.text}}</button>', $scope);133 var ctrl = btn.controller('uibBtnRadio');134 expect(ctrl).toBeDefined();135 ctrl.text = 'foo';136 $scope.$digest();137 expect(btn.html()).toBe('foo');138 }));139 //model -> UI140 it('should set active class based on model', function() {141 var btns = compileButtons('<button ng-model="model" uib-btn-radio="1">click1</button><button ng-model="model" uib-btn-radio="2">click2</button>', $scope);142 expect(btns.eq(0)).not.toHaveClass('active');143 expect(btns.eq(1)).not.toHaveClass('active');144 $scope.model = 2;145 $scope.$digest();146 expect(btns.eq(0)).not.toHaveClass('active');147 expect(btns.eq(1)).toHaveClass('active');148 });149 //UI->model150 it('should set active class via click', function() {151 var btns = compileButtons('<button ng-model="model" uib-btn-radio="1">click1</button><button ng-model="model" uib-btn-radio="2">click2</button>', $scope);152 expect($scope.model).toBeUndefined();153 btns.eq(0).click();154 expect($scope.model).toEqual(1);155 expect(btns.eq(0)).toHaveClass('active');156 expect(btns.eq(1)).not.toHaveClass('active');157 btns.eq(1).click();158 expect($scope.model).toEqual(2);159 expect(btns.eq(1)).toHaveClass('active');160 expect(btns.eq(0)).not.toHaveClass('active');161 });162 it('should watch uib-btn-radio values and update state accordingly', function() {163 $scope.values = ['value1', 'value2'];164 var btns = compileButtons('<button ng-model="model" uib-btn-radio="values[0]">click1</button><button ng-model="model" uib-btn-radio="values[1]">click2</button>', $scope);165 expect(btns.eq(0)).not.toHaveClass('active');166 expect(btns.eq(1)).not.toHaveClass('active');167 $scope.model = 'value2';168 $scope.$digest();169 expect(btns.eq(0)).not.toHaveClass('active');170 expect(btns.eq(1)).toHaveClass('active');171 $scope.values[1] = 'value3';172 $scope.model = 'value3';173 $scope.$digest();174 expect(btns.eq(0)).not.toHaveClass('active');175 expect(btns.eq(1)).toHaveClass('active');176 });177 it('should do nothing when clicking an active radio', function() {178 $scope.model = 1;179 var btns = compileButtons('<button ng-model="model" uib-btn-radio="1">click1</button><button ng-model="model" uib-btn-radio="2">click2</button>', $scope);180 expect(btns.eq(0)).toHaveClass('active');181 expect(btns.eq(1)).not.toHaveClass('active');182 btns.eq(0).click();183 $scope.$digest();184 expect(btns.eq(0)).toHaveClass('active');185 expect(btns.eq(1)).not.toHaveClass('active');186 });187 it('should not toggle when disabled - issue 4013', function() {188 $scope.model = 1;189 var btns = compileButtons('<button ng-model="model" uib-btn-radio="1">click1</button><button disabled ng-model="model" uib-btn-radio="2">click2</button>', $scope);190 expect(btns.eq(0)).toHaveClass('active');191 expect(btns.eq(1)).not.toHaveClass('active');192 btns.eq(1).click();193 expect(btns.eq(0)).toHaveClass('active');194 expect(btns.eq(1)).not.toHaveClass('active');195 $scope.$digest();196 expect(btns.eq(0)).toHaveClass('active');197 expect(btns.eq(1)).not.toHaveClass('active');198 });199 it('should handle string values in uib-btn-radio value', function() {200 $scope.model = 'Two';201 var btns = compileButtons('<button ng-model="model" uib-btn-radio="\'One\'">click1</button><button ng-model="model" uib-btn-radio="\'Two\'">click2</button>', $scope);202 expect(btns.eq(0)).not.toHaveClass('active');203 expect(btns.eq(1)).toHaveClass('active');204 btns.eq(0).click();205 expect(btns.eq(0)).toHaveClass('active');206 expect(btns.eq(1)).not.toHaveClass('active');207 expect($scope.model).toEqual('One');208 $scope.$digest();209 expect(btns.eq(0)).toHaveClass('active');210 expect(btns.eq(1)).not.toHaveClass('active');211 expect($scope.model).toEqual('One');212 });213 describe('uncheckable', function() {214 //model -> UI215 it('should set active class based on model', function() {216 var btns = compileButtons('<button ng-model="model" uib-btn-radio="1" uncheckable>click1</button><button ng-model="model" uib-btn-radio="2" uncheckable>click2</button>', $scope);217 expect(btns.eq(0)).not.toHaveClass('active');218 expect(btns.eq(1)).not.toHaveClass('active');219 $scope.model = 2;220 $scope.$digest();221 expect(btns.eq(0)).not.toHaveClass('active');222 expect(btns.eq(1)).toHaveClass('active');223 });224 //UI->model225 it('should unset active class via click', function() {226 var btns = compileButtons('<button ng-model="model" uib-btn-radio="1" uncheckable>click1</button><button ng-model="model" uib-btn-radio="2" uncheckable>click2</button>', $scope);227 expect($scope.model).toBeUndefined();228 btns.eq(0).click();229 expect($scope.model).toEqual(1);230 expect(btns.eq(0)).toHaveClass('active');231 expect(btns.eq(1)).not.toHaveClass('active');232 btns.eq(0).click();233 expect($scope.model).toBeNull();234 expect(btns.eq(1)).not.toHaveClass('active');235 expect(btns.eq(0)).not.toHaveClass('active');236 });237 it('should watch uib-btn-radio values and update state', function() {238 $scope.values = ['value1', 'value2'];239 var btns = compileButtons('<button ng-model="model" uib-btn-radio="values[0]" uncheckable>click1</button><button ng-model="model" uib-btn-radio="values[1]" uncheckable>click2</button>', $scope);240 expect(btns.eq(0)).not.toHaveClass('active');241 expect(btns.eq(1)).not.toHaveClass('active');242 $scope.model = 'value2';243 $scope.$digest();244 expect(btns.eq(0)).not.toHaveClass('active');245 expect(btns.eq(1)).toHaveClass('active');246 $scope.model = undefined;247 $scope.$digest();248 expect(btns.eq(0)).not.toHaveClass('active');249 expect(btns.eq(1)).not.toHaveClass('active');250 });251 });252 describe('uibUncheckable', function() {253 it('should set uncheckable', function() {254 $scope.uncheckable = false;255 var btns = compileButtons('<button ng-model="model" uib-btn-radio="1">click1</button><button ng-model="model" uib-btn-radio="2" uib-uncheckable="uncheckable">click2</button>', $scope);256 expect(btns.eq(0).attr('uncheckable')).toBeUndefined();257 expect(btns.eq(1).attr('uncheckable')).toBeUndefined();258 expect($scope.model).toBeUndefined();259 btns.eq(0).click();260 expect($scope.model).toEqual(1);261 btns.eq(0).click();262 expect($scope.model).toEqual(1);263 btns.eq(1).click();...
isRTL.js
Source: isRTL.js
...87 var cal = $('#cal');88 });89 it('should have have days ordered sun to sat', function() {90 var fc = $(cal).find('.fc-day-header');91 expect(fc[0]).toHaveClass('fc-sun');92 expect(fc[1]).toHaveClass('fc-mon');93 expect(fc[2]).toHaveClass('fc-tue');94 expect(fc[3]).toHaveClass('fc-wed');95 expect(fc[4]).toHaveClass('fc-thu');96 expect(fc[5]).toHaveClass('fc-fri');97 expect(fc[6]).toHaveClass('fc-sat');98 });99 });100 describe('using default isRTL is set to false', function() {101 beforeEach(function() {102 var options = {};103 $('#cal').fullCalendar({104 isRTL: false105 });106 var cal = $('#cal');107 });108 it('should have have days ordered sun to sat', function() {109 var fc = $(cal).find('.fc-day-header');110 expect(fc[0]).toHaveClass('fc-sun');111 expect(fc[1]).toHaveClass('fc-mon');112 expect(fc[2]).toHaveClass('fc-tue');113 expect(fc[3]).toHaveClass('fc-wed');114 expect(fc[4]).toHaveClass('fc-thu');115 expect(fc[5]).toHaveClass('fc-fri');116 expect(fc[6]).toHaveClass('fc-sat');117 });118 });119 describe('using default isRTL is set to false', function() {120 beforeEach(function() {121 var options = {};122 $('#cal').fullCalendar({123 isRTL: true124 });125 var cal = $('#cal');126 });127 it('should have have days ordered back sat to sun', function() {128 var fc = $(cal).find('.fc-day-header');129 expect(fc[6]).toHaveClass('fc-sun');130 expect(fc[5]).toHaveClass('fc-mon');131 expect(fc[4]).toHaveClass('fc-tue');132 expect(fc[3]).toHaveClass('fc-wed');133 expect(fc[2]).toHaveClass('fc-thu');134 expect(fc[1]).toHaveClass('fc-fri');135 expect(fc[0]).toHaveClass('fc-sat');136 });137 });138 });139 describe('when using agendaWeek view', function() {140 describe('when using default isRTL', function() {141 beforeEach(function() {142 var options = {};143 $('#cal').fullCalendar({144 defaultView: 'agendaWeek'145 });146 });147 it('should have have days ordered sun to sat', function() {148 var fc = $(cal).find('.fc-agenda-days th');149 expect(fc[0]).toHaveClass('fc-agenda-axis');150 expect(fc[1]).toHaveClass('fc-sun');151 expect(fc[2]).toHaveClass('fc-mon');152 expect(fc[3]).toHaveClass('fc-tue');153 expect(fc[4]).toHaveClass('fc-wed');154 expect(fc[5]).toHaveClass('fc-thu');155 expect(fc[6]).toHaveClass('fc-fri');156 expect(fc[7]).toHaveClass('fc-sat');157 });158 });159 describe('when using isRTL false', function() {160 beforeEach(function() {161 var options = {};162 $('#cal').fullCalendar({163 defaultView: 'agendaWeek',164 isRTL: false165 });166 });167 it('should have have days ordered sun to sat', function() {168 var fc = $(cal).find('.fc-agenda-days th');169 expect(fc[0]).toHaveClass('fc-agenda-axis');170 expect(fc[1]).toHaveClass('fc-sun');171 expect(fc[2]).toHaveClass('fc-mon');172 expect(fc[3]).toHaveClass('fc-tue');173 expect(fc[4]).toHaveClass('fc-wed');174 expect(fc[5]).toHaveClass('fc-thu');175 expect(fc[6]).toHaveClass('fc-fri');176 expect(fc[7]).toHaveClass('fc-sat');177 });178 });179 describe('when using isRTL true', function() {180 beforeEach(function() {181 var options = {};182 $('#cal').fullCalendar({183 defaultView: 'agendaWeek',184 isRTL: true185 });186 });187 it('should have have days ordered sun to sat', function() {188 var fc = $(cal).find('.fc-agenda-days th');189 expect(fc[0]).toHaveClass('fc-agenda-axis');190 expect(fc[1]).toHaveClass('fc-sat');191 expect(fc[2]).toHaveClass('fc-fri');192 expect(fc[3]).toHaveClass('fc-thu');193 expect(fc[4]).toHaveClass('fc-wed');194 expect(fc[5]).toHaveClass('fc-tue');195 expect(fc[6]).toHaveClass('fc-mon');196 expect(fc[7]).toHaveClass('fc-sun');197 });198 });199 });200 xdescribe('when using agendaWeek view', function() {201 describe('and switching from isRTL false to true', function() {202 beforeEach(function() {203 $('#cal').fullCalendar({204 defaultView: 'agendaWeek',205 isRTL: false206 });207 });208 it('should result in sunday moving from first to last day', function() {209 var fcDaysBefore = $(cal).find('.fc-agenda-days th');210 $('#cal').fullCalendar('isRTL', 'true');211 var fcDaysAfter = $(cal).find('.fc-agenda-days th');212 expect(fcDaysBefore[1]).toHaveClass('fc-sun');213 expect(fcDaysAfter[7]).toHaveCalss('fc-sun');214 });215 });216 });...
firstDay.js
Source: firstDay.js
...7 $('#cal').fullCalendar();8 });9 it('should make Sunday the first day of the week', function() {10 var dayFirst = $('.fc-day-header')[0];11 expect(dayFirst).toHaveClass('fc-sun');12 });13 });14 describe('when setting firstDay to 0', function() {15 beforeEach(function() {16 var options = {17 firstDay: 018 };19 $('#cal').fullCalendar(options);20 });21 it('should make Sunday the first day of the week', function() {22 var daysOfWeek = $('.fc-day-header');23 expect(daysOfWeek[0]).toHaveClass('fc-sun');24 expect(daysOfWeek[1]).toHaveClass('fc-mon');25 expect(daysOfWeek[2]).toHaveClass('fc-tue');26 expect(daysOfWeek[3]).toHaveClass('fc-wed');27 expect(daysOfWeek[4]).toHaveClass('fc-thu');28 expect(daysOfWeek[5]).toHaveClass('fc-fri');29 expect(daysOfWeek[6]).toHaveClass('fc-sat');30 });31 });32 describe('when setting firstDay to 1', function() {33 beforeEach(function() {34 var options = {35 firstDay: 136 };37 $('#cal').fullCalendar(options);38 });39 it('should make Monday the first day of the week', function() {40 var daysOfWeek = $('.fc-day-header');41 expect(daysOfWeek[0]).toHaveClass('fc-mon');42 expect(daysOfWeek[1]).toHaveClass('fc-tue');43 expect(daysOfWeek[2]).toHaveClass('fc-wed');44 expect(daysOfWeek[3]).toHaveClass('fc-thu');45 expect(daysOfWeek[4]).toHaveClass('fc-fri');46 expect(daysOfWeek[5]).toHaveClass('fc-sat');47 expect(daysOfWeek[6]).toHaveClass('fc-sun');48 });49 });50 describe('when setting firstDay to 2', function() {51 beforeEach(function() {52 var options = {53 firstDay: 254 };55 $('#cal').fullCalendar(options);56 });57 it('should make Tuesday the first day of the week', function() {58 var daysOfWeek = $('.fc-day-header');59 expect(daysOfWeek[0]).toHaveClass('fc-tue');60 expect(daysOfWeek[1]).toHaveClass('fc-wed');61 expect(daysOfWeek[2]).toHaveClass('fc-thu');62 expect(daysOfWeek[3]).toHaveClass('fc-fri');63 expect(daysOfWeek[4]).toHaveClass('fc-sat');64 expect(daysOfWeek[5]).toHaveClass('fc-sun');65 expect(daysOfWeek[6]).toHaveClass('fc-mon');66 });67 });68 describe('when setting firstDay to 3', function() {69 beforeEach(function() {70 var options = {71 firstDay: 372 };73 $('#cal').fullCalendar(options);74 });75 it('should make Wednesday the first day of the week', function() {76 var daysOfWeek = $('.fc-day-header');77 expect(daysOfWeek[0]).toHaveClass('fc-wed');78 expect(daysOfWeek[1]).toHaveClass('fc-thu');79 expect(daysOfWeek[2]).toHaveClass('fc-fri');80 expect(daysOfWeek[3]).toHaveClass('fc-sat');81 expect(daysOfWeek[4]).toHaveClass('fc-sun');82 expect(daysOfWeek[5]).toHaveClass('fc-mon');83 expect(daysOfWeek[6]).toHaveClass('fc-tue');84 });85 });86 describe('when setting firstDay to 4', function() {87 beforeEach(function() {88 var options = {89 firstDay: 490 };91 $('#cal').fullCalendar(options);92 });93 it('should make Thursday the first day of the week', function() {94 var daysOfWeek = $('.fc-day-header');95 expect(daysOfWeek[0]).toHaveClass('fc-thu');96 expect(daysOfWeek[1]).toHaveClass('fc-fri');97 expect(daysOfWeek[2]).toHaveClass('fc-sat');98 expect(daysOfWeek[3]).toHaveClass('fc-sun');99 expect(daysOfWeek[4]).toHaveClass('fc-mon');100 expect(daysOfWeek[5]).toHaveClass('fc-tue');101 expect(daysOfWeek[6]).toHaveClass('fc-wed');102 });103 });104 describe('when setting firstDay to 5', function() {105 beforeEach(function() {106 var options = {107 firstDay: 5108 };109 $('#cal').fullCalendar(options);110 });111 it('should make Friday the first day of the week', function() {112 var daysOfWeek = $('.fc-day-header');113 expect(daysOfWeek[0]).toHaveClass('fc-fri');114 expect(daysOfWeek[1]).toHaveClass('fc-sat');115 expect(daysOfWeek[2]).toHaveClass('fc-sun');116 expect(daysOfWeek[3]).toHaveClass('fc-mon');117 expect(daysOfWeek[4]).toHaveClass('fc-tue');118 expect(daysOfWeek[5]).toHaveClass('fc-wed');119 expect(daysOfWeek[6]).toHaveClass('fc-thu');120 });121 });122 describe('when setting firstDay to 6', function() {123 beforeEach(function() {124 var options = {125 firstDay: 6126 };127 $('#cal').fullCalendar(options);128 });129 it('should make Saturday the first day of the week', function() {130 var daysOfWeek = $('.fc-day-header');131 expect(daysOfWeek[0]).toHaveClass('fc-sat');132 expect(daysOfWeek[1]).toHaveClass('fc-sun');133 expect(daysOfWeek[2]).toHaveClass('fc-mon');134 expect(daysOfWeek[3]).toHaveClass('fc-tue');135 expect(daysOfWeek[4]).toHaveClass('fc-wed');136 expect(daysOfWeek[5]).toHaveClass('fc-thu');137 expect(daysOfWeek[6]).toHaveClass('fc-fri');138 });139 });140 describe('when new firstDay options are set', function() {141 it('should change the first day of week to Monday', function() {142 $('#cal').fullCalendar({143 firstDay: 1144 });145 expect($('.fc-day-header')[0]).toHaveClass('fc-mon');146 });147 it('shoule change the first day of week to Thursday', function() {148 $('#cal').fullCalendar({149 firstDay: 4150 });151 expect($('.fc-day-header')[0]).toHaveClass('fc-thu');152 });153 });154 describe('when first day is set to Tuesday and isRTL is true', function() {155 beforeEach(function() {156 var options = {157 firstDay: 2,158 isRTL: true159 };160 $('#cal').fullCalendar(options);161 });162 it('should put days mon, sun, sat ...', function() {163 var daysOfWeek = $('.fc-day-header');164 expect(daysOfWeek[0]).toHaveClass('fc-mon');165 expect(daysOfWeek[1]).toHaveClass('fc-sun');166 expect(daysOfWeek[2]).toHaveClass('fc-sat');167 expect(daysOfWeek[3]).toHaveClass('fc-fri');168 expect(daysOfWeek[4]).toHaveClass('fc-thu');169 expect(daysOfWeek[5]).toHaveClass('fc-wed');170 expect(daysOfWeek[6]).toHaveClass('fc-tue');171 });172 });173 it('should have a different default value based on the language', function() {174 $('#cal').fullCalendar({175 lang: 'en-gb'176 });177 // firstDay will be 1 (Monday) in Great Britain178 var daysOfWeek = $('.fc-day-header');179 expect(daysOfWeek[0]).toHaveClass('fc-mon');180 expect(daysOfWeek[1]).toHaveClass('fc-tue');181 expect(daysOfWeek[2]).toHaveClass('fc-wed');182 expect(daysOfWeek[3]).toHaveClass('fc-thu');183 expect(daysOfWeek[4]).toHaveClass('fc-fri');184 expect(daysOfWeek[5]).toHaveClass('fc-sat');185 expect(daysOfWeek[6]).toHaveClass('fc-sun');186 });...
class.spec.js
Source: class.spec.js
...3describe('vdom class module', () => {4 it('should create an element with staticClass', () => {5 const vnode = new VNode('p', { staticClass: 'class1' })6 const elm = patch(null, vnode)7 expect(elm).toHaveClass('class1')8 })9 it('should create an element with class', () => {10 const vnode = new VNode('p', { class: 'class1' })11 const elm = patch(null, vnode)12 expect(elm).toHaveClass('class1')13 })14 it('should create an element with array class', () => {15 const vnode = new VNode('p', { class: ['class1', 'class2'] })16 const elm = patch(null, vnode)17 expect(elm).toHaveClass('class1')18 expect(elm).toHaveClass('class2')19 })20 it('should create an element with object class', () => {21 const vnode = new VNode('p', {22 class: { class1: true, class2: false, class3: true }23 })24 const elm = patch(null, vnode)25 expect(elm).toHaveClass('class1')26 expect(elm).not.toHaveClass('class2')27 expect(elm).toHaveClass('class3')28 })29 it('should create an element with mixed class', () => {30 const vnode = new VNode('p', {31 class: [{ class1: false, class2: true, class3: false }, 'class4', ['class5', 'class6']]32 })33 const elm = patch(null, vnode)34 expect(elm).not.toHaveClass('class1')35 expect(elm).toHaveClass('class2')36 expect(elm).not.toHaveClass('class3')37 expect(elm).toHaveClass('class4')38 expect(elm).toHaveClass('class5')39 expect(elm).toHaveClass('class6')40 })41 it('should create an element with staticClass and class', () => {42 const vnode = new VNode('p', { staticClass: 'class1', class: 'class2' })43 const elm = patch(null, vnode)44 expect(elm).toHaveClass('class1')45 expect(elm).toHaveClass('class2')46 })47 it('should handle transition class', () => {48 const vnode1 = new VNode('p', {49 class: { class1: true, class2: false, class3: true }50 })51 let elm = patch(null, vnode1)52 elm._transitionClasses = ['class4']53 const vnode2 = new VNode('p', {54 class: { class1: true, class2: true, class3: true }55 })56 elm = patch(vnode1, vnode2)57 expect(elm).toHaveClass('class1')58 expect(elm).toHaveClass('class2')59 expect(elm).toHaveClass('class3')60 expect(elm).toHaveClass('class4')61 })62 it('should change the elements class', () => {63 const vnode1 = new VNode('p', {64 class: { class1: true, class2: false, class3: true }65 })66 const vnode2 = new VNode('p', { staticClass: 'foo bar' })67 let elm = patch(null, vnode1)68 elm = patch(vnode1, vnode2)69 expect(elm).not.toHaveClass('class1')70 expect(elm).not.toHaveClass('class2')71 expect(elm).not.toHaveClass('class3')72 expect(elm).toHaveClass('foo')73 expect(elm).toHaveClass('bar')74 })75 it('should remove the elements class', () => {76 const vnode1 = new VNode('p', {77 class: { class1: true, class2: false, class3: true }78 })79 const vnode2 = new VNode('p', { class: {}})80 let elm = patch(null, vnode1)81 elm = patch(vnode1, vnode2)82 expect(elm).not.toHaveClass('class1')83 expect(elm).not.toHaveClass('class2')84 expect(elm).not.toHaveClass('class3')85 })86 it('should remove class for new nodes without class data', () => {87 const vnode1 = new VNode('p', {88 class: { class1: true, class2: false, class3: true }89 })90 const vnode2 = new VNode('p', {})91 let elm = patch(null, vnode1)92 elm = patch(vnode1, vnode2)93 expect(elm).not.toHaveClass('class1')94 expect(elm).not.toHaveClass('class2')95 expect(elm).not.toHaveClass('class3')96 })...
agenda-view.js
Source: agenda-view.js
...10 });11 });12 it('should have have days ordered sun to sat', function() {13 var fc = $('#cal').find('.fc-view > table > thead th');14 expect(fc[0]).toHaveClass('fc-axis');15 expect(fc[1]).toHaveClass('fc-sun');16 expect(fc[2]).toHaveClass('fc-mon');17 expect(fc[3]).toHaveClass('fc-tue');18 expect(fc[4]).toHaveClass('fc-wed');19 expect(fc[5]).toHaveClass('fc-thu');20 expect(fc[6]).toHaveClass('fc-fri');21 expect(fc[7]).toHaveClass('fc-sat');22 });23 });24 describe('when isRTL is true', function() {25 beforeEach(function() {26 $('#cal').fullCalendar({27 defaultView: 'agendaWeek',28 isRTL: true29 });30 });31 it('should have have days ordered sat to sun', function() {32 var fc = $('#cal').find('.fc-view > table > thead th');33 expect(fc[0]).toHaveClass('fc-sat');34 expect(fc[1]).toHaveClass('fc-fri');35 expect(fc[2]).toHaveClass('fc-thu');36 expect(fc[3]).toHaveClass('fc-wed');37 expect(fc[4]).toHaveClass('fc-tue');38 expect(fc[5]).toHaveClass('fc-mon');39 expect(fc[6]).toHaveClass('fc-sun');40 expect(fc[7]).toHaveClass('fc-axis');41 });42 });...
basic-view.js
Source: basic-view.js
...10 });11 });12 it('should have have days ordered sun to sat', function() {13 var fc = $('#cal').find('.fc-day-header');14 expect(fc[0]).toHaveClass('fc-sun');15 expect(fc[1]).toHaveClass('fc-mon');16 expect(fc[2]).toHaveClass('fc-tue');17 expect(fc[3]).toHaveClass('fc-wed');18 expect(fc[4]).toHaveClass('fc-thu');19 expect(fc[5]).toHaveClass('fc-fri');20 expect(fc[6]).toHaveClass('fc-sat');21 });22 });23 describe('when isRTL is true', function() {24 beforeEach(function() {25 $('#cal').fullCalendar({26 defaultView: 'month',27 isRTL: true28 });29 });30 it('should have have days ordered sat to sun', function() {31 var fc = $('#cal').find('.fc-day-header');32 expect(fc[0]).toHaveClass('fc-sat');33 expect(fc[1]).toHaveClass('fc-fri');34 expect(fc[2]).toHaveClass('fc-thu');35 expect(fc[3]).toHaveClass('fc-wed');36 expect(fc[4]).toHaveClass('fc-tue');37 expect(fc[5]).toHaveClass('fc-mon');38 expect(fc[6]).toHaveClass('fc-sun');39 });40 });...
Using AI Code Generation
1const { test, expect } = require('@playwright/test');2test('should have class', async ({ page }) => {3 const element = await page.$('text=Get started');4 expect(element).toHaveClass('navbar__item');5});6const { test, expect } = require('@playwright/test');7test('should have class', async ({ page }) => {8 const element = await page.$('text=Get started');9 await expect(element).toHaveClass('navbar__item');10});11const { test, expect } = require('@playwright/test');12test('should have class', async ({ page }) => {13 const element = await page.$('text=Get started');14 expect(element).toHaveClass(['navbar__item', 'navbar__item--get-started']);15});16const { test, expect } = require('@playwright/test');17test('should have class', async ({ page }) => {18 const element = await page.$('text=Get started');19 await expect(element).toHaveClass(['navbar__item', 'navbar__item--get-started']);20});21const { test, expect } = require('@playwright/test');22test('should have class', async ({ page }) => {23 const element = await page.$('text=Get started');24 expect(element).toHaveClass(['navbar__item', /navbar__item--get/]);25});26const { test, expect } = require('@playwright/test');27test('should have class', async ({ page }) => {28 const element = await page.$('text=Get started');29 await expect(element).toHaveClass(['navbar__item', /navbar__item--get/]);30});
Using AI Code Generation
1const { test, expect } = require('@playwright/test');2test('should have class', async ({ page }) => {3 const selector = 'text=Get started';4 const element = await page.waitForSelector(selector);5 expect(element).toHaveClass('navbar__inner');6});7 7 | const element = await page.waitForSelector(selector);8 8 | expect(element).toHaveClass('navbar__inner');9 > 9 | });10const { test, expect } = require('@playwright/test');11test('should have class', async ({ page }) => {12 const selector = 'text=Get started';13 const element = await page.waitForSelector(selector);14 expect(await element.getAttribute('class')).toBe('navbar__inner');15});16const { test, expect } = require('@playwright/test');17test('should have class', async ({ page }) => {18 const selector = 'text=Get started';19 const element = await page.waitForSelector(selector);20 expect(element).toContainClass('navbar__inner');21});22const { test, expect } = require('@playwright/test');23test('should have class',
Jest + Playwright - Test callbacks of event-based DOM library
firefox browser does not start in playwright
Is it possible to get the selector from a locator object in playwright?
How to run a list of test suites in a single file concurrently in jest?
Running Playwright in Azure Function
firefox browser does not start in playwright
This question is quite close to a "need more focus" question. But let's try to give it some focus:
Does Playwright has access to the cPicker object on the page? Does it has access to the window object?
Yes, you can access both cPicker and the window object inside an evaluate call.
Should I trigger the events from the HTML file itself, and in the callbacks, print in the DOM the result, in some dummy-element, and then infer from that dummy element text that the callbacks fired?
Exactly, or you can assign values to a javascript variable:
const cPicker = new ColorPicker({
onClickOutside(e){
},
onInput(color){
window['color'] = color;
},
onChange(color){
window['result'] = color;
}
})
And then
it('Should call all callbacks with correct arguments', async() => {
await page.goto(`http://localhost:5000/tests/visual/basic.html`, {waitUntil:'load'})
// Wait until the next frame
await page.evaluate(() => new Promise(requestAnimationFrame))
// Act
// Assert
const result = await page.evaluate(() => window['color']);
// Check the value
})
Check out the latest blogs from LambdaTest on this topic:
Native apps are developed specifically for one platform. Hence they are fast and deliver superior performance. They can be downloaded from various app stores and are not accessible through browsers.
One of the essential parts when performing automated UI testing, whether using Selenium or another framework, is identifying the correct web elements the tests will interact with. However, if the web elements are not located correctly, you might get NoSuchElementException in Selenium. This would cause a false negative result because we won’t get to the actual functionality check. Instead, our test will fail simply because it failed to interact with the correct element.
Smartphones have changed the way humans interact with technology. Be it travel, fitness, lifestyle, video games, or even services, it’s all just a few touches away (quite literally so). We only need to look at the growing throngs of smartphone or tablet users vs. desktop users to grasp this reality.
As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.
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!!