Best JavaScript code snippet using playwright-internal
AssignmentRowCellPropFactorySpec.js
Source:AssignmentRowCellPropFactorySpec.js
...22} from 'jsx/gradebook/default_gradebook/__tests__/GradebookSpecHelper'23QUnit.module('GradebookGrid AssignmentRowCellPropFactory', () => {24 let $container25 let gradebook26 QUnit.module('#getProps()', hooks => {27 let editorOptions28 function getProps() {29 const factory = new AssignmentRowCellPropFactory(gradebook)30 return factory.getProps(editorOptions)31 }32 hooks.beforeEach(() => {33 $container = document.body.appendChild(document.createElement('div'))34 setFixtureHtml($container)35 gradebook = createGradebook({context_id: '1201'})36 gradebook.gradebookGrid.gridSupport = {37 helper: {38 commitCurrentEdit() {},39 focus() {}40 }41 }42 gradebook.students['1101'] = {id: '1101', isConcluded: false}43 gradebook.setAssignments({44 2301: {grading_type: 'points', id: '2301', points_possible: 10}45 })46 gradebook.updateSubmission({47 assignment_id: '2301',48 entered_grade: '7.8',49 entered_score: 7.8,50 excused: false,51 grade: '6.8',52 id: '2501',53 score: 6.8,54 user_id: '1101'55 })56 editorOptions = {57 column: {58 assignmentId: '2301'59 },60 item: {id: '1101'}61 }62 sinon.stub(gradebook, 'updateRowAndRenderSubmissionTray') // no rendering needed for these tests63 })64 hooks.afterEach(() => {65 gradebook.destroy()66 $container.remove()67 })68 test('.assignment.id is the id on the assignment', () => {69 equal(getProps().assignment.id, '2301')70 })71 test('.assignment.pointsPossible is the points possible on the assignment', () => {72 strictEqual(getProps().assignment.pointsPossible, 10)73 })74 test('.enterGradesAs is the "enter grades as" setting for the assignment', () => {75 gradebook.setEnterGradesAsSetting('2301', 'percent')76 equal(getProps().enterGradesAs, 'percent')77 })78 test('.gradeIsEditable is true when the grade for the submission is editable', () => {79 sinon80 .stub(gradebook, 'isGradeEditable')81 .withArgs('1101', '2301')82 .returns(true)83 strictEqual(getProps().gradeIsEditable, true)84 })85 test('.gradeIsEditable is false when the grade for the submission is not editable', () => {86 sinon87 .stub(gradebook, 'isGradeEditable')88 .withArgs('1101', '2301')89 .returns(false)90 strictEqual(getProps().gradeIsEditable, false)91 })92 test('.gradeIsVisible is true when the grade for the submission is visible', () => {93 sinon94 .stub(gradebook, 'isGradeVisible')95 .withArgs('1101', '2301')96 .returns(true)97 strictEqual(getProps().gradeIsVisible, true)98 })99 test('.gradeIsVisible is false when the grade for the submission is not visible', () => {100 sinon101 .stub(gradebook, 'isGradeVisible')102 .withArgs('1101', '2301')103 .returns(false)104 strictEqual(getProps().gradeIsVisible, false)105 })106 test('.gradingScheme is the grading scheme for the assignment', () => {107 const gradingScheme = {108 id: '2801',109 data: [110 ['ð', 0.9],111 ['ð', 0.8],112 ['ð', 0.7],113 ['ð¢', 0.6],114 ['ð©', 0]115 ],116 title: 'Emoji Grades'117 }118 gradebook.getAssignment('2301').grading_standard_id = '2801'119 gradebook.courseContent.gradingSchemes = [gradingScheme]120 deepEqual(getProps().gradingScheme, gradingScheme.data)121 })122 test('.isSubmissionTrayOpen is true when the tray is open for the current student and assignment', () => {123 gradebook.setSubmissionTrayState(true, '1101', '2301')124 strictEqual(getProps().isSubmissionTrayOpen, true)125 })126 test('.isSubmissionTrayOpen is false when the tray is closed', () => {127 gradebook.setSubmissionTrayState(false, '1101', '2301')128 strictEqual(getProps().isSubmissionTrayOpen, false)129 })130 test('.isSubmissionTrayOpen is true when the tray is open for a different student', () => {131 gradebook.setSubmissionTrayState(true, '1102', '2301')132 strictEqual(getProps().isSubmissionTrayOpen, false)133 })134 test('.isSubmissionTrayOpen is true when the tray is open for a different assignment', () => {135 gradebook.setSubmissionTrayState(true, '1101', '2302')136 strictEqual(getProps().isSubmissionTrayOpen, false)137 })138 test('.onGradeSubmission is the .gradeSubmission Gradebook method', () => {139 strictEqual(getProps().onGradeSubmission, gradebook.gradeSubmission)140 })141 test('.onToggleSubmissionTrayOpen toggles the tray', () => {142 getProps().onToggleSubmissionTrayOpen()143 strictEqual(gradebook.getSubmissionTrayState().open, true)144 })145 test('.onToggleSubmissionTrayOpen toggles the tray using .toggleSubmissionTrayOpen', () => {146 sinon.stub(gradebook, 'toggleSubmissionTrayOpen')147 getProps().onToggleSubmissionTrayOpen()148 strictEqual(gradebook.toggleSubmissionTrayOpen.callCount, 1)149 })150 test('.onToggleSubmissionTrayOpen toggles the tray for the current student', () => {151 getProps().onToggleSubmissionTrayOpen()152 strictEqual(gradebook.getSubmissionTrayState().studentId, '1101')153 })154 test('.onToggleSubmissionTrayOpen toggles the tray for the current assignment', () => {155 getProps().onToggleSubmissionTrayOpen()156 strictEqual(gradebook.getSubmissionTrayState().assignmentId, '2301')157 })158 test('.pendingGradeInfo is included when a valid pending grade exists', () => {159 const pendingGradeInfo = {160 enteredAs: 'points',161 excused: false,162 grade: 'A',163 score: 10,164 valid: true165 }166 gradebook.addPendingGradeInfo({assignmentId: '2301', userId: '1101'}, pendingGradeInfo)167 deepEqual(getProps().pendingGradeInfo, {168 ...pendingGradeInfo,169 assignmentId: '2301',170 userId: '1101'171 })172 })173 test('.pendingGradeInfo is null when no pending grade exists', () => {174 strictEqual(getProps().pendingGradeInfo, null)175 })176 test('.student is the student associated with the row of the cell', () => {177 deepEqual(getProps().student, gradebook.students['1101'])178 })179 test('.submission.assignmentId is the assignment id', () => {180 strictEqual(getProps().submission.assignmentId, '2301')181 })182 test('.submission.enteredGrade is the entered grade on the submission', () => {183 strictEqual(getProps().submission.enteredGrade, '7.8')184 })185 test('.submission.enteredScore is the entered score on the submission', () => {186 strictEqual(getProps().submission.enteredScore, 7.8)187 })188 test('.submission.excused is true when the submission is excused', () => {189 gradebook.getSubmission('1101', '2301').excused = true190 strictEqual(getProps().submission.excused, true)191 })192 test('.submission.excused is false when the value is undefined on the submission', () => {193 gradebook.getSubmission('1101', '2301').excused = undefined194 strictEqual(getProps().submission.excused, false)195 })196 test('.submission.grade is the final grade on the submission', () => {197 strictEqual(getProps().submission.grade, '6.8')198 })199 test('.submission.id is the submission id', () => {200 strictEqual(getProps().submission.id, '2501')201 })202 test('.submission.rawGrade is the raw grade on the submission', () => {203 strictEqual(getProps().submission.rawGrade, '6.8')204 })205 test('.submission.score is the final score on the submission', () => {206 strictEqual(getProps().submission.score, 6.8)207 })208 test('.submission.userId is the student id', () => {209 strictEqual(getProps().submission.userId, '1101')210 })211 QUnit.module('.submission.similarityInfo', () => {212 test('is null when not showing similarity scores in Gradebook', () => {213 strictEqual(getProps().submission.similarityInfo, null)214 })215 QUnit.module('when showing similarity scores in Gradebook', showSimilarityScoreHooks => {216 showSimilarityScoreHooks.beforeEach(() => {217 sinon.stub(gradebook, 'showSimilarityScore').returns(true)218 })219 showSimilarityScoreHooks.afterEach(() => {220 gradebook.showSimilarityScore.restore()221 })222 test('is null when the submission has no similarity data', () => {223 strictEqual(getProps().submission.similarityInfo, null)224 })225 test('is set to the first entry returned by extractSimilarityInfo if data is present', () => {226 const submission = {227 assignment_id: '2301',228 entered_grade: '7.8',229 entered_score: 7.8,230 excused: false,231 grade: '6.8',232 id: '2501',233 score: 6.8,234 submission_type: 'online_text_entry',235 turnitin_data: {236 submission_2501: {status: 'scored', similarity_score: 75}237 },238 user_id: '1101'239 }240 sinon.stub(gradebook, 'getSubmission').returns(submission)241 deepEqual(getProps().submission.similarityInfo, {status: 'scored', similarityScore: 75})242 gradebook.getSubmission.restore()243 })244 })245 })246 test('.submissionIsUpdating is true when a valid pending grade exists', () => {247 gradebook.addPendingGradeInfo(248 {assignmentId: '2301', userId: '1101'},249 {enteredAs: 'points', excused: false, grade: 'A', score: 10, valid: true}250 )251 strictEqual(getProps().submissionIsUpdating, true)252 })253 test('.submissionIsUpdating is false when an invalid pending grade exists', () => {254 gradebook.addPendingGradeInfo(255 {assignmentId: '2301', userId: '1101'},256 {enteredAs: null, excused: false, grade: null, score: null, valid: false}257 )258 strictEqual(getProps().submissionIsUpdating, false)259 })260 test('.submissionIsUpdating is false when no pending grade exists', () => {261 strictEqual(getProps().submissionIsUpdating, false)262 })263 })...
SimpleSchema2Bridge.js
Source:SimpleSchema2Bridge.js
...111 });112 });113 describe('#getProps', () => {114 it('works with allowedValues', () => {115 expect(bridge.getProps('o')).toEqual({label: 'O', required: true, allowedValues: ['O']});116 });117 it('works with allowedValues from props', () => {118 expect(bridge.getProps('o', {allowedValues: ['O']})).toEqual({label: 'O', required: true});119 });120 it('works with custom component', () => {121 expect(bridge.getProps('l')).toEqual({label: 'L', required: true, component: 'div'});122 expect(bridge.getProps('m')).toEqual({label: 'M', required: true, component: noop});123 });124 it('works with custom component (field)', () => {125 expect(bridge.getProps('n')).toEqual({label: 'N', required: true, component: 'div'});126 });127 it('works with Number type', () => {128 expect(bridge.getProps('h')).toEqual({label: 'H', required: true, decimal: true});129 });130 it('works with options (array)', () => {131 expect(bridge.getProps('s').transform('a')).toBe(1);132 expect(bridge.getProps('s').transform('b')).toBe(2);133 expect(bridge.getProps('s').allowedValues[0]).toBe('a');134 expect(bridge.getProps('s').allowedValues[1]).toBe('b');135 });136 it('works with options (function)', () => {137 expect(bridge.getProps('t').transform('a')).toBe(1);138 expect(bridge.getProps('t').transform('b')).toBe(2);139 expect(bridge.getProps('t').allowedValues[0]).toBe('a');140 expect(bridge.getProps('t').allowedValues[1]).toBe('b');141 });142 it('works with options (object)', () => {143 expect(bridge.getProps('r').transform('a')).toBe(1);144 expect(bridge.getProps('r').transform('b')).toBe(2);145 expect(bridge.getProps('r').allowedValues[0]).toBe('a');146 expect(bridge.getProps('r').allowedValues[1]).toBe('b');147 });148 it('works with options from props', () => {149 expect(bridge.getProps('s', {options: {c: 1, d: 2}}).transform('c')).toBe(1);150 expect(bridge.getProps('s', {options: {c: 1, d: 2}}).transform('d')).toBe(2);151 expect(bridge.getProps('s', {options: {c: 1, d: 2}}).allowedValues[0]).toBe('c');152 expect(bridge.getProps('s', {options: {c: 1, d: 2}}).allowedValues[1]).toBe('d');153 });154 it('works with transform', () => {155 expect(bridge.getProps('p')).toEqual({label: 'P', required: true, transform: noop});156 });157 it('works with transform from props', () => {158 expect(bridge.getProps('p', {transform: () => {}})).toEqual({label: 'P', required: true});159 });160 });161 describe('#getSubfields', () => {162 it('works on top level', () => {163 expect(bridge.getSubfields()).toEqual([164 'a',165 'd',166 'e',167 'f',168 'g',169 'h',170 'i',171 'j',172 'k',...
SimpleSchemaBridge.js
Source:SimpleSchemaBridge.js
...124 });125 });126 describe('#getProps', () => {127 it('works with allowedValues', () => {128 expect(bridge.getProps('o')).toEqual({label: 'O', required: true, allowedValues: ['O']});129 });130 it('works with allowedValues from props', () => {131 expect(bridge.getProps('o', {allowedValues: ['O']})).toEqual({label: 'O', required: true});132 });133 it('works with custom component', () => {134 expect(bridge.getProps('l')).toEqual({label: 'L', required: true, component: 'div'});135 expect(bridge.getProps('m')).toEqual({label: 'M', required: true, component: noop});136 });137 it('works with custom component (field)', () => {138 expect(bridge.getProps('n')).toEqual({label: 'N', required: true, component: 'div'});139 });140 it('works with options (array)', () => {141 expect(bridge.getProps('s').transform('a')).toBe(1);142 expect(bridge.getProps('s').transform('b')).toBe(2);143 expect(bridge.getProps('s').allowedValues[0]).toBe('a');144 expect(bridge.getProps('s').allowedValues[1]).toBe('b');145 });146 it('works with options (function)', () => {147 expect(bridge.getProps('t').transform('a')).toBe(1);148 expect(bridge.getProps('t').transform('b')).toBe(2);149 expect(bridge.getProps('t').allowedValues[0]).toBe('a');150 expect(bridge.getProps('t').allowedValues[1]).toBe('b');151 });152 it('works with options (object)', () => {153 expect(bridge.getProps('r').transform('a')).toBe(1);154 expect(bridge.getProps('r').transform('b')).toBe(2);155 expect(bridge.getProps('r').allowedValues[0]).toBe('a');156 expect(bridge.getProps('r').allowedValues[1]).toBe('b');157 });158 it('works with options from props', () => {159 expect(bridge.getProps('s', {options: {c: 1, d: 2}}).transform('c')).toBe(1);160 expect(bridge.getProps('s', {options: {c: 1, d: 2}}).transform('d')).toBe(2);161 expect(bridge.getProps('s', {options: {c: 1, d: 2}}).allowedValues[0]).toBe('c');162 expect(bridge.getProps('s', {options: {c: 1, d: 2}}).allowedValues[1]).toBe('d');163 });164 it('works with transform', () => {165 expect(bridge.getProps('p')).toEqual({label: 'P', required: true, transform: noop});166 });167 it('works with transform from props', () => {168 expect(bridge.getProps('p', {transform: () => {}})).toEqual({label: 'P', required: true});169 });170 });171 describe('#getSubfields', () => {172 it('works with objects', () => {173 expect(bridge.getSubfields('a')).toEqual(['b']);174 expect(bridge.getSubfields('a.b')).toEqual(['c']);175 });176 it('works with primitives', () => {177 expect(bridge.getSubfields('d')).toEqual([]);178 expect(bridge.getSubfields('e')).toEqual([]);179 });180 });181 describe('#getType', () => {182 it('works with any type', () => {...
TotalGradeOverrideCellPropFactory.test.js
Source:TotalGradeOverrideCellPropFactory.test.js
...22import TotalGradeOverrideCellPropFactory from '../TotalGradeOverrideCellPropFactory'23describe('GradebookGrid TotalGradeOverrideCellPropFactory', () => {24 let gradebook25 let gradingScheme26 describe('#getProps()', () => {27 let editorOptions28 beforeEach(() => {29 gradingScheme = {30 data: [['A', 0.9], ['B', 0.8], ['C', 0.7], ['D', 0.6], ['F', 0.5]],31 id: '2801',32 title: 'Default Grading Scheme'33 }34 // `gradebook` is a double because CoffeeScript and AMD cannot be imported35 // into Jest specs36 gradebook = {37 getCourseGradingScheme() {38 return gradingScheme39 },40 gradebookGrid: {41 updateRowCell: sinon.stub()42 },43 isFilteringColumnsByGradingPeriod: sinon.stub().returns(false),44 studentCanReceiveGradeOverride(id) {45 return {1101: true, 1102: false}[id]46 }47 }48 gradebook.finalGradeOverrides = new FinalGradeOverrides(gradebook)49 gradebook.finalGradeOverrides.setGrades({50 1101: {51 courseGrade: {52 percentage: 88.153 }54 }55 })56 editorOptions = {57 item: {id: '1101'}58 }59 })60 function getProps() {61 const factory = new TotalGradeOverrideCellPropFactory(gradebook)62 return factory.getProps(editorOptions)63 }64 it('sets .gradeEntry to a GradeOverrideEntry instance', () => {65 expect(getProps().gradeEntry).toBeInstanceOf(GradeOverrideEntry)66 })67 it('uses the grading scheme from the Gradebook to create the GradeEntry', () => {68 expect(getProps().gradeEntry.gradingScheme).toBe(gradingScheme)69 })70 it('sets .gradeInfo to a GradeOverrideInfo instance', () => {71 expect(getProps().gradeInfo).toBeInstanceOf(GradeOverrideInfo)72 })73 it('derives the grade override info from the user grade', () => {74 expect(getProps().gradeInfo.grade.percentage).toEqual(88.1)75 })76 it('sets .gradeIsUpdating to false when the user does not have a pending grade', () => {77 expect(getProps().gradeIsUpdating).toBe(false)78 })79 it('sets .gradeIsUpdating to true when the user has a valid pending grade', () => {80 const {gradeEntry} = getProps()81 const gradeInfo = gradeEntry.parseValue('A')82 gradebook.finalGradeOverrides._datastore.addPendingGradeInfo('1101', null, gradeInfo)83 expect(getProps().gradeIsUpdating).toBe(true)84 })85 it('sets .gradeIsUpdating to false when the user has an invalid pending grade', () => {86 const {gradeEntry} = getProps()87 const gradeInfo = gradeEntry.parseValue('invalid')88 gradebook.finalGradeOverrides._datastore.addPendingGradeInfo('1101', null, gradeInfo)89 expect(getProps().gradeIsUpdating).toBe(false)90 })91 describe('.onGradeUpdate', () => {92 let props93 beforeEach(() => {94 sinon.stub(gradebook.finalGradeOverrides, 'updateGrade')95 props = getProps()96 })97 it('updates a final grade override when called', () => {98 const gradeInfo = props.gradeEntry.parseValue('A')99 props.onGradeUpdate(gradeInfo)100 expect(gradebook.finalGradeOverrides.updateGrade.callCount).toEqual(1)101 })102 it('includes the user id for the row when updating the final grade override', () => {103 const gradeInfo = props.gradeEntry.parseValue('A')104 props.onGradeUpdate(gradeInfo)105 const [userId] = gradebook.finalGradeOverrides.updateGrade.lastCall.args106 expect(userId).toEqual('1101')107 })108 it('includes the given grade override info when updating the final grade override', () => {109 const gradeInfo = props.gradeEntry.parseValue('A')110 props.onGradeUpdate(gradeInfo)111 const [, gradeOverrideInfo] = gradebook.finalGradeOverrides.updateGrade.lastCall.args112 expect(gradeOverrideInfo).toBe(gradeInfo)113 })114 })115 it('sets .pendingGradeInfo to the pending grade for the related user', () => {116 const {gradeEntry} = getProps()117 const gradeInfo = gradeEntry.parseValue('A')118 gradebook.finalGradeOverrides._datastore.addPendingGradeInfo('1101', null, gradeInfo)119 expect(getProps().pendingGradeInfo).toBe(gradeInfo)120 })121 it('sets .studentIsGradeable to true when the student is gradeable', () => {122 expect(getProps().studentIsGradeable).toBe(true)123 })124 it('sets .studentIsGradeable to false when the student is not gradeable', () => {125 editorOptions.item.id = '1102'126 expect(getProps().studentIsGradeable).toBe(false)127 })128 })...
proxy-array-prototype-methods.js
Source:proxy-array-prototype-methods.js
1function assert(b) {2 if (!b)3 throw new Error("Bad assertion!");4}5function test(f) {6 for (let i = 0; i < 1000; i++)7 f();8}9function shallowEq(a, b) {10 if (a.length !== b.length)11 return false;12 for (let i = 0; i < a.length; i++) {13 if (a[i] !== b[i])14 return false;15 }16 return true;17}18test(function() {19 let delProps = new Set;20 let hasProps = new Set;21 let getProps = new Set;22 let target = [ , , 1, , 4];23 let handler = {24 get(theTarget, key) {25 getProps.add(key);26 return Reflect.get(theTarget, key);27 },28 has(theTarget, key) {29 hasProps.add(key);30 return Reflect.has(theTarget, key);31 },32 deleteProperty(theTarget, key)33 {34 delProps.add(key);35 return Reflect.deleteProperty(theTarget, key);36 }37 };38 let proxy = new Proxy(target, handler);39 proxy.unshift(20);40 assert(delProps.size === 3);41 assert(delProps.has("1"));42 assert(delProps.has("2"));43 assert(delProps.has("4"));44 assert(hasProps.size === 5);45 assert(hasProps.has("0"));46 assert(hasProps.has("1"));47 assert(hasProps.has("2"));48 assert(hasProps.has("3"));49 assert(hasProps.has("4"));50 assert(getProps.size === 4);51 assert(getProps.has("unshift"));52 assert(getProps.has("length"));53 assert(getProps.has("2"));54 assert(getProps.has("4"));55});56test(function() {57 let delProps = new Set;58 let hasProps = new Set;59 let getProps = new Set;60 let target = [ 0, 0, , 1, , 4];61 let handler = {62 get(theTarget, key) {63 getProps.add(key);64 return Reflect.get(theTarget, key);65 },66 has(theTarget, key) {67 hasProps.add(key);68 return Reflect.has(theTarget, key);69 },70 deleteProperty(theTarget, key)71 {72 delProps.add(key);73 return Reflect.deleteProperty(theTarget, key);74 }75 };76 let proxy = new Proxy(target, handler);77 proxy.shift();78 assert(target.length === 5);79 assert(delProps.size === 3);80 assert(delProps.has("1"));81 assert(delProps.has("3"));82 assert(delProps.has("5"));83 assert(hasProps.size === 5);84 assert(hasProps.has("1"));85 assert(hasProps.has("2"));86 assert(hasProps.has("3"));87 assert(hasProps.has("4"));88 assert(hasProps.has("5"));89 assert(getProps.size === 6);90 assert(getProps.has("shift"));91 assert(getProps.has("length"));92 assert(getProps.has("0"));93 assert(getProps.has("1"));94 assert(getProps.has("3"));95 assert(getProps.has("5"));96});97test(function() {98 let delProps = new Set;99 let hasProps = new Set;100 let getProps = new Set;101 let target = [ 0, , 1, , 2];102 let handler = {103 get(theTarget, key) {104 getProps.add(key);105 return Reflect.get(theTarget, key);106 },107 has(theTarget, key) {108 hasProps.add(key);109 return Reflect.has(theTarget, key);110 },111 deleteProperty(theTarget, key)112 {113 delProps.add(key);114 return Reflect.deleteProperty(theTarget, key);115 }116 };117 let proxy = new Proxy(target, handler);118 proxy.splice(2, 2);119 assert(delProps.size === 2);120 assert(delProps.has("3"));121 assert(delProps.has("4"));122 assert(hasProps.size === 3);123 assert(hasProps.has("2"));124 assert(hasProps.has("3"));125 assert(hasProps.has("4"));126 assert(getProps.size === 5);127 assert(getProps.has("splice"));128 assert(getProps.has("length"));129 assert(getProps.has("constructor"));130 assert(getProps.has("2"));131 assert(getProps.has("4"));132});133test(function() {134 let delProps = new Set;135 let hasProps = new Set;136 let getProps = new Set;137 let target = [ 0, , 1, , 2];138 let handler = {139 get(theTarget, key) {140 getProps.add(key);141 return Reflect.get(theTarget, key);142 },143 has(theTarget, key) {144 hasProps.add(key);145 return Reflect.has(theTarget, key);146 },147 deleteProperty(theTarget, key)148 {149 delProps.add(key);150 return Reflect.deleteProperty(theTarget, key);151 }152 };153 let proxy = new Proxy(target, handler);154 proxy.slice(1, 5);155 assert(delProps.size === 0);156 assert(hasProps.size === 4);157 assert(hasProps.has("1"));158 assert(hasProps.has("2"));159 assert(hasProps.has("3"));160 assert(hasProps.has("4"));161 assert(getProps.size === 5);162 assert(getProps.has("slice"));163 assert(getProps.has("length"));164 assert(getProps.has("constructor"));165 assert(getProps.has("2"));166 assert(getProps.has("4"));167});168test(function() {169 let x = [1,2,3];170 x.__proto__ = new Proxy([], {171 get(theTarget, prop, receiver) {172 assert(prop === "shift");173 assert(receiver === x);174 return Reflect.get(theTarget, prop);175 }176 });177 x.shift();178 assert(x.length === 2);179 assert(x[0] === 2);180 assert(x[1] === 3);...
f6ecd7a391be4cd2abea5f0a518361b8.js
Source:f6ecd7a391be4cd2abea5f0a518361b8.js
1function assert(b) {2 if (!b)3 throw new Error("Bad assertion!");4}5function test(f) {6 for (let i = 0; i < 1000; i++)7 f();8}9function shallowEq(a, b) {10 if (a.length !== b.length)11 return false;12 for (let i = 0; i < a.length; i++) {13 if (a[i] !== b[i])14 return false;15 }16 return true;17}18test(function() {19 let delProps = new Set;20 let hasProps = new Set;21 let getProps = new Set;22 let target = [ , , 1, , 4];23 let handler = {24 get(theTarget, key) {25 getProps.add(key);26 return Reflect.get(theTarget, key);27 },28 has(theTarget, key) {29 hasProps.add(key);30 return Reflect.has(theTarget, key);31 },32 deleteProperty(theTarget, key)33 {34 delProps.add(key);35 return Reflect.deleteProperty(theTarget, key);36 }37 };38 let proxy = new Proxy(target, handler);39 proxy.unshift(20);40 assert(delProps.size === 3);41 assert(delProps.has("1"));42 assert(delProps.has("2"));43 assert(delProps.has("4"));44 assert(hasProps.size === 5);45 assert(hasProps.has("0"));46 assert(hasProps.has("1"));47 assert(hasProps.has("2"));48 assert(hasProps.has("3"));49 assert(hasProps.has("4"));50 assert(getProps.size === 4);51 assert(getProps.has("unshift"));52 assert(getProps.has("length"));53 assert(getProps.has("2"));54 assert(getProps.has("4"));55});56test(function() {57 let delProps = new Set;58 let hasProps = new Set;59 let getProps = new Set;60 let target = [ 0, 0, , 1, , 4];61 let handler = {62 get(theTarget, key) {63 getProps.add(key);64 return Reflect.get(theTarget, key);65 },66 has(theTarget, key) {67 hasProps.add(key);68 return Reflect.has(theTarget, key);69 },70 deleteProperty(theTarget, key)71 {72 delProps.add(key);73 return Reflect.deleteProperty(theTarget, key);74 }75 };76 let proxy = new Proxy(target, handler);77 proxy.shift();78 assert(target.length === 5);79 assert(delProps.size === 3);80 assert(delProps.has("1"));81 assert(delProps.has("3"));82 assert(delProps.has("5"));83 assert(hasProps.size === 5);84 assert(hasProps.has("1"));85 assert(hasProps.has("2"));86 assert(hasProps.has("3"));87 assert(hasProps.has("4"));88 assert(hasProps.has("5"));89 assert(getProps.size === 6);90 assert(getProps.has("shift"));91 assert(getProps.has("length"));92 assert(getProps.has("0"));93 assert(getProps.has("1"));94 assert(getProps.has("3"));95 assert(getProps.has("5"));96});97test(function() {98 let delProps = new Set;99 let hasProps = new Set;100 let getProps = new Set;101 let target = [ 0, , 1, , 2];102 let handler = {103 get(theTarget, key) {104 getProps.add(key);105 return Reflect.get(theTarget, key);106 },107 has(theTarget, key) {108 hasProps.add(key);109 return Reflect.has(theTarget, key);110 },111 deleteProperty(theTarget, key)112 {113 delProps.add(key);114 return Reflect.deleteProperty(theTarget, key);115 }116 };117 let proxy = new Proxy(target, handler);118 proxy.splice(2, 2);119 assert(delProps.size === 2);120 assert(delProps.has("3"));121 assert(delProps.has("4"));122 assert(hasProps.size === 3);123 assert(hasProps.has("2"));124 assert(hasProps.has("3"));125 assert(hasProps.has("4"));126 assert(getProps.size === 5);127 assert(getProps.has("splice"));128 assert(getProps.has("length"));129 assert(getProps.has("constructor"));130 assert(getProps.has("2"));131 assert(getProps.has("4"));132});133test(function() {134 let delProps = new Set;135 let hasProps = new Set;136 let getProps = new Set;137 let target = [ 0, , 1, , 2];138 let handler = {139 get(theTarget, key) {140 getProps.add(key);141 return Reflect.get(theTarget, key);142 },143 has(theTarget, key) {144 hasProps.add(key);145 return Reflect.has(theTarget, key);146 },147 deleteProperty(theTarget, key)148 {149 delProps.add(key);150 return Reflect.deleteProperty(theTarget, key);151 }152 };153 let proxy = new Proxy(target, handler);154 proxy.slice(1, 5);155 assert(delProps.size === 0);156 assert(hasProps.size === 4);157 assert(hasProps.has("1"));158 assert(hasProps.has("2"));159 assert(hasProps.has("3"));160 assert(hasProps.has("4"));161 assert(getProps.size === 5);162 assert(getProps.has("slice"));163 assert(getProps.has("length"));164 assert(getProps.has("constructor"));165 assert(getProps.has("2"));166 assert(getProps.has("4"));167});168test(function() {169 let x = [1,2,3];170 x.__proto__ = new Proxy([], {171 get(theTarget, prop, receiver) {172 assert(prop === "shift");173 assert(receiver === x);174 return Reflect.get(theTarget, prop);175 }176 });177 x.shift();178 assert(x.length === 2);179 assert(x[0] === 2);180 assert(x[1] === 3);...
StyledIconButton.js
Source:StyledIconButton.js
...6import { Accessor, ColorX } from "IZOArc/STATIC";7const styles = {8 root: {9 background: MUIUtils.getMappedProps(ColorX.GetBGColorCSS, "theme.background", "theme.color"),10 borderRadius: MUIUtils.getProps("theme.borderRadius"),11 border: MUIUtils.getProps("theme.border"),12 borderBottom: MUIUtils.getProps("theme.borderBottom"),13 borderTop: MUIUtils.getProps("theme.borderTop"),14 borderLeft: MUIUtils.getProps("theme.borderLeft"),15 borderRight: MUIUtils.getProps("theme.borderRight"),16 color: MUIUtils.getMappedProps(ColorX.GetColorCSS, "theme.label", "theme.color"),17 height: MUIUtils.getProps("theme.height"),18 width: MUIUtils.getProps("theme.width"),19 minHeight: MUIUtils.getProps("theme.minHeight"),20 minWidth: MUIUtils.getProps("theme.minWidth"),21 maxHeight: MUIUtils.getProps("theme.maxHeight"),22 maxWidth: MUIUtils.getProps("theme.maxWidth"),23 padding: MUIUtils.getProps("theme.padding"),24 margin: MUIUtils.getProps("theme.margin"),25 position: MUIUtils.getProps("theme.position"),26 boxShadow: MUIUtils.getProps("theme.boxShadow", "theme.color"),27 "&:hover": {28 color: MUIUtils.getMappedProps(ColorX.GetColorCSS, "theme.hover.color", "theme.label", "theme.color"),29 fontWeight: MUIUtils.getProps("theme.hover.fontWeight"),30 background: MUIUtils.getMappedProps(ColorX.GetBGColorCSS, "theme.hover.background", "theme.color"),31 border: MUIUtils.getProps("theme.hover.border"),32 borderBottom: MUIUtils.getProps("theme.hover.borderBottom"),33 borderTop: MUIUtils.getProps("theme.hover.borderTop"),34 borderLeft: MUIUtils.getProps("theme.hover.borderLeft"),35 borderRight: MUIUtils.getProps("theme.hover.borderRight"),36 },37 "&:disabled": {38 color: MUIUtils.getMappedProps(ColorX.GetColorCSS, "theme.disabled.color"),39 fontWeight: MUIUtils.getProps("theme.disabled.fontWeight"),40 background: MUIUtils.getMappedProps(ColorX.GetBGColorCSS, "theme.disabled.background"),41 border: MUIUtils.getProps("theme.disabled.border"),42 borderBottom: MUIUtils.getProps("theme.disabled.borderBottom"),43 borderTop: MUIUtils.getProps("theme.disabled.borderTop"),44 borderLeft: MUIUtils.getProps("theme.disabled.borderLeft"),45 borderRight: MUIUtils.getProps("theme.disabled.borderRight"),46 },47 display: MUIUtils.getProps("theme.display"),48 visibility: MUIUtils.getProps("theme.visibility"),49 opacity: MUIUtils.getProps("theme.opacity"),50 textTransform: MUIUtils.getProps("theme.textTransform"),51 zIndex: MUIUtils.getProps("theme.zIndex"),52 },53};54/**55 * Styled Icon Button56 * @augments {Component<Props, State>}57 * @property {{58 * color: Color,59 * background: Color,60 * label: Color,61 * boxShadow: Color,62 * hover: Color,63 * }} theme64 */65class StyledIconButton extends Component {...
StyledButton.js
Source:StyledButton.js
...6import { Accessor, ColorX } from "IZOArc/STATIC";7const styles = {8 root: {9 background: MUIUtils.getMappedProps(ColorX.GetBGColorCSS, "theme.background", "theme.color"),10 borderRadius: MUIUtils.getProps("theme.borderRadius"),11 border: MUIUtils.getProps("theme.border"),12 borderBottom: MUIUtils.getProps("theme.borderBottom"),13 borderTop: MUIUtils.getProps("theme.borderTop"),14 borderLeft: MUIUtils.getProps("theme.borderLeft"),15 borderRight: MUIUtils.getProps("theme.borderRight"),16 color: MUIUtils.getMappedProps(ColorX.GetColorCSS, "theme.label", "theme.color"),17 height: MUIUtils.getProps("theme.height"),18 width: MUIUtils.getProps("theme.width"),19 minHeight: MUIUtils.getProps("theme.minHeight"),20 minWidth: MUIUtils.getProps("theme.minWidth"),21 maxHeight: MUIUtils.getProps("theme.maxHeight"),22 maxWidth: MUIUtils.getProps("theme.maxWidth"),23 padding: MUIUtils.getProps("theme.padding"),24 margin: MUIUtils.getProps("theme.margin"),25 position: MUIUtils.getProps("theme.position"),26 boxShadow: MUIUtils.getProps("theme.boxShadow", "theme.color"),27 "&:hover": {28 color: MUIUtils.getMappedProps(ColorX.GetColorCSS, "theme.hover.color", "theme.label", "theme.color"),29 fontWeight: MUIUtils.getProps("theme.hover.fontWeight"),30 background: MUIUtils.getMappedProps(ColorX.GetBGColorCSS, "theme.hover.background", "theme.color"),31 border: MUIUtils.getProps("theme.hover.border"),32 borderBottom: MUIUtils.getProps("theme.hover.borderBottom"),33 borderTop: MUIUtils.getProps("theme.hover.borderTop"),34 borderLeft: MUIUtils.getProps("theme.hover.borderLeft"),35 borderRight: MUIUtils.getProps("theme.hover.borderRight"),36 },37 "&:disabled": {38 color: MUIUtils.getMappedProps(ColorX.GetColorCSS, "theme.disabled.color"),39 fontWeight: MUIUtils.getProps("theme.disabled.fontWeight"),40 background: MUIUtils.getMappedProps(ColorX.GetBGColorCSS, "theme.disabled.background"),41 border: MUIUtils.getProps("theme.disabled.border"),42 borderBottom: MUIUtils.getProps("theme.disabled.borderBottom"),43 borderTop: MUIUtils.getProps("theme.disabled.borderTop"),44 borderLeft: MUIUtils.getProps("theme.disabled.borderLeft"),45 borderRight: MUIUtils.getProps("theme.disabled.borderRight"),46 },47 display: MUIUtils.getProps("theme.display"),48 visibility: MUIUtils.getProps("theme.visibility"),49 opacity: MUIUtils.getProps("theme.opacity"),50 textTransform: MUIUtils.getProps("theme.textTransform"),51 zIndex: MUIUtils.getProps("theme.zIndex"),52 },53};54/**55 * Styled Buttons56 * @augments {Component<Props, State>}57 * @property {{58 * color: Color,59 * background: Color,60 * label: Color,61 * boxShadow: Color,62 * hover: Color,63 * }} theme64 */65class StyledButton extends Component {...
Using AI Code Generation
1const { getProps } = require('playwright/lib/internal/api');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 console.log(await getProps(page));7 await browser.close();8})();9{10 _browser: {
Using AI Code Generation
1const { getProps } = require('@playwright/test/lib/server/inspector');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 const props = await getProps(page, 'document');7 console.log(props);8 await browser.close();9})();10const { getProps } = require('@playwright/test/lib/server/inspector');11const { chromium } = require('playwright');12const browser = await chromium.launch();13const page = await browser.newPage();14const props = await getProps(page, 'document');15console.log(props);16await browser.close();
Using AI Code Generation
1const { getProps } = require('playwright/lib/server/chromium/crBrowser');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const crBrowser = getProps(page)._browser;8 console.log(crBrowser);9})();10Browser {11 _connection: Connection {12 _transport: WebSocketTransport {13 _ws: WebSocket {14 _events: [Object: null prototype] {},15 _extensions: {},16 },17 _callbacks: Map(0) {},18 _sessions: Map(0) {},19 _eventListeners: Map(0) {}20 },21 _sessions: Map(0) {},22 _sessionsById: Map(0) {},23 _objects: Map(0) {},24 _callbacks: Map(0) {},25 _eventListeners: Map(0) {},26 },27 _defaultContext: Context {28 _browser: Browser {
Using AI Code Generation
1const { getProps } = require('playwright/lib/client/selectorEngine');2const { getProps } = require('playwright/lib/client/selectorEngine');3const { chromium } = require('playwright');4const fs = require('fs');5const path = require('path');6(async () => {7 const browser = await chromium.launch();8 const context = await browser.newContext();9 const page = await context.newPage();10 const props = await getProps(page, 'css=div');11 console.log(props);12 await browser.close();13})();
Using AI Code Generation
1const { getProps } = require('playwright/lib/server/chromium/crBrowser');2const { getProps } = require('playwright/lib/server/firefox/fxBrowser');3const { getProps } = require('playwright/lib/server/webkit/wkBrowser');4const { getProps } = require('playwright/lib/server/webkit/wkPage');5const { getProps } = require('playwright/lib/server/webkit/wkSession');6const { getProps } = require('playwright/lib/server/webkit/wkWebSocketTransport');7const { getProps } = require('playwright/lib/server/webkit/wkConnection');8const { getProps } = require('playwright/lib/server/webkit/wkBrowserContext');9const { getProps } = require('playwright/lib/server/webkit/wkFrame');10const { getProps } = require('playwright/lib/server/webkit/wkExecutionContext');11const { getProps } = require('playwright/lib/server/webkit/wkJSHandle');12const { getProps } = require('playwright/lib/server/webkit/wkElementHandle');13const { getProps } = require('playwright/lib/server/webkit/wkWorker');14const { getProps } = require('playwright/lib/server/webkit/wkNetworkManager');15const { getProps } = require('playwright/lib/server/webkit/wkNetworkManager');16const { getProps } = require('playwright/lib/server/webkit/wkRequest');17const { getProps } = require('playwright/lib/server
Using AI Code Generation
1const { getProps } = require('@playwright/test/lib/server/trace/viewer/traceModel');2const { readFileSync } = require('fs');3const { resolve } = require('path');4const tracePath = resolve(__dirname, 'trace.zip');5const trace = readFileSync(tracePath);6const props = getProps(trace);7console.log(props);8const { resources } = props;9const page = resources.find(r => r.type === 'page');10console.log(page);11const { actions } = page;12const action = actions.find(a => a.type === 'action');13console.log(action);14const { snapshot } = action;15console.log(snapshot);16const { frames } = snapshot;17console.log(frame);18const { resources: frameResources } = frame;19console.log(frameResource);20const { resources: resourceResources } = frameResource;21console.log(resource);22const { sha1 } = resource;23console.log(sha1);24const { resources: sha1Resources } = props;25const sha1Resource = sha1Resources.find(r => r.sha1 === sha1);26console.log(sha1Resource);27const { data } = sha1Resource;28console.log(data);29const { resources: dataResources } = props;30const dataResource = dataResources.find(r => r.data === data);31console.log(dataResource);32const { sha1: dataSha1 } = dataResource;33console.log(dataSha1);34const { resources: dataSha1Resources } = props;35const dataSha1Resource = dataSha1Resources.find(r => r.sha1 === dataSha1);36console.log(dataSha1Resource);37const { data: dataSha1Data } = dataSha1Resource;38console.log(dataSha1Data);39const { resources: dataSha1DataResources } = props;40const dataSha1DataResource = dataSha1DataResources.find(r => r.data === dataSha1Data);41console.log(dataSha1DataResource);42const { sha1: dataSha1DataSha1 } = dataSha1DataResource;43console.log(dataSha1DataSha1);44const { resources: dataSha1DataSha1Resources } = props;
Using AI Code Generation
1const { getProps } = require('playwright/lib/server/frames');2const frame = await page.mainFrame();3const props = getProps(frame, ['url']);4console.log(props.url);5const { getProps } = require('playwright/lib/server/frames');6const frame = await page.mainFrame();7const props = getProps(frame, ['url']);8console.log(props.url);9const { getProps } = require('playwright/lib/server/frames');10const frame = await page.mainFrame();11const props = getProps(frame, ['url']);12console.log(props.url);13const { getProps } = require('playwright/lib/server/frames');14const frame = await page.mainFrame();15const props = getProps(frame, ['url']);16console.log(props.url);17const { getProps } = require('playwright/lib/server/frames');18const frame = await page.mainFrame();19const props = getProps(frame, ['url']);20console.log(props.url);21const { getProps } = require('playwright/lib/server/frames');22const frame = await page.mainFrame();23const props = getProps(frame, ['url']);24console.log(props.url);25const { getProps } = require('playwright/lib/server/frames');26const frame = await page.mainFrame();27const props = getProps(frame, ['url']);28console.log(props.url);29const { getProps } = require
Using AI Code Generation
1const { getProps } = require('@playwright/test/lib/server/trace/common/traceModel');2const trace = require('./trace.json');3console.log(getProps(trace, 'page').length);4{5 "metadata": {6 },7 {8 }9 {10 "args": {11 "position": {12 }13 }14 }15}
Using AI Code Generation
1const { getProps } = require('playwright/lib/server/frames');2const frame = await page.mainFrame();3const { props } = await getProps(frame);4console.log(props);5{6 attributes: {7 },8 boundingBox: {9 },10 { x: 8, y: 8 },11 { x: 792, y: 8 },12 { x: 792, y: 592 },13 { x: 8, y: 592 }
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!!