How to use getTestData method in wpt

Best JavaScript code snippet using wpt

Worldview.stories.js

Source:Worldview.stories.js Github

copy

Full Screen

...52 assertionTest({53 story: (setTestData) => <WorldviewWrapper onClick={(_, clickInfo) => setTestData(clickInfo)} />,54 assertions: async (getTestData) => {55 await clickAtOrigin();56 const result = await getTestData();57 expect(result.objects.length).toEqual(0);58 // Dir59 expect(result.ray.dir[0]).toBeCloseTo(0);60 expect(result.ray.dir[1]).toBeCloseTo(-1);61 expect(result.ray.dir[2]).toBeCloseTo(0);62 // Origin63 expect(result.ray.origin[0]).toBeCloseTo(0);64 expect(result.ray.origin[1]).toBeCloseTo(75, 1);65 expect(result.ray.origin[2]).toBeCloseTo(0);66 // Point67 expect(result.ray.point[0]).toBeCloseTo(0);68 expect(result.ray.point[1]).toBeCloseTo(75, 1);69 expect(result.ray.point[2]).toBeCloseTo(0);70 },71 })72 )73 .add(74 `Default object handler has a ray`,75 assertionTest({76 story: (setTestData) => (77 <WorldviewWrapper>78 <Cubes onClick={(_, clickInfo) => setTestData(clickInfo)}>{[cube]}</Cubes>79 </WorldviewWrapper>80 ),81 assertions: async (getTestData) => {82 await clickAtOrigin();83 const result = await getTestData();84 // Dir85 expect(result.ray.dir[0]).toBeCloseTo(0);86 expect(result.ray.dir[1]).toBeCloseTo(-1);87 expect(result.ray.dir[2]).toBeCloseTo(0);88 // Origin89 expect(result.ray.origin[0]).toBeCloseTo(0);90 expect(result.ray.origin[1]).toBeCloseTo(75, 1);91 expect(result.ray.origin[2]).toBeCloseTo(0);92 // Point93 expect(result.ray.point[0]).toBeCloseTo(0);94 expect(result.ray.point[1]).toBeCloseTo(75, 1);95 expect(result.ray.point[2]).toBeCloseTo(0);96 },97 })98 )99 .add(100 `onMouseMove does not pick up objects with hitmapOnMouseMove=false`,101 assertionTest({102 story: (setTestData) => (103 <WorldviewWrapper onMouseMove={(_, { objects }) => setTestData(objects)}>104 <Cubes>{[cube]}</Cubes>105 </WorldviewWrapper>106 ),107 assertions: async (getTestData) => {108 await emitMouseEvent("mousemove");109 const result = await getTestData();110 expect(result.length).toEqual(0);111 },112 })113 )114 .add(115 `onMouseMove picks up objects with hitmapOnMouseMove=true`,116 assertionTest({117 story: (setTestData) => (118 <WorldviewWrapper onMouseMove={(_, { objects }) => setTestData(objects)} hitmapOnMouseMove>119 <Cubes>{[cube]}</Cubes>120 </WorldviewWrapper>121 ),122 assertions: async (getTestData) => {123 await emitMouseEvent("mousemove");124 const result = await getTestData();125 expect(result.length).toEqual(1);126 expect(result[0].object).toEqual(cube);127 },128 })129 )130 .add(131 `onMouseUp detects objects`,132 assertionTest({133 story: (setTestData) => (134 <WorldviewWrapper onMouseUp={(_, { objects }) => setTestData(objects)}>135 <Cubes>{[cube]}</Cubes>136 </WorldviewWrapper>137 ),138 assertions: async (getTestData) => {139 await emitMouseEvent("mouseup");140 const result = await getTestData();141 expect(result.length).toEqual(1);142 expect(result[0].object).toEqual(cube);143 },144 })145 )146 .add(147 `onMouseDown detects objects`,148 assertionTest({149 story: (setTestData) => (150 <WorldviewWrapper onMouseDown={(_, { objects }) => setTestData(objects)}>151 <Cubes>{[cube]}</Cubes>152 </WorldviewWrapper>153 ),154 assertions: async (getTestData) => {155 await emitMouseEvent("mousedown");156 const result = await getTestData();157 expect(result.length).toEqual(1);158 expect(result[0].object).toEqual(cube);159 },160 })161 )162 .add(163 `onDoubleClick detects objects`,164 assertionTest({165 story: (setTestData) => (166 <WorldviewWrapper onDoubleClick={(_, { objects }) => setTestData(objects)}>167 <Cubes>{[cube]}</Cubes>168 </WorldviewWrapper>169 ),170 assertions: async (getTestData) => {171 await emitMouseEvent("dblclick");172 const result = await getTestData();173 expect(result.length).toEqual(1);174 expect(result[0].object).toEqual(cube);175 },176 })177 )178 .add(179 `a component's mouse handlers can stop event propagation to worldview's global mouse handlers`,180 assertionTest({181 story: (setTestData) => (182 <WorldviewWrapper onMouseDown={(_, { objects }) => setTestData([])}>183 <Cubes184 onMouseDown={(e, { objects }) => {185 e.stopPropagation();186 setTestData(objects);187 }}>188 {[cube]}189 </Cubes>190 </WorldviewWrapper>191 ),192 assertions: async (getTestData) => {193 await emitMouseEvent("mousedown");194 const result = await getTestData();195 expect(result.length).toEqual(1);196 expect(result[0].object).toEqual(cube);197 },198 })199 )200 .add(201 `when there are overlapping objects from different commands, the command on top of the drawing layer can stop event propagation to other commands`,202 assertionTest({203 story: (setTestData) => (204 <WorldviewWrapper enableStackedObjectEvents>205 <Cubes206 onMouseDown={(e, { objects }) => {207 e.stopPropagation();208 setTestData(objects);209 }}>210 {[cube]}211 </Cubes>212 <Cubes213 onMouseDown={() => {214 setTestData([]);215 }}>216 {[underCube]}217 </Cubes>218 </WorldviewWrapper>219 ),220 assertions: async (getTestData) => {221 await emitMouseEvent("mousedown");222 const result = await getTestData();223 expect(result.length).toEqual(1);224 expect(result[0].object).toEqual(cube);225 },226 })227 )228 .add(229 `Firing two mouse events at the same time does not cause an error`,230 assertionTest({231 story: (setTestData) => (232 <WorldviewWrapper onMouseDown={(_, clickInfo) => setTestData(clickInfo)}>233 <Cubes>{[cube]}</Cubes>234 </WorldviewWrapper>235 ),236 assertions: async (getTestData) => {237 emitMouseEvent("mousedown");238 await emitMouseEvent("mousedown");239 const result1 = await getTestData();240 expect(result1.objects[0].object).toEqual(cube);241 },242 })243 )244 .add(245 `(cached hitmap test) A second event at the same point correctly selects the same object`,246 assertionTest({247 story: (setTestData) => (248 <WorldviewWrapper onMouseDown={(_, clickInfo) => setTestData(clickInfo)}>249 <Cubes>{[cube]}</Cubes>250 </WorldviewWrapper>251 ),252 assertions: async (getTestData) => {253 await emitMouseEvent("mousedown");254 const result1 = await getTestData();255 expect(result1.objects[0].object).toEqual(cube);256 await emitMouseEvent("mousedown");257 const result2 = await getTestData();258 expect(result2.objects[0].object).toEqual(cube);259 },260 })261 )262 .add(263 `(cached hitmap test) Repainting busts the cache`,264 assertionTest({265 story: (setTestData, state) => (266 <WorldviewWrapper267 cameraState={state || defaultCameraState}268 onMouseDown={(_, clickInfo) => setTestData(clickInfo)}>269 <Cubes>{[cube]}</Cubes>270 </WorldviewWrapper>271 ),272 assertions: async (getTestData, setState) => {273 await emitMouseEvent("mousedown");274 const result1 = await getTestData();275 expect(result1.objects[0].object).toEqual(cube);276 setState({ ...defaultCameraState, target: [100, 0, 0] });277 await timeout(100);278 await emitMouseEvent("mousedown");279 const result2 = await getTestData();280 expect(result2.objects.length).toEqual(0);281 },282 })283 )284 .add(285 `(cached hitmap test) A second event at a different point does not use the first cached point`,286 assertionTest({287 story: (setTestData) => (288 <WorldviewWrapper onMouseDown={(_, clickInfo) => setTestData(clickInfo)}>289 <Cubes>{[cube]}</Cubes>290 </WorldviewWrapper>291 ),292 assertions: async (getTestData) => {293 await emitMouseEvent("mousedown");294 const result1 = await getTestData();295 expect(result1.objects[0].object).toEqual(cube);296 await emitMouseEvent("mousedown", 0, 0);297 const result2 = await getTestData();298 expect(result2.objects.length).toEqual(0);299 },300 })...

Full Screen

Full Screen

FakeApi.spec.js

Source:FakeApi.spec.js Github

copy

Full Screen

...32}(this, function(expect, pointer, assertEquals, SwaggerPetstore, testData) {33 'use strict';34 var instance;35 var testDataCache;36 function getTestData(pointer) {37 return testDataCache.get('/petstore/FakeApi' + pointer);38 }39 before(function() {40 testDataCache = pointer(testData);41 });42 beforeEach(function() {43 instance = new SwaggerPetstore.FakeApi();44 });45 describe('petstore', function() {46 describe('FakeApi', function() {47 describe('fakeOuterBooleanSerialize', function() {48 it('should call fakeOuterBooleanSerialize successfully', function(done) {49 var opts = {};50 opts.body = getTestData('/fakeOuterBooleanSerialize/body');51 instance.fakeOuterBooleanSerialize(opts, function(error, data, response) {52 if (error) {53 done(error);54 return;55 }56 let expected = getTestData('/fakeOuterBooleanSerialize/response');57 assertEquals(expected, data);58 done();59 });60 });61 });62 describe('fakeOuterCompositeSerialize', function() {63 it('should call fakeOuterCompositeSerialize successfully', function(done) {64 var opts = {};65 opts.body = getTestData('/fakeOuterCompositeSerialize/body');66 instance.fakeOuterCompositeSerialize(opts, function(error, data, response) {67 if (error) {68 done(error);69 return;70 }71 let expected = getTestData('/fakeOuterCompositeSerialize/response');72 assertEquals(expected, data);73 done();74 });75 });76 });77 describe('fakeOuterNumberSerialize', function() {78 it('should call fakeOuterNumberSerialize successfully', function(done) {79 var opts = {};80 opts.body = getTestData('/fakeOuterNumberSerialize/body');81 instance.fakeOuterNumberSerialize(opts, function(error, data, response) {82 if (error) {83 done(error);84 return;85 }86 let expected = getTestData('/fakeOuterNumberSerialize/response');87 assertEquals(expected, data);88 done();89 });90 });91 });92 describe('fakeOuterStringSerialize', function() {93 it('should call fakeOuterStringSerialize successfully', function(done) {94 var opts = {};95 opts.body = getTestData('/fakeOuterStringSerialize/body');96 instance.fakeOuterStringSerialize(opts, function(error, data, response) {97 if (error) {98 done(error);99 return;100 }101 let expected = getTestData('/fakeOuterStringSerialize/response');102 assertEquals(expected, data);103 done();104 });105 });106 });107 describe('testBodyWithQueryParams', function() {108 it('should call testBodyWithQueryParams successfully', function(done) {109 var body = getTestData('/testBodyWithQueryParams/body');110 var query = getTestData('/testBodyWithQueryParams/query');111 instance.testBodyWithQueryParams(body, query, function(error, data, response) {112 if (error) {113 done(error);114 return;115 }116 done();117 });118 });119 });120 describe('testClientModel', function() {121 it('should call testClientModel successfully', function(done) {122 var body = getTestData('/testClientModel/body');123 instance.testClientModel(body, function(error, data, response) {124 if (error) {125 done(error);126 return;127 }128 let expected = getTestData('/testClientModel/response');129 assertEquals(expected, data);130 done();131 });132 });133 });134 describe('testEndpointParameters', function() {135 it('should call testEndpointParameters successfully', function(done) {136 var _number = getTestData('/testEndpointParameters/_number');137 var _double = getTestData('/testEndpointParameters/_double');138 var patternWithoutDelimiter = getTestData('/testEndpointParameters/patternWithoutDelimiter');139 var _byte = getTestData('/testEndpointParameters/_byte');140 var opts = {};141 opts.integer = getTestData('/testEndpointParameters/integer');142 opts.int32 = getTestData('/testEndpointParameters/int32');143 opts.int64 = getTestData('/testEndpointParameters/int64');144 opts._float = getTestData('/testEndpointParameters/_float');145 opts._string = getTestData('/testEndpointParameters/_string');146 opts.binary = getTestData('/testEndpointParameters/binary');147 opts._date = getTestData('/testEndpointParameters/_date');148 opts.dateTime = getTestData('/testEndpointParameters/dateTime');149 opts.password = getTestData('/testEndpointParameters/password');150 opts.callback = getTestData('/testEndpointParameters/callback');151 instance.testEndpointParameters(_number, _double, patternWithoutDelimiter, _byte, opts, function(error, data, response) {152 if (error) {153 done(error);154 return;155 }156 done();157 });158 });159 });160 describe('testEnumParameters', function() {161 it('should call testEnumParameters successfully', function(done) {162 var opts = {};163 opts.enumFormStringArray = getTestData('/testEnumParameters/enumFormStringArray');164 opts.enumFormString = getTestData('/testEnumParameters/enumFormString');165 opts.enumHeaderStringArray = getTestData('/testEnumParameters/enumHeaderStringArray');166 opts.enumHeaderString = getTestData('/testEnumParameters/enumHeaderString');167 opts.enumQueryStringArray = getTestData('/testEnumParameters/enumQueryStringArray');168 opts.enumQueryString = getTestData('/testEnumParameters/enumQueryString');169 opts.enumQueryInteger = getTestData('/testEnumParameters/enumQueryInteger');170 opts.enumQueryDouble = getTestData('/testEnumParameters/enumQueryDouble');171 instance.testEnumParameters(opts, function(error, data, response) {172 if (error) {173 done(error);174 return;175 }176 done();177 });178 });179 });180 describe('testInlineAdditionalProperties', function() {181 it('should call testInlineAdditionalProperties successfully', function(done) {182 var param = getTestData('/testInlineAdditionalProperties/param');183 instance.testInlineAdditionalProperties(param, function(error, data, response) {184 if (error) {185 done(error);186 return;187 }188 done();189 });190 });191 });192 describe('testJsonFormData', function() {193 it('should call testJsonFormData successfully', function(done) {194 var param = getTestData('/testJsonFormData/param');195 var param2 = getTestData('/testJsonFormData/param2');196 instance.testJsonFormData(param, param2, function(error, data, response) {197 if (error) {198 done(error);199 return;200 }201 done();202 });203 });204 });205 });206 });...

Full Screen

Full Screen

test_game.js

Source:test_game.js Github

copy

Full Screen

1'use strict';2const assert = require('assert');3const Fool = require('../classes/Fool');4function getTestData(round, step) {5 return require(`./data/rounds/${round}/${step}`);6}7function loadGame(data) {8 return Fool.load(data.before);9}10// show diff11// assert.deepStrictEqual(testData.after, testData.before);12describe('Testing Fool with 36 card and 3 Players', () => {13 beforeEach(() => {14 const game = new Fool(['Player1', 'Player2', 'Player3'], 36);15 game._debug = false;16 game.log();17 });18 afterEach(() => {19 });20 describe('Round #1', () => {21 it('#0', () => {22 const testData = getTestData(0, 0);23 const game = loadGame(testData);24 game[testData.command](...testData.args);25 game._debug = true;26 game.log();27 assert.deepStrictEqual(game, Fool.load(testData.after));28 });29 it('#1', () => {30 const testData = getTestData(0, 1);31 const game = loadGame(testData);32 game[testData.command](...testData.args);33 assert.deepStrictEqual(game, Fool.load(testData.after));34 });35 it('#2', () => {36 const testData = getTestData(0, 2);37 const game = loadGame(testData);38 game[testData.command](...testData.args);39 assert.deepStrictEqual(game, Fool.load(testData.after));40 });41 it('#3', () => {42 const testData = getTestData(0, 3);43 const game = loadGame(testData);44 game[testData.command](...testData.args);45 assert.deepStrictEqual(game, Fool.load(testData.after));46 });47 it('#4', () => {48 const testData = getTestData(0, 4);49 const game = loadGame(testData);50 game[testData.command](...testData.args);51 assert.deepStrictEqual(game, Fool.load(testData.after));52 });53 it('#5', () => {54 const testData = getTestData(0, 5);55 const game = loadGame(testData);56 game[testData.command](...testData.args);57 assert.deepStrictEqual(game, Fool.load(testData.after));58 });59 it('#6', () => {60 const testData = getTestData(0, 6);61 const game = loadGame(testData);62 game[testData.command](...testData.args);63 assert.deepStrictEqual(game, Fool.load(testData.after));64 });65 it('#7', () => {66 const testData = getTestData(0, 7);67 const game = loadGame(testData);68 game[testData.command](...testData.args);69 assert.deepStrictEqual(game, Fool.load(testData.after));70 });71 it('#8', () => {72 const testData = getTestData(0, 8);73 const game = loadGame(testData);74 game[testData.command](...testData.args);75 assert.deepStrictEqual(game, Fool.load(testData.after));76 });77 it('#9', () => {78 const testData = getTestData(0, 9);79 const game = loadGame(testData);80 game[testData.command](...testData.args);81 assert.deepStrictEqual(game, Fool.load(testData.after));82 });83 it('#10', () => {84 const testData = getTestData(0, 10);85 const game = loadGame(testData);86 game[testData.command](...testData.args);87 assert.deepStrictEqual(game, Fool.load(testData.after));88 });89 it('#11', () => {90 const testData = getTestData(0, 11);91 const game = loadGame(testData);92 game[testData.command](...testData.args);93 assert.deepStrictEqual(game, Fool.load(testData.after));94 });95 it('#12', () => {96 const testData = getTestData(0, 12);97 const game = loadGame(testData);98 game[testData.command](...testData.args);99 assert.deepStrictEqual(game, Fool.load(testData.after));100 });101 it('#13', () => {102 const testData = getTestData(0, 13);103 const game = loadGame(testData);104 game[testData.command](...testData.args);105 assert.deepStrictEqual(game, Fool.load(testData.after));106 });107 it('#14', () => {108 const testData = getTestData(0, 14);109 const game = loadGame(testData);110 game[testData.command](...testData.args);111 assert.deepStrictEqual(game, Fool.load(testData.after));112 });113 it('#15', () => {114 const testData = getTestData(0, 15);115 const game = loadGame(testData);116 game[testData.command](...testData.args);117 assert.deepStrictEqual(game, Fool.load(testData.after));118 });119 it('#16', () => {120 const testData = getTestData(0, 16);121 const game = loadGame(testData);122 game[testData.command](...testData.args);123 assert.deepStrictEqual(game, Fool.load(testData.after));124 });125 it('#17', () => {126 const testData = getTestData(0, 17);127 const game = loadGame(testData);128 game[testData.command](...testData.args);129 assert.deepStrictEqual(game, Fool.load(testData.after));130 game.log();131 });132 it('#18', () => {133 const testData = getTestData(0, 18);134 const game = loadGame(testData);135 game[testData.command](...testData.args);136 assert.deepStrictEqual(game, Fool.load(testData.after));137 });138 it('#19', () => {139 const testData = getTestData(0, 19);140 const game = loadGame(testData);141 game[testData.command](...testData.args);142 assert.deepStrictEqual(game, Fool.load(testData.after));143 });144 it('#20', () => {145 const testData = getTestData(0, 20);146 const game = loadGame(testData);147 game[testData.command](...testData.args);148 assert.deepStrictEqual(game, Fool.load(testData.after));149 });150 it('#21', () => {151 const testData = getTestData(0, 21);152 const game = loadGame(testData);153 game[testData.command](...testData.args);154 assert.deepStrictEqual(game, Fool.load(testData.after));155 });156 it('#22', () => {157 const testData = getTestData(0, 22);158 const game = loadGame(testData);159 game[testData.command](...testData.args);160 assert.deepStrictEqual(game, Fool.load(testData.after));161 });162 it('#23', () => {163 const testData = getTestData(0, 23);164 const game = loadGame(testData);165 game[testData.command](...testData.args);166 assert.deepStrictEqual(game, Fool.load(testData.after));167 });168 it('#24', () => {169 const testData = getTestData(0, 24);170 const game = loadGame(testData);171 game[testData.command](...testData.args);172 assert.deepStrictEqual(game, Fool.load(testData.after));173 });174 it('#25', () => {175 const testData = getTestData(0, 25);176 const game = loadGame(testData);177 game[testData.command](...testData.args);178 assert.deepStrictEqual(game, Fool.load(testData.after));179 });180 it('#26', () => {181 const testData = getTestData(0, 26);182 const game = loadGame(testData);183 game[testData.command](...testData.args);184 game._debug = true;185 game.log();186 assert.deepStrictEqual(game, Fool.load(testData.after));187 });188 it('#27', () => {189 const testData = getTestData(0, 27);190 const game = loadGame(testData);191 game[testData.command](...testData.args);192 assert.deepStrictEqual(game, Fool.load(testData.after));193 });194 it('#28', () => {195 const testData = getTestData(0, 28);196 const game = loadGame(testData);197 game[testData.command](...testData.args);198 game._debug = true;199 game.log();200 assert.deepStrictEqual(game, Fool.load(testData.after));201 });202 it('#29', () => {203 const testData = getTestData(0, 29);204 const game = loadGame(testData);205 game[testData.command](...testData.args);206 game._debug = true;207 game.log();208 assert.deepStrictEqual(game, Fool.load(testData.after));209 });210 it('#30 game over', () => {211 const testData = getTestData(0, 30);212 const game = loadGame(testData);213 assert.throws(() => {214 game[testData.command](...testData.args);215 }, new Error('GAME_OVER'));216 game._debug = true;217 game.log();218 // assert.deepStrictEqual(game, Fool.load(testData.after));219 });220 it('#31', () => {221 const testData = getTestData(0, 31);222 const game = loadGame(testData);223 game[testData.command](...testData.args);224 game._debug = true;225 game.log();226 assert.deepStrictEqual(game, Fool.load(testData.after));227 // assert.deepStrictEqual(testData.after, testData.before);228 });229 it('#32', () => {230 const testData = getTestData(0, 32);231 const game = loadGame(testData);232 game[testData.command](...testData.args);233 game._debug = true;234 game.log();235 assert.deepStrictEqual(game, Fool.load(testData.after));236 assert.deepStrictEqual(testData.after, testData.before);237 });238 // it('#<>', () => {239 // const testData = getTestData(0, 12);240 // const game = loadGame(testData);241 // game[testData.command](...testData.args);242 // game._debug = true;243 // game.log();244 // assert.deepStrictEqual(game, Fool.load(testData.after));245 // assert.deepStrictEqual(testData.after, testData.before);246 // });247 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var WebPageTest = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'your api key');3wpt.getTestData('140529_2B_2G2', function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var webPageTest = new wpt('A.8d4b4f4b4f4b4f4b4f4b4f4b4f4b4f4b', 'www.webpagetest.org');3var options = {4};5webPageTest.runTest(options, function(err, data) {6 if (err) return console.error(err);7 console.log('Test Results: %j', data.data);8 webPageTest.getTestResults(data.data.testId, function(err, data) {9 if (err) return console.error(err);10 console.log('Test Results: %j', data.data);11 });12});

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful