Best JavaScript code snippet using playwright-internal
player.spec.js
Source:player.spec.js
...75 start() {},76 end() {}77 }78 };79 deepFreeze(stateBefore);80 deepFreeze(action);81 const stateResult = player(stateBefore, action);82 expect(stateResult.buffered.length).toEqual(stateAfter.buffered.length);83 });84 it('should handle CAN_PLAY action', () => {85 const stateBefore = {86 waiting: true,87 videoWidth: 0,88 videoHeight: 0,89 duration: 090 };91 const action = {92 type: CAN_PLAY,93 videoProps: {94 videoWidth: 1080,95 videoHeight: 1920,96 duration: 52.20997 }98 };99 const stateAfter = {100 waiting: false,101 videoWidth: 1080,102 videoHeight: 1920,103 duration: 52.209104 };105 deepFreeze(stateBefore);106 deepFreeze(action);107 expect(player(stateBefore, action)).toEqual(stateAfter);108 });109 it('should handle WAITING action with FALSE', () => {110 const stateBefore = {111 waiting: false112 };113 const action = {114 type: WAITING115 };116 const stateAfter = {117 waiting: true118 };119 deepFreeze(stateBefore);120 deepFreeze(action);121 expect(player(stateBefore, action)).toEqual(stateAfter);122 });123 it('should handle WAITING action with WAITING true', () => {124 const stateBefore = {125 waiting: true126 };127 const action = {128 type: WAITING129 };130 const stateAfter = {131 waiting: true132 };133 deepFreeze(stateBefore);134 deepFreeze(action);135 expect(player(stateBefore, action)).toEqual(stateAfter);136 });137 it('should handle PLAYING action with WAITING false', () => {138 const stateBefore = {139 waiting: false140 };141 const action = {142 type: PLAYING143 };144 const stateAfter = {145 waiting: false146 };147 deepFreeze(stateBefore);148 deepFreeze(action);149 expect(player(stateBefore, action)).toEqual(stateAfter);150 });151 it('should handle PLAYING action with WAITING true', () => {152 const stateBefore = {153 waiting: true154 };155 const action = {156 type: PLAYING157 };158 const stateAfter = {159 waiting: false160 };161 deepFreeze(stateBefore);162 deepFreeze(action);163 expect(player(stateBefore, action)).toEqual(stateAfter);164 });165 it('should handle PLAY action', () => {166 const stateBefore = {167 ended: false,168 paused: false,169 autoPaused: false,170 waiting: false,171 hasStarted: true,172 duration: 0173 };174 const action = {175 type: PLAY,176 videoProps: {177 duration: 52.209178 }179 };180 const stateAfter = {181 ended: false,182 paused: false,183 autoPaused: false,184 waiting: false,185 hasStarted: true,186 duration: 52.209187 };188 deepFreeze(stateBefore);189 deepFreeze(action);190 expect(player(stateBefore, action)).toEqual(stateAfter);191 });192 it('should handle PAUSE action', () => {193 const stateBefore = {194 paused: false195 };196 const action = {197 type: PAUSE198 };199 const stateAfter = {200 paused: true201 };202 deepFreeze(stateBefore);203 deepFreeze(action);204 expect(player(stateBefore, action)).toEqual(stateAfter);205 });206 it('should handle END action', () => {207 const stateBefore = {208 ended: false209 };210 const action = {211 type: END212 };213 const stateAfter = {214 ended: true215 };216 deepFreeze(stateBefore);217 deepFreeze(action);218 expect(player(stateBefore, action)).toEqual(stateAfter);219 });220 it('should handle SEEKING action', () => {221 const stateBefore = {222 seeking: false223 };224 const action = {225 type: SEEKING226 };227 const stateAfter = {228 seeking: true229 };230 deepFreeze(stateBefore);231 deepFreeze(action);232 expect(player(stateBefore, action)).toEqual(stateAfter);233 });234 it('should handle SEEKED action', () => {235 const stateBefore = {236 seeking: false237 };238 const action = {239 type: SEEKED240 };241 const stateAfter = {242 seeking: false243 };244 deepFreeze(stateBefore);245 deepFreeze(action);246 expect(player(stateBefore, action)).toEqual(stateAfter);247 });248 it('should handle SEEKING_TIME action', () => {249 const stateBefore = {250 seekingTime: 12251 };252 const action = {253 type: SEEKING_TIME,254 time: 12255 };256 const stateAfter = {257 seekingTime: 12258 };259 deepFreeze(stateBefore);260 deepFreeze(action);261 expect(player(stateBefore, action)).toEqual(stateAfter);262 });263 it('should handle END_SEEKING action', () => {264 const stateBefore = {265 seekingTime: 1266 };267 const action = {268 type: END_SEEKING,269 time: 1270 };271 const stateAfter = {272 seekingTime: 0273 };274 deepFreeze(stateBefore);275 deepFreeze(action);276 expect(player(stateBefore, action)).toEqual(stateAfter);277 });278 it('should handle DURATION_CHANGE action', () => {279 const stateBefore = {280 duration: 0281 };282 const action = {283 type: DURATION_CHANGE,284 videoProps: {285 duration: 23286 }287 };288 const stateAfter = {289 duration: 23290 };291 deepFreeze(stateBefore);292 deepFreeze(action);293 expect(player(stateBefore, action)).toEqual(stateAfter);294 });295 it('should handle TIME_UPDATE action', () => {296 const stateBefore = {297 currentTime: 49.11298 };299 const action = {300 type: TIME_UPDATE,301 videoProps: {302 currentTime: 12.01303 }304 };305 const stateAfter = {306 currentTime: 12.01307 };308 deepFreeze(stateBefore);309 deepFreeze(action);310 expect(player(stateBefore, action)).toEqual(stateAfter);311 });312 it('should handle VOLUME_CHANGE action', () => {313 const stateBefore = {314 volume: 0.99,315 muted: true316 };317 const action = {318 type: VOLUME_CHANGE,319 videoProps: {320 volume: 0.62,321 muted: false322 }323 };324 const stateAfter = {325 volume: 0.62,326 muted: false327 };328 deepFreeze(stateBefore);329 deepFreeze(action);330 expect(player(stateBefore, action)).toEqual(stateAfter);331 });332 it('should handle PROGRESS_CHANGE action', () => {333 const bufferThree = {334 length: 3,335 start() {},336 end() {}337 };338 const stateBefore = {339 buffered: {340 length: 1,341 start() {},342 end() {}343 }344 };345 const action = {346 type: PROGRESS_CHANGE,347 videoProps: {348 buffered: bufferThree349 }350 };351 const stateAfter = {352 buffered: bufferThree353 };354 deepFreeze(stateBefore);355 deepFreeze(action);356 const stateResult = player(stateBefore, action);357 expect(stateResult.buffered.length).toEqual(stateAfter.buffered.length);358 });359 it('should handle RATE_CHANGE action', () => {360 const stateBefore = {361 playbackRate: 1362 };363 const action = {364 type: RATE_CHANGE,365 videoProps: {366 playbackRate: 1.1367 }368 };369 const stateAfter = {370 playbackRate: 1.1371 };372 deepFreeze(stateBefore);373 deepFreeze(action);374 expect(player(stateBefore, action)).toEqual(stateAfter);375 });376 it('should handle FULLSCREEN_CHANGE action', () => {377 const stateBefore = {378 isFullscreen: false379 };380 const action = {381 type: FULLSCREEN_CHANGE,382 isFullscreen: true383 };384 const stateAfter = {385 isFullscreen: true386 };387 deepFreeze(stateBefore);388 deepFreeze(action);389 expect(player(stateBefore, action)).toEqual(stateAfter);390 });391 it('should handle USER_ACTIVATE action', () => {392 const stateBefore = {393 userActivity: false394 };395 const action = {396 type: USER_ACTIVATE,397 activity: true398 };399 const stateAfter = {400 userActivity: true401 };402 deepFreeze(stateBefore);403 deepFreeze(action);404 expect(player(stateBefore, action)).toEqual(stateAfter);405 });406 it('should handle PLAYER_ACTIVATE action', () => {407 const stateBefore = {408 isActive: true409 };410 const action = {411 type: PLAYER_ACTIVATE,412 activity: false413 };414 const stateAfter = {415 isActive: false416 };417 deepFreeze(stateBefore);418 deepFreeze(action);419 expect(player(stateBefore, action)).toEqual(stateAfter);420 });...
deepfreeze_test.js
Source:deepfreeze_test.js
...18 'e': null,19 'f': 5,20 'g': undefined,21 };22 const f = deepFreeze(a);23 assertEquals('c', f.b);24 assertTrue(f.c);25 assertFalse(f.d);26 assertNull(f.e);27 assertEquals(5, f.f);28 assertTrue(f.hasOwnProperty('g'));29 assertThrows(() => {30 f.e = 5;31 });32 assertThrows(() => {33 console.log(a.e);34 });35 assertEquals('c', f.b);36 assertTrue(f.c);37 assertFalse(f.d);38 assertNull(f.e);39 assertEquals(5, f.f);40 },41 testObjectWithArray() {42 const a = {43 'b': 'c',44 'c': ['d', 'e', 'f'],45 };46 const f = deepFreeze(a);47 assertEquals('c', f.b);48 assertEquals('d', f.c[0]);49 assertEquals('e', f.c[1]);50 assertEquals('f', f.c[2]);51 asserts.assertArray(f.c);52 assertThrows(() => {53 f.c = 'hello world!';54 });55 assertThrows(() => {56 console.log(a.c);57 });58 assertEquals('c', f.b);59 assertEquals('d', f.c[0]);60 assertEquals('e', f.c[1]);61 assertEquals('f', f.c[2]);62 },63 testObjectWithChildObjects() {64 const a = {65 'c': {66 'd': 'e',67 'r': 'f',68 },69 };70 const f = deepFreeze(a);71 assertEquals('e', f.c.d);72 assertEquals('f', f.c.r);73 assertThrows(() => {74 f.c.r = 10;75 });76 assertThrows(() => {77 f.c = {};78 });79 assertThrows(() => {80 console.log(a.c);81 });82 assertThrows(() => {83 a.c = {};84 });85 assertEquals('e', f.c.d);86 assertEquals('f', f.c.r);87 },88 /**89 @suppress {missingProperties} suppression added to enable type checking90 */91 testObjectWithChildMultipath() {92 const a = {93 'c': {94 'd': 'e',95 'r': 'f',96 },97 };98 const d = {'a': 'b'};99 // Create two ways to access object d. This should not throw when frozen,100 // and both paths to this same object should throw.101 a.c['g'] = d;102 a.c['h'] = d;103 const f = deepFreeze(a);104 assertEquals('e', f.c.d);105 assertEquals('f', f.c.r);106 assertEquals('b', f.c.g.a);107 assertEquals('b', f.c.h.a);108 assertThrows(() => {109 f.c.r = 10;110 });111 assertThrows(() => {112 f.c = {};113 });114 assertThrows(() => {115 console.log(a.c);116 });117 assertThrows(() => {118 /**119 * @suppress {missingProperties} suppression added to enable type120 * checking121 */122 f.c.g.a = 'c';123 });124 assertThrows(() => {125 /**126 * @suppress {missingProperties} suppression added to enable type127 * checking128 */129 f.c.h.a = 'c';130 });131 assertThrows(() => {132 a.c = {};133 });134 assertEquals('e', f.c.d);135 assertEquals('f', f.c.r);136 },137 testObjectWithSymbolKeys() {138 const s = Symbol(5);139 const a = {};140 a[s] = 'hello world';141 const f = deepFreeze(a);142 assertEquals('hello world', f[s]);143 // The below check would be an assertThrows, but the Symbol polyfill for144 // IE doesn't throw when changing a frozen symbol key's value.145 try {146 f[s] = 'new thing!';147 } catch (expectedInStrictMode) {148 }149 assertEquals('hello world', f[s]);150 assertThrows(() => {151 console.log(a[s]);152 });153 },154 /** @suppress {checkTypes} suppression added to enable type checking */155 testObjectWithSymbolValues() {156 const s = Symbol(5);157 if (s instanceof Object) {158 // The below test doesn't work in IE as the Symbol polyfill is detected159 // to be an object that is not an object literal.160 // TODO(user): run this test on IE.161 return;162 }163 const a = {164 's': s,165 };166 const f = deepFreeze(a);167 assertEquals(s, f.s);168 assertThrows(() => {169 f.s = Symbol(10);170 });171 assertThrows(() => {172 console.log(a.s);173 });174 assertEquals(s, f.s);175 },176 testArray() {177 const a = new Array(5);178 a[2] = 5;179 const f = deepFreeze(a);180 assertEquals(a.length, f.length);181 assertEquals(5, f[2]);182 asserts.assertArray(f);183 assertThrows(() => {184 f[2] = 'hello world!';185 });186 assertThrows(() => {187 console.log(a[2]);188 });189 },190 testFailsWithFunctions() {191 assertThrows(() => {192 deepFreeze(function() {193 console.log('');194 });195 });196 },197 testFailsWithFunctionInObject() {198 assertThrows(() => {199 deepFreeze({200 a: function() {201 console.log('');202 },203 });204 });205 },206 testFailsWithClasses() {207 assertThrows(() => {208 class C {209 hello() {210 console.log('Hello');211 }212 }213 const b = new C();214 deepFreeze(b);215 });216 },217 testFailsWithClassInObject() {218 assertThrows(() => {219 class C {220 hello() {221 console.log('Hello');222 }223 }224 const b = new C();225 deepFreeze({226 'b': b,227 });228 });229 },230 testFailsWithClassDefinition() {231 assertThrows(() => {232 const b = class C {};233 deepFreeze(b);234 });235 },236 testFailsWithClassDefinitionInObject() {237 assertThrows(() => {238 const b = class C {};239 deepFreeze({240 'b': b,241 });242 });243 },244 testFailsWithGetters() {245 assertThrows(() => {246 deepFreeze({247 get aThing() {248 return 5;249 },250 });251 });252 },253 testFailsWithSetters() {254 assertThrows(() => {255 deepFreeze({256 a: 5,257 /**258 @suppress {undefinedVars} suppression added to enable type259 checking260 */261 set aThing(v) {262 a++;263 },264 });265 });266 },267 testFailsWithCyclicReferences() {268 const a = {b: {}};269 a.b.c = a;270 assertThrows(() => {271 deepFreeze(a);272 });273 },274 },...
index.spec.js
Source:index.spec.js
...20 counter: 1,21 childIds: []22 }23 }24 deepFreeze(stateBefore)25 deepFreeze(action)26 expect(reducer(stateBefore, action)).toEqual(stateAfter)27 })28 it('should handle CREATE_NODE action', () => {29 const stateBefore = {}30 const action = createNode()31 const stateAfter = {32 [action.nodeId]: {33 id: action.nodeId,34 counter: 0,35 childIds: []36 }37 }38 deepFreeze(stateBefore)39 deepFreeze(action)40 expect(reducer(stateBefore, action)).toEqual(stateAfter)41 })42 it('should handle DELETE_NODE action', () => {43 const stateBefore = {44 'node_0': {45 id: 'node_0',46 counter: 0,47 childIds: [ 'node_1' ]48 },49 'node_1': {50 id: 'node_1',51 counter: 0,52 childIds: []53 },54 'node_2': {55 id: 'node_2',56 counter: 0,57 childIds: [ 'node_3', 'node_4' ]58 },59 'node_3': {60 id: 'node_3',61 counter: 0,62 childIds: []63 },64 'node_4': {65 id: 'node_4',66 counter: 0,67 childIds: []68 }69 }70 const action = deleteNode('node_2')71 const stateAfter = {72 'node_0': {73 id: 'node_0',74 counter: 0,75 childIds: [ 'node_1' ]76 },77 'node_1': {78 id: 'node_1',79 counter: 0,80 childIds: []81 }82 }83 deepFreeze(stateBefore)84 deepFreeze(action)85 expect(reducer(stateBefore, action)).toEqual(stateAfter)86 })87 it('should handle ADD_CHILD action', () => {88 const stateBefore = {89 'node_0': {90 id: 'node_0',91 counter: 0,92 childIds: []93 },94 'node_1': {95 id: 'node_1',96 counter: 0,97 childIds: []98 }99 }100 const action = addChild('node_0', 'node_1')101 const stateAfter = {102 'node_0': {103 id: 'node_0',104 counter: 0,105 childIds: [ 'node_1' ]106 },107 'node_1': {108 id: 'node_1',109 counter: 0,110 childIds: []111 }112 }113 deepFreeze(stateBefore)114 deepFreeze(action)115 expect(reducer(stateBefore, action)).toEqual(stateAfter)116 })117 it('should handle REMOVE_CHILD action', () => {118 const stateBefore = {119 'node_0': {120 id: 'node_0',121 counter: 0,122 childIds: [ 'node_1' ]123 },124 'node_1': {125 id: 'node_1',126 counter: 0,127 childIds: []128 }129 }130 const action = removeChild('node_0', 'node_1')131 const stateAfter = {132 'node_0': {133 id: 'node_0',134 counter: 0,135 childIds: []136 },137 'node_1': {138 id: 'node_1',139 counter: 0,140 childIds: []141 }142 }143 deepFreeze(stateBefore)144 deepFreeze(action)145 expect(reducer(stateBefore, action)).toEqual(stateAfter)146 })...
counters.test.js
Source:counters.test.js
...6it('counters should be a function', () => {7 expect(counters).to.be.a('function')8})9it('Should add a new counter', () => {10 const before = deepFreeze([])11 const action = deepFreeze({ type: ADD_COUNTER })12 const after = [0]13 expect(counters(before, action)).to.be.deep.equal(after)14})15it('Should add a new counter again', () => {16 const before = deepFreeze([0, 1])17 const action = deepFreeze({ type: ADD_COUNTER })18 const after = [0, 1, 0]19 expect(counters(before, action)).to.be.deep.equal(after)20})21it('Should remove a counter', () => {22 const before = deepFreeze([0, 1, 2])23 const action = deepFreeze({ type: REMOVE_COUNTER, index: 1 })24 const after = [0, 2]25 expect(counters(before, action)).to.be.deep.equal(after)26})27it('Should remove a counter again', () => {28 const before = deepFreeze([3, 1])29 const action = deepFreeze({ type: REMOVE_COUNTER, index: 0 })30 const after = [1]31 expect(counters(before, action)).to.be.deep.equal(after)32})33it('Should increment a counter', () => {34 const before = deepFreeze([0, 0])35 const action = deepFreeze({ type: INCREMENT, index: 0 })36 const after = [1, 0]37 expect(counters(before, action)).to.be.deep.equal(after)38})39it('Should increment an other counter', () => {40 const before = deepFreeze([1, 0])41 const action = deepFreeze({ type: INCREMENT, index: 1 })42 const after = [1, 1]43 expect(counters(before, action)).to.be.deep.equal(after)44})45it('Should decrement a counter', () => {46 const before = deepFreeze([0, 2, 1])47 const action = deepFreeze({ type: DECREMENT, index: 2 })48 const after = [0, 2, 0]49 expect(counters(before, action)).to.be.deep.equal(after)50})51it('Should decrement an other counter', () => {52 const before = deepFreeze([0, 2, 0])53 const action = deepFreeze({ type: DECREMENT, index: 1 })54 const after = [0, 1, 0]55 expect(counters(before, action)).to.be.deep.equal(after)56})57it('Should return same state if action is unknown', () => {58 const before = deepFreeze([0, 0, 1])59 const action = deepFreeze({ type: 'UNKNOWN' })60 const after = [0, 0, 1]61 expect(counters(before, action)).to.be.deep.equal(after)62})63it('Should return initial state if last state is undefined', () => {64 const before = undefined65 const action = deepFreeze({})66 const after = initialState67 expect(counters(before, action)).to.be.deep.equal(after)...
todos.test.js
Source:todos.test.js
...6it('should todos be a function', () => {7 expect(todos).to.be.a('function')8})9it('should add a todo item', () => {10 const before = deepFreeze([])11 const action = deepFreeze({12 type: ADD_TODO,13 payload: { id: 0, text: 'Hey' }14 })15 const after = [{ id: 0, text: 'Hey', completed: false }]16 expect(todos(before, action)).to.be.deep.equal(after)17})18it('should add a new todo item', () => {19 const before = deepFreeze([20 { id: 0, text: 'Hey', completed: false }21 ])22 const action = deepFreeze({23 type: ADD_TODO,24 payload: { id: 1, text: 'Ho' }25 })26 const after = [27 { id: 0, text: 'Hey', completed: false },28 { id: 1, text: 'Ho', completed: false }29 ]30 expect(todos(before, action)).to.be.deep.equal(after)31})32it('should toggle first todo', () => {33 const before = deepFreeze([34 { id: 0, text: 'Hey', completed: false },35 { id: 1, text: 'Ho', completed: false }36 ])37 const action = deepFreeze({38 type: TOGGLE_TODO,39 payload: { id: 0}40 })41 const after = [42 { id: 0, text: 'Hey', completed: true },43 { id: 1, text: 'Ho', completed: false }44 ]45 expect(todos(before, action)).to.be.deep.equal(after)46})47it('should toggle second todo', () => {48 const before = deepFreeze([49 { id: 0, text: 'Hey', completed: false },50 { id: 1, text: 'Ho', completed: false }51 ])52 const action = deepFreeze({53 type: TOGGLE_TODO,54 payload: { id: 1}55 })56 const after = [57 { id: 0, text: 'Hey', completed: false },58 { id: 1, text: 'Ho', completed: true }59 ]60 expect(todos(before, action)).to.be.deep.equal(after)61})62it('should return the latest state when action is unknown', () => {63 const before = deepFreeze([{ id: 0, text: 'Hey', completed: false }])64 const action = deepFreeze({ type: 'ANYTHING' })65 const after = [{ id: 0, text: 'Hey', completed: false }]66 expect(todos(before, action)).to.be.deep.equal(after)67})68it('should return initialState when before is undefined', () => {69 const before = undefined70 const action = deepFreeze({})71 const after = initialState72 expect(todos(before, action)).to.be.deep.equal(after)...
projects.test.js
Source:projects.test.js
...12 const data1 = {id: 12, name: 'a'};13 const data2 = {id: 13, name: 'b'};14 const action = {type: GET_PROJECTS, payload: {data: [data1, data2]}};15 const state = {};16 deepFreeze(state);17 deepFreeze(action);18 expect(reduce(state, action)).toMatchSnapshot();19 });20 it('handles action of type SET_PROJECT_CLOAKED', () => {21 const action = {type: SET_PROJECT_CLOAKED, payload: {data: {id: 12, cloaked: true}}};22 const state = {12: {id: 12, cloaked: false}};23 deepFreeze(state);24 deepFreeze(action);25 expect(reduce(state, action)).toMatchSnapshot();26 });27 it('handles action of type UPDATE_PROJECT', () => {28 const action = {type: UPDATE_PROJECT, payload: {data: {id: 13, name: 'Bob'}}};29 const state = {13: {id: 13, name: 'Foo'}};30 deepFreeze(state);31 deepFreeze(action);32 expect(reduce(state, action)).toMatchSnapshot();33 });34 it('handles action of type CREATE_PROJECT', () => {35 const action = {type: CREATE_PROJECT, payload: {data: {id: 14, name: 'Bob'}}};36 const state = {};37 deepFreeze(state);38 deepFreeze(action);39 expect(reduce(state, action)).toMatchSnapshot();40 });41 it('handles action of type DELETE_PROJECT', () => {42 const action = {type: DELETE_PROJECT, payload: {data: {id: 15}}};43 const state = {15: {id: 15, name: 'bob'}};44 deepFreeze(state);45 deepFreeze(action);46 expect(reduce(state, action)).toEqual({});47 });...
reducer.test.js
Source:reducer.test.js
...10 const state = {}11 const action = {12 type: 'DO_NOTHING'13 }14 deepFreeze(state)15 const newState = counterReducer(undefined, action)16 expect(newState).toEqual(initialState)17 })18 test('good is incremented', () => {19 const action = {20 type: 'GOOD'21 }22 const state = initialState23 deepFreeze(state)24 const newState = counterReducer(state, action)25 expect(newState).toEqual({26 good: 1,27 ok: 0,28 bad: 029 })30 })31 test('ok is incremented', () => {32 const action = {33 type: 'OK'34 }35 const state = initialState36 deepFreeze(state)37 const newState = counterReducer(state, action)38 expect(newState).toEqual({39 good: 0,40 ok: 1,41 bad: 042 })43 })44 test('bad is incremented', () => {45 const action = {46 type: 'BAD'47 }48 const state = initialState49 deepFreeze(state)50 const newState = counterReducer(state, action)51 expect(newState).toEqual({52 good: 0,53 ok: 0,54 bad: 155 })56 })57 test('zero resets state to initial state', () => {58 const action = {59 type: 'ZERO'60 }61 const state = initialState62 deepFreeze(state)63 const newState = counterReducer(state, action)64 expect(newState).toEqual(initialState)65 })66 test('unknown action type returns state without modifying it', () => {67 const action = {68 type: 'OTHER'69 }70 const state = initialState71 deepFreeze(state)72 const newState = counterReducer(state, action)73 expect(newState).toEqual(initialState)74 })...
index.test.js
Source:index.test.js
...4 it('Initialize action', ()=>{5 const state = {};6 const action = { type: 'INITIALIZE' };7 const expected = { data: false, intro: false, vis: false };8 deepFreeze(state);9 deepFreeze(action);10 deepFreeze(expected);11 const res = AppReducer(state, action);12 expect(res.isLoading).toEqual(expected);13 });14 it('Set gender action', ()=>{15 const state = {};16 const action = {17 type: 'SET_GENDER',18 value: 'men'19 };20 deepFreeze(state);21 deepFreeze(action);22 const res = AppReducer(state, action);23 expect(res.gender.type).toEqual('men');24 });25 it('Set view change action', ()=>{26 const state = {27 isLoading: { data: false, intro: true, vis: false }28 };29 const action = { type: 'SET_VIEW_CHANGE', from: 'intro', to: 'vis'};30 const expected = { data: false, intro: false, vis: true };31 deepFreeze(state);32 deepFreeze(action);33 deepFreeze(expected);34 const res = AppReducer(state, action);35 expect(res.isLoading).toEqual(expected);36 });...
Using AI Code Generation
1const { deepFreeze } = require('@playwright/test/lib/utils/deep-freeze');2const obj = { a: { b: 1 } };3deepFreeze(obj);4obj.a.b = 2;5const { deepFreeze } = require('@playwright/test/lib/utils/deep-freeze');6const obj = { a: { b: 1 } };7deepFreeze(obj);8obj.a.b = 2;9const { deepFreeze } = require('@playwright/test/lib/utils/deep-freeze');10const obj = { a: { b: 1 } };11deepFreeze(obj);12obj.a.b = 2;13const { deepFreeze } = require('@playwright/test/lib/utils/deep-freeze');14const obj = { a: { b: 1 } };15deepFreeze(obj);16obj.a.b = 2;17const { deepFreeze } = require('@playwright/test/lib/utils/deep-freeze');18const obj = { a: { b: 1 } };19deepFreeze(obj);20obj.a.b = 2;21const { deepFreeze } = require('@playwright/test/lib/utils/deep-freeze');22const obj = { a: { b: 1 } };23deepFreeze(obj);24obj.a.b = 2;25const { deepFreeze } = require('@playwright/test/lib/utils/deep-freeze');26const obj = { a: { b: 1 } };27deepFreeze(obj);28obj.a.b = 2;29const { deepFreeze } = require('@playwright
Using AI Code Generation
1const { deepFreeze } = require('playwright-core/lib/server/dom.js');2const { deepFreeze } = require('playwright-core/lib/server/dom.js');3const obj = {4 c: {5 f: {6 },7 },8};9deepFreeze(obj);10obj.c.f.g = 10;11console.log(obj.c.f.g);12const { deepFreeze } = require('playwright-core/lib/server/dom.js');13const obj = {14 c: {15 f: {16 },17 },18};19deepFreeze(obj);20obj.c.f.g = 10;21console.log(obj.c.f.g);22const { deepFreeze } = require('playwright-core/lib/server/dom.js');23const obj = {24 c: {25 f: {26 },27 },28};29deepFreeze(obj);30obj.c.f.g = 10;31console.log(obj.c.f.g);32const { deepFreeze } = require('playwright-core/lib/server/dom.js');33const obj = {34 c: {35 f: {36 },37 },38};39deepFreeze(obj);40obj.c.f.g = 10;41console.log(obj.c.f.g);42const { deepFreeze } = require('playwright-core/lib/server/dom.js');43const obj = {
Using AI Code Generation
1const { deepFreeze } = require('playwright-core/lib/server/utils/stackTrace');2const { deepFreeze } = require('playwright-core/lib/utils/stackTrace');3const { deepFreeze } = require('playwright-core/lib/server/utils');4const { deepFreeze } = require('playwright-core/lib/utils');5const { deepFreeze } = require('playwright-core/lib/server');6const { deepFreeze } = require('playwright-core/lib');7const { deepFreeze } = require('playwright-core');8const { deepFreeze } = require('playwright-core');9const { deepFreeze } = require('playwright-core');10const { deepFreeze } = require('playwright-core');11const { deepFreeze } = require('playwright-core');12const { deepFreeze } = require('playwright-core');13const { deepFreeze } = require('playwright-core');14const { deepFreeze } = require('playwright-core');15const { deepFreeze } = require('playwright-core');16const { deepFreeze } = require('playwright-core');17const { deepFreeze } = require('playwright-core');18const { deepFreeze } = require('playwright-core');19const { deepFreeze } = require('playwright-core');
Using AI Code Generation
1const { deepFreeze } = require('playwright/lib/utils/utils');2const objectToBeFrozen = { a: 1, b: 2, c: 3 };3deepFreeze(objectToBeFrozen);4objectToBeFrozen.a = 4;5delete objectToBeFrozen.a;6objectToBeFrozen.d = 4;7Object.defineProperty(objectToBeFrozen, "e", { value: 5 });8Object.setPrototypeOf(objectToBeFrozen, { f: 6 });9Object.preventExtensions(objectToBeFrozen);10objectToBeFrozen.g = 7;11Object.seal(objectToBeFrozen);12delete objectToBeFrozen.b;13Object.freeze(objectToBeFrozen);14objectToBeFrozen.c = 8;15Object.defineProperty(objectToBeFrozen, "h", { value: 9, writable: false });16objectToBeFrozen.h = 10;17Object.defineProperty(objectToBeFrozen, "i", { value: 11, configurable: false });18delete objectToBeFrozen.i;19Object.defineProperty(objectToBeFrozen, "j", { value: 12, enumerable: false });20for (let x in objectToBeFrozen)
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!!