How to use stringMatching method in stryker-parent

Best JavaScript code snippet using stryker-parent

defaultGraphQLTypes.spec.js

Source:defaultGraphQLTypes.spec.js Github

copy

Full Screen

...42 const myString = 'myString';43 expect(parseStringValue(myString)).toBe(myString);44 });45 it('should fail if not a string', () => {46 expect(() => parseStringValue()).toThrow(jasmine.stringMatching('is not a valid String'));47 expect(() => parseStringValue({})).toThrow(jasmine.stringMatching('is not a valid String'));48 expect(() => parseStringValue([])).toThrow(jasmine.stringMatching('is not a valid String'));49 expect(() => parseStringValue(123)).toThrow(jasmine.stringMatching('is not a valid String'));50 });51 });52 describe('parseIntValue', () => {53 it('should parse to number if a string', () => {54 const myString = '123';55 expect(parseIntValue(myString)).toBe(123);56 });57 it('should fail if not a string', () => {58 expect(() => parseIntValue()).toThrow(jasmine.stringMatching('is not a valid Int'));59 expect(() => parseIntValue({})).toThrow(jasmine.stringMatching('is not a valid Int'));60 expect(() => parseIntValue([])).toThrow(jasmine.stringMatching('is not a valid Int'));61 expect(() => parseIntValue(123)).toThrow(jasmine.stringMatching('is not a valid Int'));62 });63 it('should fail if not an integer string', () => {64 expect(() => parseIntValue('a123')).toThrow(jasmine.stringMatching('is not a valid Int'));65 expect(() => parseIntValue('123.4')).toThrow(jasmine.stringMatching('is not a valid Int'));66 });67 });68 describe('parseFloatValue', () => {69 it('should parse to number if a string', () => {70 expect(parseFloatValue('123')).toBe(123);71 expect(parseFloatValue('123.4')).toBe(123.4);72 });73 it('should fail if not a string', () => {74 expect(() => parseFloatValue()).toThrow(jasmine.stringMatching('is not a valid Float'));75 expect(() => parseFloatValue({})).toThrow(jasmine.stringMatching('is not a valid Float'));76 expect(() => parseFloatValue([])).toThrow(jasmine.stringMatching('is not a valid Float'));77 });78 it('should fail if not a float string', () => {79 expect(() => parseIntValue('a123')).toThrow(jasmine.stringMatching('is not a valid Int'));80 });81 });82 describe('parseBooleanValue', () => {83 it('should return itself if a boolean', () => {84 let myBoolean = true;85 expect(parseBooleanValue(myBoolean)).toBe(myBoolean);86 myBoolean = false;87 expect(parseBooleanValue(myBoolean)).toBe(myBoolean);88 });89 it('should fail if not a boolean', () => {90 expect(() => parseBooleanValue()).toThrow(jasmine.stringMatching('is not a valid Boolean'));91 expect(() => parseBooleanValue({})).toThrow(jasmine.stringMatching('is not a valid Boolean'));92 expect(() => parseBooleanValue([])).toThrow(jasmine.stringMatching('is not a valid Boolean'));93 expect(() => parseBooleanValue(123)).toThrow(94 jasmine.stringMatching('is not a valid Boolean')95 );96 expect(() => parseBooleanValue('true')).toThrow(97 jasmine.stringMatching('is not a valid Boolean')98 );99 });100 });101 describe('parseDateValue', () => {102 it('should parse to date if a string', () => {103 const myDateString = '2019-05-09T23:12:00.000Z';104 const myDate = new Date(Date.UTC(2019, 4, 9, 23, 12, 0, 0));105 expect(parseDateIsoValue(myDateString)).toEqual(myDate);106 });107 it('should fail if not a string', () => {108 expect(() => parseDateIsoValue()).toThrow(jasmine.stringMatching('is not a valid Date'));109 expect(() => parseDateIsoValue({})).toThrow(jasmine.stringMatching('is not a valid Date'));110 expect(() => parseDateIsoValue([])).toThrow(jasmine.stringMatching('is not a valid Date'));111 expect(() => parseDateIsoValue(123)).toThrow(jasmine.stringMatching('is not a valid Date'));112 });113 it('should fail if not a date string', () => {114 expect(() => parseDateIsoValue('not a date')).toThrow(115 jasmine.stringMatching('is not a valid Date')116 );117 });118 });119 describe('parseValue', () => {120 const someString = createValue(Kind.STRING, 'somestring');121 const someInt = createValue(Kind.INT, '123');122 const someFloat = createValue(Kind.FLOAT, '123.4');123 const someBoolean = createValue(Kind.BOOLEAN, true);124 const someOther = createValue(undefined, new Object());125 const someObject = createValue(Kind.OBJECT, undefined, undefined, [126 createObjectField('someString', someString),127 createObjectField('someInt', someInt),128 createObjectField('someFloat', someFloat),129 createObjectField('someBoolean', someBoolean),130 createObjectField('someOther', someOther),131 createObjectField(132 'someList',133 createValue(Kind.LIST, undefined, [134 createValue(Kind.OBJECT, undefined, undefined, [135 createObjectField('someString', someString),136 ]),137 ])138 ),139 createObjectField(140 'someObject',141 createValue(Kind.OBJECT, undefined, undefined, [142 createObjectField('someString', someString),143 ])144 ),145 ]);146 const someList = createValue(Kind.LIST, undefined, [147 someString,148 someInt,149 someFloat,150 someBoolean,151 someObject,152 someOther,153 createValue(Kind.LIST, undefined, [154 someString,155 someInt,156 someFloat,157 someBoolean,158 someObject,159 someOther,160 ]),161 ]);162 it('should parse string', () => {163 expect(parseValue(someString)).toEqual('somestring');164 });165 it('should parse int', () => {166 expect(parseValue(someInt)).toEqual(123);167 });168 it('should parse float', () => {169 expect(parseValue(someFloat)).toEqual(123.4);170 });171 it('should parse boolean', () => {172 expect(parseValue(someBoolean)).toEqual(true);173 });174 it('should parse list', () => {175 expect(parseValue(someList)).toEqual([176 'somestring',177 123,178 123.4,179 true,180 {181 someString: 'somestring',182 someInt: 123,183 someFloat: 123.4,184 someBoolean: true,185 someOther: {},186 someList: [187 {188 someString: 'somestring',189 },190 ],191 someObject: {192 someString: 'somestring',193 },194 },195 {},196 [197 'somestring',198 123,199 123.4,200 true,201 {202 someString: 'somestring',203 someInt: 123,204 someFloat: 123.4,205 someBoolean: true,206 someOther: {},207 someList: [208 {209 someString: 'somestring',210 },211 ],212 someObject: {213 someString: 'somestring',214 },215 },216 {},217 ],218 ]);219 });220 it('should parse object', () => {221 expect(parseValue(someObject)).toEqual({222 someString: 'somestring',223 someInt: 123,224 someFloat: 123.4,225 someBoolean: true,226 someOther: {},227 someList: [228 {229 someString: 'somestring',230 },231 ],232 someObject: {233 someString: 'somestring',234 },235 });236 });237 it('should return value otherwise', () => {238 expect(parseValue(someOther)).toEqual(new Object());239 });240 });241 describe('parseListValues', () => {242 it('should parse to list if an array', () => {243 expect(244 parseListValues([245 { kind: Kind.STRING, value: 'someString' },246 { kind: Kind.INT, value: '123' },247 ])248 ).toEqual(['someString', 123]);249 });250 it('should fail if not an array', () => {251 expect(() => parseListValues()).toThrow(jasmine.stringMatching('is not a valid List'));252 expect(() => parseListValues({})).toThrow(jasmine.stringMatching('is not a valid List'));253 expect(() => parseListValues('some string')).toThrow(254 jasmine.stringMatching('is not a valid List')255 );256 expect(() => parseListValues(123)).toThrow(jasmine.stringMatching('is not a valid List'));257 });258 });259 describe('parseObjectFields', () => {260 it('should parse to list if an array', () => {261 expect(262 parseObjectFields([263 {264 name: { value: 'someString' },265 value: { kind: Kind.STRING, value: 'someString' },266 },267 {268 name: { value: 'someInt' },269 value: { kind: Kind.INT, value: '123' },270 },271 ])272 ).toEqual({273 someString: 'someString',274 someInt: 123,275 });276 });277 it('should fail if not an array', () => {278 expect(() => parseObjectFields()).toThrow(jasmine.stringMatching('is not a valid Object'));279 expect(() => parseObjectFields({})).toThrow(jasmine.stringMatching('is not a valid Object'));280 expect(() => parseObjectFields('some string')).toThrow(281 jasmine.stringMatching('is not a valid Object')282 );283 expect(() => parseObjectFields(123)).toThrow(jasmine.stringMatching('is not a valid Object'));284 });285 });286 describe('Date', () => {287 describe('parse literal', () => {288 const { parseLiteral } = DATE;289 it('should parse to date if string', () => {290 const date = '2019-05-09T23:12:00.000Z';291 expect(parseLiteral(createValue(Kind.STRING, date))).toEqual({292 __type: 'Date',293 iso: new Date(date),294 });295 });296 it('should parse to date if object', () => {297 const date = '2019-05-09T23:12:00.000Z';298 expect(299 parseLiteral(300 createValue(Kind.OBJECT, undefined, undefined, [301 createObjectField('__type', { value: 'Date' }),302 createObjectField('iso', { value: date, kind: Kind.STRING }),303 ])304 )305 ).toEqual({306 __type: 'Date',307 iso: new Date(date),308 });309 });310 it('should fail if not an valid object or string', () => {311 expect(() => parseLiteral({})).toThrow(jasmine.stringMatching('is not a valid Date'));312 expect(() =>313 parseLiteral(314 createValue(Kind.OBJECT, undefined, undefined, [315 createObjectField('__type', { value: 'Foo' }),316 createObjectField('iso', { value: '2019-05-09T23:12:00.000Z' }),317 ])318 )319 ).toThrow(jasmine.stringMatching('is not a valid Date'));320 expect(() => parseLiteral([])).toThrow(jasmine.stringMatching('is not a valid Date'));321 expect(() => parseLiteral(123)).toThrow(jasmine.stringMatching('is not a valid Date'));322 });323 });324 describe('parse value', () => {325 const { parseValue } = DATE;326 it('should parse string value', () => {327 const date = '2019-05-09T23:12:00.000Z';328 expect(parseValue(date)).toEqual({329 __type: 'Date',330 iso: new Date(date),331 });332 });333 it('should parse object value', () => {334 const input = {335 __type: 'Date',336 iso: new Date('2019-05-09T23:12:00.000Z'),337 };338 expect(parseValue(input)).toEqual(input);339 });340 it('should fail if not an valid object or string', () => {341 expect(() => parseValue({})).toThrow(jasmine.stringMatching('is not a valid Date'));342 expect(() =>343 parseValue({344 __type: 'Foo',345 iso: '2019-05-09T23:12:00.000Z',346 })347 ).toThrow(jasmine.stringMatching('is not a valid Date'));348 expect(() =>349 parseValue({350 __type: 'Date',351 iso: 'foo',352 })353 ).toThrow(jasmine.stringMatching('is not a valid Date'));354 expect(() => parseValue([])).toThrow(jasmine.stringMatching('is not a valid Date'));355 expect(() => parseValue(123)).toThrow(jasmine.stringMatching('is not a valid Date'));356 });357 });358 describe('serialize date type', () => {359 const { serialize } = DATE;360 it('should do nothing if string', () => {361 const str = '2019-05-09T23:12:00.000Z';362 expect(serialize(str)).toBe(str);363 });364 it('should serialize date', () => {365 const date = new Date();366 expect(serialize(date)).toBe(date.toISOString());367 });368 it('should return iso value if object', () => {369 const iso = '2019-05-09T23:12:00.000Z';370 const date = {371 __type: 'Date',372 iso,373 };374 expect(serialize(date)).toEqual(iso);375 });376 it('should fail if not an valid object or string', () => {377 expect(() => serialize({})).toThrow(jasmine.stringMatching('is not a valid Date'));378 expect(() =>379 serialize({380 __type: 'Foo',381 iso: '2019-05-09T23:12:00.000Z',382 })383 ).toThrow(jasmine.stringMatching('is not a valid Date'));384 expect(() => serialize([])).toThrow(jasmine.stringMatching('is not a valid Date'));385 expect(() => serialize(123)).toThrow(jasmine.stringMatching('is not a valid Date'));386 });387 });388 });389 describe('Bytes', () => {390 describe('parse literal', () => {391 const { parseLiteral } = BYTES;392 it('should parse to bytes if string', () => {393 expect(parseLiteral(createValue(Kind.STRING, 'bytesContent'))).toEqual({394 __type: 'Bytes',395 base64: 'bytesContent',396 });397 });398 it('should parse to bytes if object', () => {399 expect(400 parseLiteral(401 createValue(Kind.OBJECT, undefined, undefined, [402 createObjectField('__type', { value: 'Bytes' }),403 createObjectField('base64', { value: 'bytesContent' }),404 ])405 )406 ).toEqual({407 __type: 'Bytes',408 base64: 'bytesContent',409 });410 });411 it('should fail if not an valid object or string', () => {412 expect(() => parseLiteral({})).toThrow(jasmine.stringMatching('is not a valid Bytes'));413 expect(() =>414 parseLiteral(415 createValue(Kind.OBJECT, undefined, undefined, [416 createObjectField('__type', { value: 'Foo' }),417 createObjectField('base64', { value: 'bytesContent' }),418 ])419 )420 ).toThrow(jasmine.stringMatching('is not a valid Bytes'));421 expect(() => parseLiteral([])).toThrow(jasmine.stringMatching('is not a valid Bytes'));422 expect(() => parseLiteral(123)).toThrow(jasmine.stringMatching('is not a valid Bytes'));423 });424 });425 describe('parse value', () => {426 const { parseValue } = BYTES;427 it('should parse string value', () => {428 expect(parseValue('bytesContent')).toEqual({429 __type: 'Bytes',430 base64: 'bytesContent',431 });432 });433 it('should parse object value', () => {434 const input = {435 __type: 'Bytes',436 base64: 'bytesContent',437 };438 expect(parseValue(input)).toEqual(input);439 });440 it('should fail if not an valid object or string', () => {441 expect(() => parseValue({})).toThrow(jasmine.stringMatching('is not a valid Bytes'));442 expect(() =>443 parseValue({444 __type: 'Foo',445 base64: 'bytesContent',446 })447 ).toThrow(jasmine.stringMatching('is not a valid Bytes'));448 expect(() => parseValue([])).toThrow(jasmine.stringMatching('is not a valid Bytes'));449 expect(() => parseValue(123)).toThrow(jasmine.stringMatching('is not a valid Bytes'));450 });451 });452 describe('serialize bytes type', () => {453 const { serialize } = BYTES;454 it('should do nothing if string', () => {455 const str = 'foo';456 expect(serialize(str)).toBe(str);457 });458 it('should return base64 value if object', () => {459 const base64Content = 'bytesContent';460 const bytes = {461 __type: 'Bytes',462 base64: base64Content,463 };464 expect(serialize(bytes)).toEqual(base64Content);465 });466 it('should fail if not an valid object or string', () => {467 expect(() => serialize({})).toThrow(jasmine.stringMatching('is not a valid Bytes'));468 expect(() =>469 serialize({470 __type: 'Foo',471 base64: 'bytesContent',472 })473 ).toThrow(jasmine.stringMatching('is not a valid Bytes'));474 expect(() => serialize([])).toThrow(jasmine.stringMatching('is not a valid Bytes'));475 expect(() => serialize(123)).toThrow(jasmine.stringMatching('is not a valid Bytes'));476 });477 });478 });479 describe('File', () => {480 describe('parse literal', () => {481 const { parseLiteral } = FILE;482 it('should parse to file if string', () => {483 expect(parseLiteral(createValue(Kind.STRING, 'parsefile'))).toEqual({484 __type: 'File',485 name: 'parsefile',486 });487 });488 it('should parse to file if object', () => {489 expect(490 parseLiteral(491 createValue(Kind.OBJECT, undefined, undefined, [492 createObjectField('__type', { value: 'File' }),493 createObjectField('name', { value: 'parsefile' }),494 createObjectField('url', { value: 'myurl' }),495 ])496 )497 ).toEqual({498 __type: 'File',499 name: 'parsefile',500 url: 'myurl',501 });502 });503 it('should fail if not an valid object or string', () => {504 expect(() => parseLiteral({})).toThrow(jasmine.stringMatching('is not a valid File'));505 expect(() =>506 parseLiteral(507 createValue(Kind.OBJECT, undefined, undefined, [508 createObjectField('__type', { value: 'Foo' }),509 createObjectField('name', { value: 'parsefile' }),510 createObjectField('url', { value: 'myurl' }),511 ])512 )513 ).toThrow(jasmine.stringMatching('is not a valid File'));514 expect(() => parseLiteral([])).toThrow(jasmine.stringMatching('is not a valid File'));515 expect(() => parseLiteral(123)).toThrow(jasmine.stringMatching('is not a valid File'));516 });517 });518 describe('serialize file type', () => {519 const { serialize } = FILE;520 it('should do nothing if string', () => {521 const str = 'foo';522 expect(serialize(str)).toBe(str);523 });524 it('should return file name if object', () => {525 const fileName = 'parsefile';526 const file = {527 __type: 'File',528 name: fileName,529 url: 'myurl',530 };531 expect(serialize(file)).toEqual(fileName);532 });533 it('should fail if not an valid object or string', () => {534 expect(() => serialize({})).toThrow(jasmine.stringMatching('is not a valid File'));535 expect(() =>536 serialize({537 __type: 'Foo',538 name: 'parsefile',539 url: 'myurl',540 })541 ).toThrow(jasmine.stringMatching('is not a valid File'));542 expect(() => serialize([])).toThrow(jasmine.stringMatching('is not a valid File'));543 expect(() => serialize(123)).toThrow(jasmine.stringMatching('is not a valid File'));544 });545 });546 });...

