How to use globaltype method in wpt

Best JavaScript code snippet using wpt

find.ts

Source:find.ts Github

copy

Full Screen

1/*2 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one3 * or more contributor license agreements. Licensed under the Elastic License;4 * you may not use this file except in compliance with the Elastic License.5 */6import { AUTHENTICATION } from '../../common/lib/authentication';7import { FtrProviderContext } from '../../common/ftr_provider_context';8import { findTestSuiteFactory } from '../../common/suites/find';9export default function({ getService }: FtrProviderContext) {10 const supertest = getService('supertestWithoutAuth');11 const esArchiver = getService('esArchiver');12 describe('find', () => {13 const {14 createExpectEmpty,15 createExpectRbacForbidden,16 createExpectVisualizationResults,17 expectFilterWrongTypeError,18 expectNotSpaceAwareResults,19 expectTypeRequired,20 findTest,21 } = findTestSuiteFactory(esArchiver, supertest);22 findTest(`user with no access`, {23 user: AUTHENTICATION.NOT_A_KIBANA_USER,24 tests: {25 spaceAwareType: {26 description: 'forbidden login and find visualization message',27 statusCode: 403,28 response: createExpectRbacForbidden('visualization'),29 },30 notSpaceAwareType: {31 description: 'forbidden login and find globaltype message',32 statusCode: 403,33 response: createExpectRbacForbidden('globaltype'),34 },35 hiddenType: {36 description: 'forbidden login and find hiddentype message',37 statusCode: 403,38 response: createExpectRbacForbidden('hiddentype'),39 },40 unknownType: {41 description: 'forbidden find wigwags message',42 statusCode: 403,43 response: createExpectRbacForbidden('wigwags'),44 },45 pageBeyondTotal: {46 description: 'forbidden login and find visualization message',47 statusCode: 403,48 response: createExpectRbacForbidden('visualization'),49 },50 unknownSearchField: {51 description: 'forbidden login and unknown search field',52 statusCode: 403,53 response: createExpectRbacForbidden('url'),54 },55 noType: {56 description: 'bad request, type is required',57 statusCode: 400,58 response: expectTypeRequired,59 },60 filterWithNotSpaceAwareType: {61 description: 'forbidden login and find globaltype message',62 statusCode: 403,63 response: createExpectRbacForbidden('globaltype'),64 },65 filterWithHiddenType: {66 description: 'forbidden login and find hiddentype message',67 statusCode: 403,68 response: createExpectRbacForbidden('hiddentype'),69 },70 filterWithUnknownType: {71 description: 'forbidden find wigwags message',72 statusCode: 403,73 response: createExpectRbacForbidden('wigwags'),74 },75 filterWithNoType: {76 description: 'bad request, type is required',77 statusCode: 400,78 response: expectTypeRequired,79 },80 filterWithUnAllowedType: {81 description: 'forbidden',82 statusCode: 403,83 response: createExpectRbacForbidden('globaltype'),84 },85 },86 });87 findTest(`superuser`, {88 user: AUTHENTICATION.SUPERUSER,89 tests: {90 spaceAwareType: {91 description: 'only the visualization',92 statusCode: 200,93 response: createExpectVisualizationResults(),94 },95 notSpaceAwareType: {96 description: 'only the globaltype',97 statusCode: 200,98 response: expectNotSpaceAwareResults,99 },100 hiddenType: {101 description: 'empty result',102 statusCode: 200,103 response: createExpectEmpty(1, 20, 0),104 },105 unknownType: {106 description: 'empty result',107 statusCode: 200,108 response: createExpectEmpty(1, 20, 0),109 },110 pageBeyondTotal: {111 description: 'empty result',112 statusCode: 200,113 response: createExpectEmpty(100, 100, 1),114 },115 unknownSearchField: {116 description: 'empty result',117 statusCode: 200,118 response: createExpectEmpty(1, 20, 0),119 },120 noType: {121 description: 'bad request, type is required',122 statusCode: 400,123 response: expectTypeRequired,124 },125 filterWithNotSpaceAwareType: {126 description: 'only the globaltype',127 statusCode: 200,128 response: expectNotSpaceAwareResults,129 },130 filterWithHiddenType: {131 description: 'empty result',132 statusCode: 200,133 response: createExpectEmpty(1, 20, 0),134 },135 filterWithUnknownType: {136 description: 'empty result',137 statusCode: 200,138 response: createExpectEmpty(1, 20, 0),139 },140 filterWithNoType: {141 description: 'bad request, type is required',142 statusCode: 400,143 response: expectTypeRequired,144 },145 filterWithUnAllowedType: {146 description: 'Bad Request',147 statusCode: 400,148 response: expectFilterWrongTypeError,149 },150 },151 });152 findTest(`legacy user`, {153 user: AUTHENTICATION.KIBANA_LEGACY_USER,154 tests: {155 spaceAwareType: {156 description: 'forbidden login and find visualization message',157 statusCode: 403,158 response: createExpectRbacForbidden('visualization'),159 },160 notSpaceAwareType: {161 description: 'forbidden login and find globaltype message',162 statusCode: 403,163 response: createExpectRbacForbidden('globaltype'),164 },165 hiddenType: {166 description: 'forbidden login and find hiddentype message',167 statusCode: 403,168 response: createExpectRbacForbidden('hiddentype'),169 },170 unknownType: {171 description: 'forbidden find wigwags message',172 statusCode: 403,173 response: createExpectRbacForbidden('wigwags'),174 },175 pageBeyondTotal: {176 description: 'forbidden login and find visualization message',177 statusCode: 403,178 response: createExpectRbacForbidden('visualization'),179 },180 unknownSearchField: {181 description: 'forbidden login and unknown search field',182 statusCode: 403,183 response: createExpectRbacForbidden('url'),184 },185 noType: {186 description: 'bad request, type is required',187 statusCode: 400,188 response: expectTypeRequired,189 },190 filterWithNotSpaceAwareType: {191 description: 'forbidden login and find globaltype message',192 statusCode: 403,193 response: createExpectRbacForbidden('globaltype'),194 },195 filterWithHiddenType: {196 description: 'forbidden login and find hiddentype message',197 statusCode: 403,198 response: createExpectRbacForbidden('hiddentype'),199 },200 filterWithUnknownType: {201 description: 'forbidden find wigwags message',202 statusCode: 403,203 response: createExpectRbacForbidden('wigwags'),204 },205 filterWithNoType: {206 description: 'bad request, type is required',207 statusCode: 400,208 response: expectTypeRequired,209 },210 filterWithUnAllowedType: {211 description: 'forbidden',212 statusCode: 403,213 response: createExpectRbacForbidden('globaltype'),214 },215 },216 });217 findTest(`dual-privileges user`, {218 user: AUTHENTICATION.KIBANA_DUAL_PRIVILEGES_USER,219 tests: {220 spaceAwareType: {221 description: 'only the visualization',222 statusCode: 200,223 response: createExpectVisualizationResults(),224 },225 notSpaceAwareType: {226 description: 'only the globaltype',227 statusCode: 200,228 response: expectNotSpaceAwareResults,229 },230 hiddenType: {231 description: 'forbidden find hiddentype message',232 statusCode: 403,233 response: createExpectRbacForbidden('hiddentype'),234 },235 unknownType: {236 description: 'forbidden find wigwags message',237 statusCode: 403,238 response: createExpectRbacForbidden('wigwags'),239 },240 pageBeyondTotal: {241 description: 'empty result',242 statusCode: 200,243 response: createExpectEmpty(100, 100, 1),244 },245 unknownSearchField: {246 description: 'empty result',247 statusCode: 200,248 response: createExpectEmpty(1, 20, 0),249 },250 noType: {251 description: 'bad request, type is required',252 statusCode: 400,253 response: expectTypeRequired,254 },255 filterWithNotSpaceAwareType: {256 description: 'only the globaltype',257 statusCode: 200,258 response: expectNotSpaceAwareResults,259 },260 filterWithHiddenType: {261 description: 'forbidden find hiddentype message',262 statusCode: 403,263 response: createExpectRbacForbidden('hiddentype'),264 },265 filterWithUnknownType: {266 description: 'forbidden find wigwags message',267 statusCode: 403,268 response: createExpectRbacForbidden('wigwags'),269 },270 filterWithNoType: {271 description: 'bad request, type is required',272 statusCode: 400,273 response: expectTypeRequired,274 },275 filterWithUnAllowedType: {276 description: 'Bad Request',277 statusCode: 400,278 response: expectFilterWrongTypeError,279 },280 },281 });282 findTest(`dual-privileges readonly user`, {283 user: AUTHENTICATION.KIBANA_DUAL_PRIVILEGES_DASHBOARD_ONLY_USER,284 tests: {285 spaceAwareType: {286 description: 'only the visualization',287 statusCode: 200,288 response: createExpectVisualizationResults(),289 },290 notSpaceAwareType: {291 description: 'only the globaltype',292 statusCode: 200,293 response: expectNotSpaceAwareResults,294 },295 hiddenType: {296 description: 'forbidden find hiddentype message',297 statusCode: 403,298 response: createExpectRbacForbidden('hiddentype'),299 },300 unknownType: {301 description: 'forbidden find wigwags message',302 statusCode: 403,303 response: createExpectRbacForbidden('wigwags'),304 },305 pageBeyondTotal: {306 description: 'empty result',307 statusCode: 200,308 response: createExpectEmpty(100, 100, 1),309 },310 unknownSearchField: {311 description: 'empty result',312 statusCode: 200,313 response: createExpectEmpty(1, 20, 0),314 },315 noType: {316 description: 'bad request, type is required',317 statusCode: 400,318 response: expectTypeRequired,319 },320 filterWithNotSpaceAwareType: {321 description: 'only the globaltype',322 statusCode: 200,323 response: expectNotSpaceAwareResults,324 },325 filterWithHiddenType: {326 description: 'forbidden find hiddentype message',327 statusCode: 403,328 response: createExpectRbacForbidden('hiddentype'),329 },330 filterWithUnknownType: {331 description: 'forbidden find wigwags message',332 statusCode: 403,333 response: createExpectRbacForbidden('wigwags'),334 },335 filterWithNoType: {336 description: 'bad request, type is required',337 statusCode: 400,338 response: expectTypeRequired,339 },340 filterWithUnAllowedType: {341 description: 'Bad Request',342 statusCode: 400,343 response: expectFilterWrongTypeError,344 },345 },346 });347 findTest(`rbac user with all globally`, {348 user: AUTHENTICATION.KIBANA_RBAC_USER,349 tests: {350 spaceAwareType: {351 description: 'only the visualization',352 statusCode: 200,353 response: createExpectVisualizationResults(),354 },355 notSpaceAwareType: {356 description: 'only the globaltype',357 statusCode: 200,358 response: expectNotSpaceAwareResults,359 },360 hiddenType: {361 description: 'forbidden find hiddentype message',362 statusCode: 403,363 response: createExpectRbacForbidden('hiddentype'),364 },365 unknownType: {366 description: 'forbidden find wigwags message',367 statusCode: 403,368 response: createExpectRbacForbidden('wigwags'),369 },370 pageBeyondTotal: {371 description: 'empty result',372 statusCode: 200,373 response: createExpectEmpty(100, 100, 1),374 },375 unknownSearchField: {376 description: 'empty result',377 statusCode: 200,378 response: createExpectEmpty(1, 20, 0),379 },380 noType: {381 description: 'bad request, type is required',382 statusCode: 400,383 response: expectTypeRequired,384 },385 filterWithNotSpaceAwareType: {386 description: 'only the globaltype',387 statusCode: 200,388 response: expectNotSpaceAwareResults,389 },390 filterWithHiddenType: {391 description: 'forbidden find hiddentype message',392 statusCode: 403,393 response: createExpectRbacForbidden('hiddentype'),394 },395 filterWithUnknownType: {396 description: 'forbidden find wigwags message',397 statusCode: 403,398 response: createExpectRbacForbidden('wigwags'),399 },400 filterWithNoType: {401 description: 'bad request, type is required',402 statusCode: 400,403 response: expectTypeRequired,404 },405 filterWithUnAllowedType: {406 description: 'Bad Request',407 statusCode: 400,408 response: expectFilterWrongTypeError,409 },410 },411 });412 findTest(`rbac user with read globally`, {413 user: AUTHENTICATION.KIBANA_RBAC_DASHBOARD_ONLY_USER,414 tests: {415 spaceAwareType: {416 description: 'only the visualization',417 statusCode: 200,418 response: createExpectVisualizationResults(),419 },420 notSpaceAwareType: {421 description: 'only the globaltype',422 statusCode: 200,423 response: expectNotSpaceAwareResults,424 },425 hiddenType: {426 description: 'forbidden find hiddentype message',427 statusCode: 403,428 response: createExpectRbacForbidden('hiddentype'),429 },430 unknownType: {431 description: 'forbidden find wigwags message',432 statusCode: 403,433 response: createExpectRbacForbidden('wigwags'),434 },435 pageBeyondTotal: {436 description: 'empty result',437 statusCode: 200,438 response: createExpectEmpty(100, 100, 1),439 },440 unknownSearchField: {441 description: 'empty result',442 statusCode: 200,443 response: createExpectEmpty(1, 20, 0),444 },445 noType: {446 description: 'bad request, type is required',447 statusCode: 400,448 response: expectTypeRequired,449 },450 filterWithNotSpaceAwareType: {451 description: 'only the globaltype',452 statusCode: 200,453 response: expectNotSpaceAwareResults,454 },455 filterWithHiddenType: {456 description: 'forbidden find hiddentype message',457 statusCode: 403,458 response: createExpectRbacForbidden('hiddentype'),459 },460 filterWithUnknownType: {461 description: 'forbidden find wigwags message',462 statusCode: 403,463 response: createExpectRbacForbidden('wigwags'),464 },465 filterWithNoType: {466 description: 'bad request, type is required',467 statusCode: 400,468 response: expectTypeRequired,469 },470 filterWithUnAllowedType: {471 description: 'Bad Request',472 statusCode: 400,473 response: expectFilterWrongTypeError,474 },475 },476 });477 findTest(`rbac user with all at default space`, {478 user: AUTHENTICATION.KIBANA_RBAC_DEFAULT_SPACE_ALL_USER,479 tests: {480 spaceAwareType: {481 description: 'only the visualization',482 statusCode: 403,483 response: createExpectRbacForbidden('visualization'),484 },485 notSpaceAwareType: {486 description: 'only the globaltype',487 statusCode: 403,488 response: createExpectRbacForbidden('globaltype'),489 },490 hiddenType: {491 description: 'forbidden find hiddentype message',492 statusCode: 403,493 response: createExpectRbacForbidden('hiddentype'),494 },495 unknownType: {496 description: 'forbidden find wigwags message',497 statusCode: 403,498 response: createExpectRbacForbidden('wigwags'),499 },500 pageBeyondTotal: {501 description: 'empty result',502 statusCode: 403,503 response: createExpectRbacForbidden('visualization'),504 },505 unknownSearchField: {506 description: 'forbidden login and unknown search field',507 statusCode: 403,508 response: createExpectRbacForbidden('url'),509 },510 noType: {511 description: 'bad request, type is required',512 statusCode: 400,513 response: expectTypeRequired,514 },515 filterWithNotSpaceAwareType: {516 description: 'only the globaltype',517 statusCode: 403,518 response: createExpectRbacForbidden('globaltype'),519 },520 filterWithHiddenType: {521 description: 'forbidden find hiddentype message',522 statusCode: 403,523 response: createExpectRbacForbidden('hiddentype'),524 },525 filterWithUnknownType: {526 description: 'forbidden find wigwags message',527 statusCode: 403,528 response: createExpectRbacForbidden('wigwags'),529 },530 filterWithNoType: {531 description: 'bad request, type is required',532 statusCode: 400,533 response: expectTypeRequired,534 },535 filterWithUnAllowedType: {536 description: 'forbidden',537 statusCode: 403,538 response: createExpectRbacForbidden('globaltype'),539 },540 },541 });542 findTest(`rbac user with read at default space`, {543 user: AUTHENTICATION.KIBANA_RBAC_DEFAULT_SPACE_READ_USER,544 tests: {545 spaceAwareType: {546 description: 'only the visualization',547 statusCode: 403,548 response: createExpectRbacForbidden('visualization'),549 },550 notSpaceAwareType: {551 description: 'only the globaltype',552 statusCode: 403,553 response: createExpectRbacForbidden('globaltype'),554 },555 hiddenType: {556 description: 'forbidden find hiddentype message',557 statusCode: 403,558 response: createExpectRbacForbidden('hiddentype'),559 },560 unknownType: {561 description: 'forbidden find wigwags message',562 statusCode: 403,563 response: createExpectRbacForbidden('wigwags'),564 },565 pageBeyondTotal: {566 description: 'empty result',567 statusCode: 403,568 response: createExpectRbacForbidden('visualization'),569 },570 unknownSearchField: {571 description: 'forbidden login and unknown search field',572 statusCode: 403,573 response: createExpectRbacForbidden('url'),574 },575 noType: {576 description: 'bad request, type is required',577 statusCode: 400,578 response: expectTypeRequired,579 },580 filterWithNotSpaceAwareType: {581 description: 'only the globaltype',582 statusCode: 403,583 response: createExpectRbacForbidden('globaltype'),584 },585 filterWithHiddenType: {586 description: 'forbidden find hiddentype message',587 statusCode: 403,588 response: createExpectRbacForbidden('hiddentype'),589 },590 filterWithUnknownType: {591 description: 'forbidden find wigwags message',592 statusCode: 403,593 response: createExpectRbacForbidden('wigwags'),594 },595 filterWithNoType: {596 description: 'bad request, type is required',597 statusCode: 400,598 response: expectTypeRequired,599 },600 filterWithUnAllowedType: {601 description: 'forbidden',602 statusCode: 403,603 response: createExpectRbacForbidden('globaltype'),604 },605 },606 });607 findTest(`rbac user with all at space_1`, {608 user: AUTHENTICATION.KIBANA_RBAC_SPACE_1_ALL_USER,609 tests: {610 spaceAwareType: {611 description: 'only the visualization',612 statusCode: 403,613 response: createExpectRbacForbidden('visualization'),614 },615 notSpaceAwareType: {616 description: 'only the globaltype',617 statusCode: 403,618 response: createExpectRbacForbidden('globaltype'),619 },620 hiddenType: {621 description: 'forbidden find hiddentype message',622 statusCode: 403,623 response: createExpectRbacForbidden('hiddentype'),624 },625 unknownType: {626 description: 'forbidden find wigwags message',627 statusCode: 403,628 response: createExpectRbacForbidden('wigwags'),629 },630 pageBeyondTotal: {631 description: 'empty result',632 statusCode: 403,633 response: createExpectRbacForbidden('visualization'),634 },635 unknownSearchField: {636 description: 'forbidden login and unknown search field',637 statusCode: 403,638 response: createExpectRbacForbidden('url'),639 },640 noType: {641 description: 'bad request, type is required',642 statusCode: 400,643 response: expectTypeRequired,644 },645 filterWithNotSpaceAwareType: {646 description: 'only the globaltype',647 statusCode: 403,648 response: createExpectRbacForbidden('globaltype'),649 },650 filterWithHiddenType: {651 description: 'forbidden find hiddentype message',652 statusCode: 403,653 response: createExpectRbacForbidden('hiddentype'),654 },655 filterWithUnknownType: {656 description: 'forbidden find wigwags message',657 statusCode: 403,658 response: createExpectRbacForbidden('wigwags'),659 },660 filterWithNoType: {661 description: 'bad request, type is required',662 statusCode: 400,663 response: expectTypeRequired,664 },665 filterWithUnAllowedType: {666 description: 'forbidden',667 statusCode: 403,668 response: createExpectRbacForbidden('globaltype'),669 },670 },671 });672 findTest(`rbac user with read at space_1`, {673 user: AUTHENTICATION.KIBANA_RBAC_SPACE_1_READ_USER,674 tests: {675 spaceAwareType: {676 description: 'only the visualization',677 statusCode: 403,678 response: createExpectRbacForbidden('visualization'),679 },680 notSpaceAwareType: {681 description: 'only the globaltype',682 statusCode: 403,683 response: createExpectRbacForbidden('globaltype'),684 },685 hiddenType: {686 description: 'forbidden find hiddentype message',687 statusCode: 403,688 response: createExpectRbacForbidden('hiddentype'),689 },690 unknownType: {691 description: 'forbidden find wigwags message',692 statusCode: 403,693 response: createExpectRbacForbidden('wigwags'),694 },695 pageBeyondTotal: {696 description: 'empty result',697 statusCode: 403,698 response: createExpectRbacForbidden('visualization'),699 },700 unknownSearchField: {701 description: 'forbidden login and unknown search field',702 statusCode: 403,703 response: createExpectRbacForbidden('url'),704 },705 noType: {706 description: 'bad request, type is required',707 statusCode: 400,708 response: expectTypeRequired,709 },710 filterWithNotSpaceAwareType: {711 description: 'only the globaltype',712 statusCode: 403,713 response: createExpectRbacForbidden('globaltype'),714 },715 filterWithHiddenType: {716 description: 'forbidden find hiddentype message',717 statusCode: 403,718 response: createExpectRbacForbidden('hiddentype'),719 },720 filterWithUnknownType: {721 description: 'forbidden find wigwags message',722 statusCode: 403,723 response: createExpectRbacForbidden('wigwags'),724 },725 filterWithNoType: {726 description: 'bad request, type is required',727 statusCode: 400,728 response: expectTypeRequired,729 },730 filterWithUnAllowedType: {731 description: 'forbidden',732 statusCode: 403,733 response: createExpectRbacForbidden('globaltype'),734 },735 },736 });737 });...

Full Screen

Full Screen

bettingCalculator.js

Source:bettingCalculator.js Github

copy

Full Screen

1/**2 * @ngdoc controller3 * @name vbet5.controller:bettingCalculatorController4 * @description stand alone system calculator5 */6angular.module('vbet5').controller('bettingCalculatorController', ['$scope', '$rootScope','Utils', 'analytics', '$location', 'Config', 'BetService', function ($scope, $rootScope ,Utils, analytics, $location, Config, BetService) {7 'use strict';8 /**9 * @ngdoc method10 * @name init11 * @methodOf betting.controller:bettingCalculatorController12 * @description Initialization13 */14 $scope.init = function init() {15 analytics.gaSend('send', 'event', 'betting', 'betting calculator', {16 'page': $location.path(),17 'eventLabel': 'open'18 });19 $scope.calculator = new BetCalculator($scope);20 };21 $scope.resetCalculator = function () {22 $scope.calculator = new BetCalculator($scope);23 };24 /**25 * @ngdoc method26 * @name BetCalculator27 * @methodOf betting.controller:bettingCalculatorController28 * @description Initialization29 */30 function BetCalculator(n) {31 this.container = n;32 this.accumulatorCount = 0;33 this.baseStake = 1;34 this.stake = 10;35 this.perBetStack = 0;36 this.totalStake = 0;37 this.totalOdd = 0;38 this.totalOddEW = 0;39 this.betsCount = 1;40 this.totalProfit = 0;41 this.totalOdd = 0;42 this.maxMultipleEventCount = 20;43 this.maxSystemEventCount = 16;44 this.minSystemEventCount = 3;45 this.enableUKTypes = Config.betting.fullCoverBetTypes.enabled;46 var fullCoverTypesMap = BetService.constants.fullCoverTypesMap;47 var fullCoverAdditionalTypesMap = BetService.constants.fullCoverAdditionalTypesMap;48 this.betTypes = [49 {50 name: "Trixie",51 betCount: 3,52 isAccumulator: true,53 isSingle: false,54 addrow: true,55 removerow: true,56 value: 9,57 globalType: 458 }, {59 name: "Yankee",60 betCount: 4,61 isAccumulator: true,62 isSingle: false,63 addrow: true,64 removerow: true,65 value: 10,66 globalType: 467 }, {68 name: "Canadian / Super Yankee",69 betCount: 5,70 isAccumulator: true,71 isSingle: false,72 addrow: true,73 removerow: true,74 value: 11,75 globalType: 476 }, {77 name: "Patent",78 betCount: 3,79 isAccumulator: true,80 isSingle: true,81 addrow: true,82 removerow: true,83 value: 12,84 globalType: 485 }, {86 name: "Lucky 15",87 betCount: 4,88 isAccumulator: true,89 isSingle: true,90 addrow: true,91 removerow: true,92 value: 13,93 globalType: 494 }, {95 name: "Lucky 31",96 betCount: 5,97 isAccumulator: true,98 isSingle: true,99 addrow: true,100 removerow: true,101 value: 14,102 globalType: 4103 }, {104 name: "Lucky 63",105 betCount: 6,106 isAccumulator: true,107 isSingle: true,108 addrow: true,109 removerow: true,110 value: 15,111 globalType: 4112 }, {113 name: "Heinz",114 betCount: 6,115 isAccumulator: true,116 isSingle: false,117 addrow: true,118 removerow: true,119 value: 16,120 globalType: 4121 }, {122 name: "Super Heinz",123 betCount: 7,124 isAccumulator: true,125 isSingle: false,126 addrow: true,127 removerow: true,128 value: 17,129 globalType: 4130 }, {131 name: "Goliath",132 betCount: 8,133 isAccumulator: true,134 isSingle: false,135 addrow: true,136 removerow: true,137 value: 18,138 globalType: 4139 }, {140 name: "Super Heinz with Singles",141 betCount: 7,142 isAccumulator: true,143 isSingle: true,144 addrow: true,145 removerow: true,146 value: 19,147 globalType: 4148 }, {149 name: "Super Goliath",150 betCount: 8,151 isAccumulator: true,152 isSingle: true,153 addrow: false,154 removerow: true,155 value: 20,156 globalType: 4157 }];158 this.createSystemTypes = function (minSystemEventCount, maxSystemEventCount, withSingles) {159 for (var betCount = minSystemEventCount; betCount <= maxSystemEventCount; betCount++) {160 var _betCount = withSingles ? betCount + 1 : betCount;161 for (var systemValue = minSystemEventCount; systemValue < _betCount; systemValue++) {162 var globalType = 3; // system163 var name = "System " + systemValue + "/" + betCount;164 var isSingle = false;165 var isAccumulator = true;166 if (systemValue !== 1 && systemValue === betCount) {167 globalType = 2; // express168 name = 'Express';169 isAccumulator = false;170 } else if (systemValue === 1) {171 globalType = 1; // single172 name = 'Singles';173 isSingle = true;174 }175 if (this.enableUKTypes) {176 globalType = 4 // uk177 }178 this.betTypes.push(179 {180 name: name,181 betCount: betCount,182 sysValue: systemValue,183 isAccumulator: isAccumulator,184 isSingle: isSingle,185 addrow: maxSystemEventCount !== betCount,186 removerow: betCount > 1,187 value: this.betTypes.length + 1,188 globalType: globalType189 });190 }191 }192 };193 this.createSystemTypes(1,this.maxSystemEventCount,true);194 if (this.enableUKTypes) {195 angular.forEach(this.betTypes, function (type) {196 var betTypes;197 var betType;198 var name;199 if (type.globalType === 4) { // UK200 if (!type.sysValue) {201 betTypes = fullCoverAdditionalTypesMap[type.betCount];202 betType = (betTypes && betTypes[type.isSingle ? 1 : 0]);203 name = betType ? betType.name : null;204 } else {205 betType = fullCoverTypesMap[type.sysValue > 3 ? 'default' : type.sysValue];206 name = (type.sysValue > 3 ? type.sysValue + ' ' + betType : betType);207 }208 type.name = name;209 }210 });211 }212 this.selectedBetType = this.betTypes[23];213 this.ewChecked = false;214 this.rfChecked = false;215 this.dhChecked = false;216 /**217 * @ngdoc method218 * @name decimalOddRounding219 * @methodOf betting.controller:bettingCalculatorController220 * @description decimal odds rounding221 */222 this.decimalOddRounding = function decimalOddRounding(value) { // todo223 return value;224 };225 function formatDecimal(value) {226 return Utils.formatDecimal(value, $rootScope.partnerConfig.price_round_method, $rootScope.partnerConfig.price_decimals);227 }228 function formatMultipleOdd(value) {229 return Utils.formatDecimal(value, $rootScope.partnerConfig.price_round_method, ($rootScope.partnerConfig.multiple_price_decimals || 3));230 }231 function roundPossibleWin(value) {232 return ($rootScope.partnerConfig.multiple_possiblewin_round_method === 0)? Utils.cuttingDecimals(value, $rootScope.conf.balanceFractionSize).toFixed($rootScope.conf.balanceFractionSize) : Utils.bankersRounding(value, $rootScope.conf.balanceFractionSize);233 }234 // Utils.formatDecimal235 this.getSpecialKeys = function () {236 var n = ["Backspace", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Tab"];237 for (i = 1; i <= 12; i++) {238 n.push("F" + i);239 }240 return n;241 };242 this.getCompareValue = function (n, t, i, r) {243 return n.substr(0, t) + r + n.substr(i, n.length);244 };245 this.fractToDecimDown = function (row) {246 var t = parseInt(row.odd_fractional_pricedown),247 i = parseInt(row.odd_fractional_priceup),248 r = i / t + 1;249 row.odd_decimal = this.decimalOddRounding(r);250 this.Calc();251 };252 this.fractToDecim = function (row) {253 var t = parseInt(row.odd_fractional_priceup),254 i = parseInt(row.odd_fractional_pricedown),255 r = t / i + 1;256 row.odd_decimal = this.decimalOddRounding(r);257 this.Calc();258 };259 this.decimToFract = function (row) {260 row.odd_decimal = formatMultipleOdd(row.odd_decimal);261 var t = row.odd_decimal - 1;262 var r = Math.round(t) + "/1";263 var e = Math.round(t);264 var o = Math.abs(e - t), f, u;265 for (var i = 2; i <= 200; i++) if (f = Math.round(t * i) / i, u = Math.abs(f - t), u < o) {266 if (r = Math.round(t * i) + "/" + i, e = f, u == 0) break;267 o = u268 }269 r = r.split("/");270 row.odd_fractional_priceup = parseInt(r[0]) || 1;271 row.odd_fractional_pricedown = parseInt(r[1]) || 1;272 this.Calc();273 };274 this.ToggleEachWay = function () {275 if (!this.ewChecked) {276 for (var i = 0; i < this.BetSlipRows.length; i++) {277 if (this.BetSlipRows[i].wp_option === 'placed') {278 this.BetSlipRows[i].wp_option = 'win';279 }280 }281 }282 this.Calc();283 };284 this.ToggleRule4 = function () {285 this.Calc();286 };287 this.ToggleDeadHeat = function () {288 this.Calc();289 };290 this.GetBetInfo = function (index) {291 var result = {};292 var row = this.BetSlipRows[index];293 if (row) {294 var odd_fractional_priceup = parseInt(row.odd_fractional_priceup);295 var odd_fractional_pricedown = parseInt(row.odd_fractional_pricedown);296 var odd_decimal = this.decimalOddRounding(odd_fractional_pricedown <= 0 || odd_fractional_priceup <= 0 ? Number.NaN : odd_fractional_priceup / odd_fractional_pricedown);297 var ewDecimal = this.decimalOddRounding(row.ew_option);298 var rule4 = parseFloat(row.rule_4) / 100, dh_option;299 (isNaN(rule4) || rule4 < 0 || !this.rfChecked) && (rule4 = 0);300 dh_option = parseInt(row.dh_option);301 (isNaN(dh_option) || !this.dhChecked) && (dh_option = 1);302 result = {303 PriceDecimal: odd_decimal,304 EwDecimal: ewDecimal,305 Rule4: rule4,306 DeadHeat: dh_option,307 Result: row.wp_option308 };309 }310 return result;311 };312 this.systemCombinations = {};313 this.addSystemCompination = function (system) {314 var systemName = this.enableUKTypes ? (system > 3 ? system + ' ' + fullCoverTypesMap['default'] : fullCoverTypesMap[system]) : system;315 if (!this.systemCombinations[systemName]) {316 this.systemCombinations[systemName] = 1;317 } else {318 this.systemCombinations[systemName]++;319 }320 };321 this.Calc = function () {322 var ewChecked = this.ewChecked;323 this.baseStake = 1;324 this.totalOdd = 0;325 this.totalOddEW = 0;326 this.perBetStack = 0;327 this.totalStake = 0;328 this.betsCount = 0;329 this.systemCombinations = {};330 this.CalcOddReturn(0, this.baseStake, this.baseStake);331 if (ewChecked) {332 this.totalOdd += this.totalOddEW;333 this.totalStake = 2 * this.totalStake;334 this.betsCount = 2 * this.betsCount;335 }336 this.perBetStack = formatDecimal(this.selectedStackType === 'total' ? this.stake / this.betsCount: this.stake).toFixed(2);337 var stackK = this.perBetStack / this.baseStake;338 this.totalStake = formatDecimal(this.totalStake * stackK);339 this.totalOdd = this.totalOdd / this.betsCount;340 this.totalWin = roundPossibleWin(this.totalOdd * stackK * this.betsCount);341 this.totalProfit = roundPossibleWin(this.totalWin - this.totalStake);342 };343 this.CalcOddReturn = function (index, totalOdd, odd, system) {344 system = system || 1;345 var betCount = this.selectedBetType.betCount;346 var rowIndex;347 var betInfo;348 var returnOdd;349 var returnEWOdd;350 if (this.accumulatorCount > this.selectedBetType.betCount) {351 betCount = this.accumulatorCount;352 }353 for (rowIndex = index; rowIndex < betCount; rowIndex++) {354 betInfo = this.GetBetInfo(rowIndex);355 if (!(isNaN(betInfo.PriceDecimal) && this.selectedBetType.name === "Accumulator")) {356 returnOdd = this.calcReturnOdds(totalOdd, false, betInfo);357 returnEWOdd = this.calcReturnOdds(odd, true, betInfo);358 if (this.selectedBetType.isAccumulator) {359 if ((index !== 0) || this.selectedBetType.isSingle) {360 if (this.selectedBetType.sysValue) {361 if (this.selectedBetType.sysValue === system) {362 this.totalOdd += formatMultipleOdd(returnOdd);363 this.totalOddEW += formatMultipleOdd(returnEWOdd);364 this.totalStake += this.baseStake;365 this.betsCount++;366 this.addSystemCompination(system);367 }368 } else {369 this.totalOdd += formatMultipleOdd(returnOdd);370 this.totalOddEW += formatMultipleOdd(returnEWOdd);371 this.totalStake += this.baseStake;372 this.betsCount++;373 this.addSystemCompination(system);374 }375 }376 this.CalcOddReturn(rowIndex + 1, returnOdd, returnEWOdd, 1 + (system || 1));377 } else {378 this.totalOdd = returnOdd;379 totalOdd = returnOdd;380 this.totalOddEW = returnEWOdd;381 odd = returnEWOdd;382 this.totalStake = this.baseStake;383 this.betsCount = 1;384 }385 }386 }387 };388 this.calcReturnOdds = function (odd, ew, betInfo) {389 if (betInfo.Result === 'return') {390 betInfo.PriceDecimal = 0;391 betInfo.EwDecimal = 0;392 betInfo.Result = 'win';393 }394 var result;395 if (betInfo.Result === "lost") {396 result = 0;397 } else {398 if (!ew && betInfo.Result === "win") {399 result = (odd + betInfo.PriceDecimal * odd - betInfo.PriceDecimal * odd * betInfo.Rule4) / betInfo.DeadHeat400 } else {401 if (ew && (betInfo.Result === "win" || betInfo.Result === "placed")) {402 result = odd + betInfo.PriceDecimal * betInfo.EwDecimal * odd - betInfo.PriceDecimal * betInfo.EwDecimal * odd * betInfo.Rule4403 } else {404 result = 0;405 }406 }407 }408 return result;409 };410 this.setOptionForAll = function (option_name, value) {411 for (var i = 0; i < this.BetSlipRows.length; i++) {412 this.BetSlipRows[i][option_name] = value;413 }414 this.Calc();415 };416 this.ewOptions = [417 {name: '1/1', value: "1"},418 {name: '1/2', value: "0.5"},419 {name: '1/3', value: "0.333333"},420 {name: '1/4', value: "0.25"},421 {name: '1/5', value: "0.2"}422 ];423 this.dhOptions = [424 {425 name: '-',426 value: '1'427 },428 {429 name: '2 horses',430 value: '2'431 },432 {433 name: '3 horses',434 value: '3'435 },436 {437 name: '4 horses',438 value: '4'439 }440 ];441 this.wpOptions = [442 {443 name: 'Win',444 value: 'win'445 },446 {447 name: 'Lose',448 value: 'lost'449 },450 {451 name: 'Returned',452 value: 'return'453 },454 {455 name: 'Placed',456 value: 'placed'457 }458 ];459 this.oddTypes = [460 {name: 'Decimal', value: 'decimal'},461 {name: 'Fractional', value: 'fractional'}462 ];463 this.stackTypes = [464 {name: 'Per Selection', value: 'unit'},465 {name: 'Total combined bet', value: 'total'}466 ];467 this.selectedStackType = this.stackTypes[0].value;468 this.filterOddTypes = function () {469 var filteredOddTypes = [];470 var oddTypes = this.oddTypes;471 angular.forEach(Config.main.oddFormats, function (confType) {472 angular.forEach(oddTypes, function (type) {473 if (confType.format === type.value) {474 filteredOddTypes.push(type);475 }476 });477 });478 if (filteredOddTypes.length) {479 this.oddTypes = filteredOddTypes;480 } else {481 this.oddTypes = [oddTypes[0]];482 }483 };484 this.filterOddTypes();485 this.selectedOddType = this.oddTypes[0].value;486 this.BetSlipRows = [{487 odd_decimal: 2,488 odd_fractional_priceup: 1,489 odd_fractional_pricedown: 1,490 ew_option: this.ewOptions[2].value,491 rule_4: 0,492 dh_option: '1',493 wp_option: 'win'494 }];495 this.BuildBetSlipRows = function (betCount /*n*/, rowCount /*t*/, i) {496 var o, f, r, s, u, e;497 if (betCount < rowCount) {498 this.BetSlipRows = this.BetSlipRows.slice(0, betCount)499 } else {500 for (o = betCount - rowCount, f = 0; f < o; f++) {501 r = angular.copy(this.BetSlipRows[0]);502 r.odd_decimal = 2;503 r.wp_option = 'win';504 r.odd_fractional_priceup = r.odd_fractional_pricedown = 1;505 this.BetSlipRows.push(r);506 u = this;507 }508 }509 };510 this.filterBetTypes = function () {511 var eventsCount = this.BetSlipRows.length;512 var enableUKtypes = this.enableUKTypes;513 var selectedBetTypeGlobalType = this.selectedBetType && this.selectedBetType.globalType;514 this.filteredBetTypes = this.betTypes.filter(function (type) {515 return type.betCount === eventsCount && type.name && (!enableUKtypes ? type.globalType !== 4 : true);516 });517 this.selectedBetType = this.filteredBetTypes[0];518 if(selectedBetTypeGlobalType && this.filteredBetTypes.length > 1 && this.filteredBetTypes[0].globalType !== selectedBetTypeGlobalType){519 var filteredByGlobalType = this.filteredBetTypes.filter(function (type) {520 return type.globalType === selectedBetTypeGlobalType;521 });522 if(filteredByGlobalType && filteredByGlobalType.length){523 this.selectedBetType = filteredByGlobalType[0];524 }525 }526 };527 this.CreateBetList = function () {528 if (this.selectedBetType) {529 var rowCount = this.BetSlipRows.length;530 var betCount = this.selectedBetType.betCount;531 this.selectedBetType.name !== "Accumulator" ? this.accumulatorCount = 0 : betCount = rowCount;532 if (this.selectedBetType !== null) {533 this.BuildBetSlipRows(betCount, rowCount, false);534 this.Calc();535 }536 }537 };538 this.addRow = function () {539 var n = this.BetSlipRows.length;540 this.BuildBetSlipRows(n + 1, n, false);541 this.filterBetTypes();542 this.Calc();543 };544 this.removeRow = function (index) {545 this.BetSlipRows.splice(index, 1);546 this.accumulatorCount--;547 var n = this.BetSlipRows.length - 1;548 this.BuildBetSlipRows(this.BetSlipRows.length, this.BetSlipRows.length, true);549 this.filterBetTypes();550 this.Calc();551 };552 this.filterBetTypes();553 this.CreateBetList();554 }...

Full Screen

Full Screen

catsAction.ts

Source:catsAction.ts Github

copy

Full Screen

1import catAPI from 'api/catApi'2import { AxiosResponse } from 'axios'3import { BreedType, CatsType, GlobalType } from 'enums/actionTypes'4import { Pagination } from 'enums/pagination'5import { SearchParamsType } from 'interfaces/searchParams'6import { AppDispatch } from 'store'7export const getCatBreed = (params: SearchParamsType) => async (dispatch: AppDispatch) => {8 dispatch({9 type: GlobalType.LOADING_START,10 payload: false11 })12 const { id, page, limit } = params13 const queryParams = {14 params: {15 breed_id: id,16 page: page ?? 1,17 limit: limit ?? 10,18 order: 'ASC'19 }20 }21 try {22 const { data }: AxiosResponse = await catAPI.get('/images/search', queryParams)23 if (data.length < queryParams.params.limit) {24 dispatch({25 type: BreedType.BREED_LIST_FINAL,26 payload: { ...queryParams.params, final: true, count: data.length }27 })28 }29 return (30 dispatch({31 type: CatsType.GET_CAT_BREED,32 payload: { breed: id, data }33 }),34 dispatch({35 type: GlobalType.LOADING_STOP,36 payload: false37 }),38 dispatch({39 type: BreedType.BREED_LIST_INCREMENT,40 payload: { ...queryParams.params, count: data.length }41 })42 )43 } catch (error: any) {44 dispatch({45 type: GlobalType.LOADING_STOP,46 payload: false47 })48 dispatch({49 type: GlobalType.ERROR,50 payload: {51 show: true,52 message: 'Apologies but we could not load new cats for you at this time! Miau!'53 }54 })55 }56}57export const getCat = (id: string, breed: string) => async (dispatch: AppDispatch) => {58 dispatch({59 type: GlobalType.LOADING_START,60 payload: false61 })62 try {63 const { data }: AxiosResponse = await catAPI.get(`/images/${id}`)64 return (65 dispatch({66 type: CatsType.GET_CAT,67 payload: { breed, data }68 }),69 dispatch({70 type: GlobalType.LOADING_STOP,71 payload: false72 })73 )74 } catch (error) {75 dispatch({76 type: GlobalType.LOADING_STOP,77 payload: false78 })79 dispatch({80 type: GlobalType.ERROR,81 payload: {82 show: true,83 message: 'Apologies, the cat is not home! Miau!'84 }85 })86 }87}88export const getCatBreedList = () => async (dispatch: AppDispatch) => {89 dispatch({90 type: GlobalType.LOADING_START,91 payload: false92 })93 try {94 const { data }: AxiosResponse = await catAPI.get(`/breeds`)95 const dropDownObject = data.map(({ id, name }: { id: string, name: string }) => {96 return {97 id,98 name,99 page: Pagination.DEFAULT_PAGE_NO,100 limit: Pagination.DEFAULT_LIMIT,101 final: false,102 count: 0103 }104 })105 return (106 dispatch({107 type: CatsType.GET_CAT_BREED_LIST,108 payload: dropDownObject109 }),110 dispatch({111 type: GlobalType.LOADING_STOP,112 payload: false113 })114 )115 } catch (error) {116 dispatch({117 type: GlobalType.LOADING_STOP,118 payload: false119 })120 dispatch({121 type: GlobalType.ERROR,122 payload: {123 show: true,124 message: 'Apologies, the cats are busy at the moment! Miau!'125 }126 })127 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { globalType } = require('wpt');2const { globalType } = require('wpt');3const { globalType } = require('wpt');4const { globalType } = require('wpt');5const { globalType } = require('wpt');6const { globalType } = require('wpt');7const { globalType } = require('wpt');8const { globalType } = require('wpt');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var test = new wpt(options);5 if (err) return console.error(err);6 console.log('Test submitted to WebPagetest for %s', data.data.testUrl);7 test.getTestStatus(data.data.testId, function(err, data) {8 if (err) return console.error(err);9 console.log('Test status for %s: %s', data.data.testId, data.data.statusText);10 });11});

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