Full Screen

Full Screen

schemaMethods.test.ts

Source:schemaMethods.test.ts Github

copy

Full Screen

...18 eth2BeaconChain = new ETH2BeaconChain(provider)19})20it('getGenesis', async () => {21 const expectedResponse = {22 genesis_validators_root: expect.stringMatching(/0x[a-f|A-F|\d]{64}/),23 genesis_time: expect.stringMatching(/\d{10}/),24 genesis_fork_version: expect.stringMatching(/0x[a-f|A-F|\d]{8}/)25 }26 const response = await eth2BeaconChain.getGenesis()27 expect(response).toMatchObject(expectedResponse)28})29it('getHashRoot', async () => {30 const routeParameters = { stateId: 'head' }31 const expectedResponse = {32 root: expect.stringMatching(/0x[a-f|A-F|\d]{64}/),33 }34 const response = await eth2BeaconChain.getHashRoot(routeParameters)35 expect(response).toMatchObject(expectedResponse)36})37it('getForkData', async () => {38 const routeParameters = { stateId: 'head' }39 const expectedResponse = {40 current_version: expect.stringMatching(/0x[a-f|A-F|\d]{8}/),41 epoch: expect.stringMatching(/\d/),42 previous_version: expect.stringMatching(/0x[a-f|A-F|\d]{8}/),43 }44 const response = await eth2BeaconChain.getForkData(routeParameters)45 expect(response).toMatchObject(expectedResponse)46})47it('getFinalityCheckpoint', async () => {48 const routeParameters = { stateId: 'head' }49 const expectedResponse = {50 current_justified: {51 epoch: expect.stringMatching(/\d+/),52 root: expect.stringMatching(/0x[a-f|A-F|\d]{64}/),53 },54 finalized: {55 epoch: expect.stringMatching(/\d+/),56 root: expect.stringMatching(/0x[a-f|A-F|\d]{64}/),57 },58 previous_justified: {59 epoch: expect.stringMatching(/\d+/),60 root: expect.stringMatching(/0x[a-f|A-F|\d]{64}/),61 },62 }63 const response = await eth2BeaconChain.getFinalityCheckpoint(routeParameters)64 expect(response).toMatchObject(expectedResponse)65})66it('getValidators', async () => {67 const routeParameters = { stateId: 'genesis' }68 const expectedResponse = {69 balance: expect.stringMatching(/\d+/),70 index: expect.stringMatching(/\d+/),71 status: expect.stringMatching(/pending_initialized|pending_queued|active_ongoing|active_exiting|active_slashed|exited_unslashed|exited_slashed|withdrawal_possible|withdrawal_done|active|pending|exited|withdrawal/),72 validator: {73 activation_eligibility_epoch: expect.stringMatching(/\d+/),74 activation_epoch: expect.stringMatching(/\d+/),75 effective_balance: expect.stringMatching(/\d+/),76 exit_epoch: expect.stringMatching(/\d+/),77 pubkey: expect.stringMatching(/0x[a-f|A-F|\d]{96}/),78 slashed: false,79 withdrawable_epoch: expect.stringMatching(/\d+/),80 withdrawal_credentials: expect.stringMatching(/0x[a-f|A-F|\d]{64}/),81 }82 }83 const response = await eth2BeaconChain.getValidators(routeParameters)84 expect(response[0]).toMatchObject(expectedResponse)85})86it('getValidatorById', async () => {87 const routeParameters = {88 stateId: 'head',89 validatorId: '0x96fb9db98b540d8500711c45fcb3608cc3fd75212457976f5b11f9f93c26701e68f846a9751e3dc2d92fa3d972a8c6b0'90 }91 const expectedResponse = {92 balance: expect.stringMatching(/\d+/),93 index: expect.stringMatching(/\d+/),94 status: expect.stringMatching(/pending_initialized|pending_queued|active_ongoing|active_exiting|active_slashed|exited_unslashed|exited_slashed|withdrawal_possible|withdrawal_done|active|pending|exited|withdrawal/),95 validator: {96 activation_eligibility_epoch: expect.stringMatching(/\d+/),97 activation_epoch: expect.stringMatching(/\d+/),98 effective_balance: expect.stringMatching(/\d+/),99 exit_epoch: expect.stringMatching(/\d+/),100 pubkey: expect.stringMatching(/0x[a-f|A-F|\d]{96}/),101 slashed: false,102 withdrawable_epoch: expect.stringMatching(/\d+/),103 withdrawal_credentials: expect.stringMatching(/0x[a-f|A-F|\d]{64}/),104 }105 }106 const response = await eth2BeaconChain.getValidatorById(routeParameters)107 expect(response).toMatchObject(expectedResponse)108})109it('getValidatorBalances', async () => {110 const routeParameters = {111 stateId: 'head',112 }113 const expectedResponse = {114 balance: expect.stringMatching(/\d+/),115 index: expect.stringMatching(/\d+/)116 }117 const response = await eth2BeaconChain.getValidatorBalances(routeParameters)118 expect(response[0]).toMatchObject(expectedResponse)119})120xit('getEpochCommittees', async () => {121 const routeParameters = {122 stateId: 'head',123 epoch: ''124 }125 const queryParameters = {126 index: '1',127 slot: '1'128 }129 const expectedResponse = {130 index: expect.stringMatching(/\d+/),131 slot: expect.stringMatching(/\d+/),132 validators: expect.anything() // Only tests if not null or undefined133 }134 const response = await eth2BeaconChain.getEpochCommittees(routeParameters, queryParameters)135 expect(response[0]).toMatchObject(expectedResponse)136})137it('getBlockHeaders', async () => {138 const expectedResponse = [139 {140 root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),141 // @ts-ignore - method is added at top of file142 canonical: expect.toBeBoolean(),143 header: {144 message: {145 slot: expect.stringMatching(/\d/),146 proposer_index: expect.stringMatching(/\d/),147 parent_root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),148 state_root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),149 body_root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),150 },151 signature: expect.stringMatching(/0x[a-f|A-F|\d]{192}/),152 }153 }154 ]155 const response = await eth2BeaconChain.getBlockHeaders()156 expect(response).toMatchObject(expectedResponse)157})158it('getBlockHeader', async () => {159 const routeParameters = {160 blockId: 'head',161 }162 const expectedResponse = {163 root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),164 // @ts-ignore - method is added at top of file165 canonical: expect.toBeBoolean(),166 header: {167 message: {168 slot: expect.stringMatching(/\d/),169 proposer_index: expect.stringMatching(/\d/),170 parent_root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),171 state_root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),172 body_root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),173 },174 signature: expect.stringMatching(/0x[a-f|A-F|\d]{192}/),175 }176 }177 const response = await eth2BeaconChain.getBlockHeader(routeParameters)178 expect(response).toMatchObject(expectedResponse)179})180/**181 * @TODO Doesn't actually test publishing signed block, but not sure how to go about182 * setting this up in a test environment to test actual publishing of blocks183 */184it('publishSignedBlock', async () => {185 const response = eth2BeaconChain.publishSignedBlock()186 await expect(response).rejects.toThrow('Failed to publish signed block: Request failed with status code 400')187})188it('getBlock', async () => {189 const routeParameters = {190 blockId: 'head',191 }192 const expectedResponse = {193 root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),194 // @ts-ignore - method is added at top of file195 canonical: expect.toBeBoolean(),196 header: {197 message: {198 slot: expect.stringMatching(/\d/),199 proposer_index: expect.stringMatching(/\d/),200 parent_root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),201 state_root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),202 body_root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),203 },204 signature: expect.stringMatching(/0x[a-f|A-F|\d]{192}/),205 }206 }207 const response = await eth2BeaconChain.getBlockHeader(routeParameters)208 expect(response).toMatchObject(expectedResponse)209})210it('getBlockRoot', async () => {211 const routeParameters = {212 blockId: 'head',213 }214 const expectedResponse = {215 root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/)216 }217 const response = await eth2BeaconChain.getBlockRoot(routeParameters)218 expect(response).toMatchObject(expectedResponse)219})220it('getBlockAttestations', async () => {221 const routeParameters = {222 blockId: 'head',223 }224 const expectedResponse = {225 aggregation_bits: expect.stringMatching(/0x[a-f|A-F|\d]{2}/),226 signature: expect.stringMatching(/0x[a-f|A-F|\d]{192}/),227 data: {228 slot: expect.stringMatching(/\d/),229 index: expect.stringMatching(/\d/),230 beacon_block_root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),231 source: {232 epoch: expect.stringMatching(/\d/),233 root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/)234 },235 target: {236 epoch: expect.stringMatching(/\d/),237 root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/)238 }239 }240 }241 const response = await eth2BeaconChain.getBlockAttestations(routeParameters)242 expect(response[0]).toMatchObject(expectedResponse)243})244/**245 * @TODO queryParameters don't seem to be taken into consideration246 */247it('getAttestationsFromPool', async () => {248 const queryParameters = {249 slot: 1,250 committee_index: 1251 }252 // const expectedResponse = {253 // aggregation_bits: expect.stringMatching(/0x[a-f|A-F|\d]{2}/),254 // signature: expect.stringMatching(/0x[a-f|A-F|\d]{192}/),255 // data: {256 // slot: expect.stringMatching(/\d/),257 // index: expect.stringMatching(/\d/),258 // beacon_block_root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/),259 // source: {260 // epoch: expect.stringMatching(/\d/),261 // root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/)262 // },263 // target: {264 // epoch: expect.stringMatching(/\d/),265 // root: expect.stringMatching(/0x[a-f|A-F|\d]{62}/)266 // }267 // }268 // }269 const expectedResponse: any[] = []270 const response = await eth2BeaconChain.getAttestationsFromPool(null, queryParameters)271 expect(response).toMatchObject(expectedResponse)272})273/**274 * @TODO Doesn't actually test submitting attestation, but not sure how to go about275 * setting this up in a test environment to test actual submission276 */277it('submitAttestation', async () => {278 const response = eth2BeaconChain.submitAttestation()279 await expect(response).rejects.toThrow('Failed to submit attestations to operations pool: Request failed with status code 400')...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2const strykerParentConfig = strykerParent.config;3const strykerParentConfigStringMatching = strykerParentConfig.stringMatching;4describe('stryker-parent', () => {5 it('should return stringMatching function', () => {6 expect(strykerParentConfigStringMatching).toBeDefined();7 expect(typeof strykerParentConfigStringMatching).toBe('function');8 });9 it('should return stringMatching function', () => {10 const strykerParentConfigStringMatchingResult = strykerParentConfigStringMatching('*.js');11 expect(strykerParentConfigStringMatchingResult).toBeDefined();12 expect(typeof strykerParentConfigStringMatchingResult).toBe('object');13 expect(strykerParentConfigStringMatchingResult).toEqual({ pattern: '*.js', included: false, mutated: false, type: 'js' });14 });15});16 Object {17 }18 at Object.<anonymous> (test.js:10:5)19const strykerParent = require('stryker-parent');

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2var strykerParent = strykerParent.stringMatching;3var str = 'Hello World';4var result = strykerParent(str, 'Hello');5console.log(result);6var strykerParent = require('stryker-parent');7var strykerParent = strykerParent.stringMatching;8var str = 'Hello World';9var result = strykerParent(str, 'Hello');10console.log(result);11var strykerParent = require('stryker-parent');12var strykerParent = strykerParent.stringMatching;13var str = 'Hello World';14var result = strykerParent(str, 'Hello');15console.log(result);16var strykerParent = require('stryker-parent');17var strykerParent = strykerParent.stringMatching;18var str = 'Hello World';19var result = strykerParent(str, 'Hello');20console.log(result);21var strykerParent = require('stryker-parent');22var strykerParent = strykerParent.stringMatching;23var str = 'Hello World';24var result = strykerParent(str, 'Hello');25console.log(result);26var strykerParent = require('stryker-parent');27var strykerParent = strykerParent.stringMatching;28var str = 'Hello World';29var result = strykerParent(str, 'Hello');30console.log(result);31var strykerParent = require('stryker-parent');32var strykerParent = strykerParent.stringMatching;33var str = 'Hello World';34var result = strykerParent(str, 'Hello');35console.log(result);36var strykerParent = require('stryker-parent');37var strykerParent = strykerParent.stringMatching;

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2var strykerParent = new strykerParent();3strykerParent.stringMatching('Hello World', 'Hello');4var strykerParent = require('stryker-parent');5var strykerParent = new strykerParent();6strykerParent.stringMatching('Hello World', 'Hello');7module.exports = function(config) {8 config.set({9 mochaOptions: {10 }11 });12};13Your name to display (optional):14Your name to display (optional):

Full Screen

Using AI Code Generation

copy

Full Screen

1var stringMatching = require('stryker-parent').stringMatching;2var str = 'This is a test string';3var match = 'is a test';4var result = stringMatching(str, match);5console.log(result);6{ match: 'is a test', startIndex: 2, endIndex: 10 }

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 stryker-parent 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