How to use report method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

countries.js

Source:countries.js Github

copy

Full Screen

1module.exports = [2 {3 "label": "Afghanistan",4 "value": "AFG",5 "region": "Asia",6 "subregion": "Southern Asia",7 "supported_identity_report": true8 },9 {10 "label": "Albania",11 "value": "ALB",12 "region": "Europe",13 "subregion": "Southern Europe",14 "supported_identity_report": true15 },16 {17 "label": "Algeria",18 "value": "DZA",19 "region": "Africa",20 "subregion": "Northern Africa",21 "supported_identity_report": true22 },23 {24 "label": "Andorra",25 "value": "AND",26 "region": "Europe",27 "subregion": "Southern Europe",28 "supported_identity_report": true29 },30 {31 "label": "Antigua and Barbuda",32 "value": "ATG",33 "region": "Americas",34 "subregion": "Caribbean",35 "supported_identity_report": true36 },37 {38 "label": "Argentina",39 "value": "ARG",40 "region": "Americas",41 "subregion": "South America",42 "supported_identity_report": true43 },44 {45 "label": "Armenia",46 "value": "ARM",47 "region": "Asia",48 "subregion": "Western Asia",49 "supported_identity_report": true50 },51 {52 "label": "Aruba",53 "value": "ABW",54 "region": "Americas",55 "subregion": "Caribbean",56 "supported_identity_report": true57 },58 {59 "label": "Australia",60 "value": "AUS",61 "region": "Oceania",62 "subregion": "Australia and New Zealand",63 "supported_identity_report": true64 },65 {66 "label": "Austria",67 "value": "AUT",68 "region": "Europe",69 "subregion": "Western Europe",70 "supported_identity_report": true71 },72 {73 "label": "Azerbaijan",74 "value": "AZE",75 "region": "Asia",76 "subregion": "Western Asia",77 "supported_identity_report": true78 },79 {80 "label": "Bahrain",81 "value": "BHR",82 "region": "Asia",83 "subregion": "Western Asia",84 "supported_identity_report": true85 },86 {87 "label": "Barbados",88 "value": "BRB",89 "region": "Americas",90 "subregion": "Caribbean",91 "supported_identity_report": true92 },93 {94 "label": "Belarus",95 "value": "BLR",96 "region": "Europe",97 "subregion": "Eastern Europe",98 "supported_identity_report": true99 },100 {101 "label": "Belgium",102 "value": "BEL",103 "region": "Europe",104 "subregion": "Western Europe",105 "supported_identity_report": true106 },107 {108 "label": "Belize",109 "value": "BLZ",110 "region": "Americas",111 "subregion": "Central America",112 "supported_identity_report": true113 },114 {115 "label": "Benin",116 "value": "BEN",117 "region": "Africa",118 "subregion": "Western Africa",119 "supported_identity_report": true120 },121 {122 "label": "Bermuda",123 "value": "BMU",124 "region": "Americas",125 "subregion": "Northern America",126 "supported_identity_report": true127 },128 {129 "label": "Bhutan",130 "value": "BTN",131 "region": "Asia",132 "subregion": "Southern Asia",133 "supported_identity_report": true134 },135 {136 "label": "Bosnia and Herzegovina",137 "value": "BIH",138 "region": "Europe",139 "subregion": "Southern Europe",140 "supported_identity_report": true141 },142 {143 "label": "Brazil",144 "value": "BRA",145 "region": "Americas",146 "subregion": "South America",147 "supported_identity_report": true148 },149 {150 "label": "Brunei Darussalam",151 "value": "BRN",152 "region": "Asia",153 "subregion": "South-Eastern Asia",154 "supported_identity_report": true155 },156 {157 "label": "Bulgaria",158 "value": "BGR",159 "region": "Europe",160 "subregion": "Eastern Europe",161 "supported_identity_report": true162 },163 {164 "label": "Burkina Faso",165 "value": "BFA",166 "region": "Africa",167 "subregion": "Western Africa",168 "supported_identity_report": true169 },170 {171 "label": "Burundi",172 "value": "BDI",173 "region": "Africa",174 "subregion": "Eastern Africa",175 "supported_identity_report": true176 },177 {178 "label": "Cambodia",179 "value": "KHM",180 "region": "Asia",181 "subregion": "South-Eastern Asia",182 "supported_identity_report": true183 },184 {185 "label": "Cameroon",186 "value": "CMR",187 "region": "Africa",188 "subregion": "Middle Africa",189 "supported_identity_report": true190 },191 {192 "label": "Canada",193 "value": "CAN",194 "region": "Americas",195 "subregion": "Northern America",196 "supported_identity_report": true197 },198 {199 "label": "Cayman Islands",200 "value": "CYM",201 "region": "Americas",202 "subregion": "Caribbean",203 "supported_identity_report": true204 },205 {206 "label": "Central African Republic",207 "value": "CAF",208 "region": "Africa",209 "subregion": "Middle Africa",210 "supported_identity_report": true211 },212 {213 "label": "Chile",214 "value": "CHL",215 "region": "Americas",216 "subregion": "South America",217 "supported_identity_report": true218 },219 {220 "label": "China",221 "value": "CHN",222 "region": "Asia",223 "subregion": "Eastern Asia",224 "supported_identity_report": true225 },226 {227 "label": "Colombia",228 "value": "COL",229 "region": "Americas",230 "subregion": "South America",231 "supported_identity_report": true232 },233 {234 "label": "Congo",235 "value": "COG",236 "region": "Africa",237 "subregion": "Middle Africa",238 "supported_identity_report": true239 },240 {241 "label": "Cook Islands",242 "value": "COK",243 "region": "Oceania",244 "subregion": "Polynesia",245 "supported_identity_report": true246 },247 {248 "label": "Costa Rica",249 "value": "CRI",250 "region": "Americas",251 "subregion": "Central America",252 "supported_identity_report": true253 },254 {255 "label": "Croatia",256 "value": "HRV",257 "region": "Europe",258 "subregion": "Southern Europe",259 "supported_identity_report": true260 },261 {262 "label": "Cuba",263 "value": "CUB",264 "region": "Americas",265 "subregion": "Caribbean",266 "supported_identity_report": true267 },268 {269 "label": "Cyprus",270 "value": "CYP",271 "region": "Asia",272 "subregion": "Western Asia",273 "supported_identity_report": true274 },275 {276 "label": "Czechia",277 "value": "CZE",278 "region": "Europe",279 "subregion": "Eastern Europe",280 "supported_identity_report": true281 },282 {283 "label": "Côte d'Ivoire",284 "value": "CIV",285 "region": "Africa",286 "subregion": "Western Africa",287 "supported_identity_report": true288 },289 {290 "label": "Denmark",291 "value": "DNK",292 "region": "Europe",293 "subregion": "Northern Europe",294 "supported_identity_report": true295 },296 {297 "label": "Djibouti",298 "value": "DJI",299 "region": "Africa",300 "subregion": "Eastern Africa",301 "supported_identity_report": true302 },303 {304 "label": "Dominica",305 "value": "DMA",306 "region": "Americas",307 "subregion": "Caribbean",308 "supported_identity_report": true309 },310 {311 "label": "Dominican Republic",312 "value": "DOM",313 "region": "Americas",314 "subregion": "Caribbean",315 "supported_identity_report": true316 },317 {318 "label": "Ecuador",319 "value": "ECU",320 "region": "Americas",321 "subregion": "South America",322 "supported_identity_report": true323 },324 {325 "label": "Egypt",326 "value": "EGY",327 "region": "Africa",328 "subregion": "Northern Africa",329 "supported_identity_report": true330 },331 {332 "label": "El Salvador",333 "value": "SLV",334 "region": "Americas",335 "subregion": "Central America",336 "supported_identity_report": true337 },338 {339 "label": "Equatorial Guinea",340 "value": "GNQ",341 "region": "Africa",342 "subregion": "Middle Africa",343 "supported_identity_report": true344 },345 {346 "label": "Estonia",347 "value": "EST",348 "region": "Europe",349 "subregion": "Northern Europe",350 "supported_identity_report": true351 },352 {353 "label": "Ethiopia",354 "value": "ETH",355 "region": "Africa",356 "subregion": "Eastern Africa",357 "supported_identity_report": true358 },359 {360 "label": "Faroe Islands",361 "value": "FRO",362 "region": "Europe",363 "subregion": "Northern Europe",364 "supported_identity_report": true365 },366 {367 "label": "Fiji",368 "value": "FJI",369 "region": "Oceania",370 "subregion": "Melanesia",371 "supported_identity_report": true372 },373 {374 "label": "Finland",375 "value": "FIN",376 "region": "Europe",377 "subregion": "Northern Europe",378 "supported_identity_report": true379 },380 {381 "label": "France",382 "value": "FRA",383 "region": "Europe",384 "subregion": "Western Europe",385 "supported_identity_report": true386 },387 {388 "label": "Gabon",389 "value": "GAB",390 "region": "Africa",391 "subregion": "Middle Africa",392 "supported_identity_report": true393 },394 {395 "label": "Georgia",396 "value": "GEO",397 "region": "Asia",398 "subregion": "Western Asia",399 "supported_identity_report": true400 },401 {402 "label": "Germany",403 "value": "DEU",404 "region": "Europe",405 "subregion": "Western Europe",406 "supported_identity_report": true407 },408 {409 "label": "Gibraltar",410 "value": "GIB",411 "region": "Europe",412 "subregion": "Southern Europe",413 "supported_identity_report": true414 },415 {416 "label": "Greece",417 "value": "GRC",418 "region": "Europe",419 "subregion": "Southern Europe",420 "supported_identity_report": true421 },422 {423 "label": "Grenada",424 "value": "GRD",425 "region": "Americas",426 "subregion": "Caribbean",427 "supported_identity_report": true428 },429 {430 "label": "Guatemala",431 "value": "GTM",432 "region": "Americas",433 "subregion": "Central America",434 "supported_identity_report": true435 },436 {437 "label": "Guernsey",438 "value": "GGY",439 "region": "Europe",440 "subregion": "Northern Europe",441 "supported_identity_report": true442 },443 {444 "label": "Guinea",445 "value": "GIN",446 "region": "Africa",447 "subregion": "Western Africa",448 "supported_identity_report": true449 },450 {451 "label": "Honduras",452 "value": "HND",453 "region": "Americas",454 "subregion": "Central America",455 "supported_identity_report": true456 },457 {458 "label": "Hong Kong",459 "value": "HKG",460 "region": "Asia",461 "subregion": "Eastern Asia",462 "supported_identity_report": true463 },464 {465 "label": "Hungary",466 "value": "HUN",467 "region": "Europe",468 "subregion": "Eastern Europe",469 "supported_identity_report": true470 },471 {472 "label": "Iceland",473 "value": "ISL",474 "region": "Europe",475 "subregion": "Northern Europe",476 "supported_identity_report": true477 },478 {479 "label": "India",480 "value": "IND",481 "region": "Asia",482 "subregion": "Southern Asia",483 "supported_identity_report": true484 },485 {486 "label": "Indonesia",487 "value": "IDN",488 "region": "Asia",489 "subregion": "South-Eastern Asia",490 "supported_identity_report": true491 },492 {493 "label": "Iran (Islamic Republic of)",494 "value": "IRN",495 "region": "Asia",496 "subregion": "Southern Asia",497 "supported_identity_report": true498 },499 {500 "label": "Ireland",501 "value": "IRL",502 "region": "Europe",503 "subregion": "Northern Europe",504 "supported_identity_report": true505 },506 {507 "label": "Isle of Man",508 "value": "IMN",509 "region": "Europe",510 "subregion": "Northern Europe",511 "supported_identity_report": true512 },513 {514 "label": "Israel",515 "value": "ISR",516 "region": "Asia",517 "subregion": "Western Asia",518 "supported_identity_report": true519 },520 {521 "label": "Italy",522 "value": "ITA",523 "region": "Europe",524 "subregion": "Southern Europe",525 "supported_identity_report": true526 },527 {528 "label": "Jamaica",529 "value": "JAM",530 "region": "Americas",531 "subregion": "Caribbean",532 "supported_identity_report": true533 },534 {535 "label": "Japan",536 "value": "JPN",537 "region": "Asia",538 "subregion": "Eastern Asia",539 "supported_identity_report": true540 },541 {542 "label": "Jersey",543 "value": "JEY",544 "region": "Europe",545 "subregion": "Northern Europe",546 "supported_identity_report": true547 },548 {549 "label": "Kazakhstan",550 "value": "KAZ",551 "region": "Asia",552 "subregion": "Central Asia",553 "supported_identity_report": true554 },555 {556 "label": "Kenya",557 "value": "KEN",558 "region": "Africa",559 "subregion": "Eastern Africa",560 "supported_identity_report": true561 },562 {563 "label": "Korea (Republic of)",564 "value": "KOR",565 "region": "Asia",566 "subregion": "Eastern Asia",567 "supported_identity_report": true568 },569 {570 "label": "Kuwait",571 "value": "KWT",572 "region": "Asia",573 "subregion": "Western Asia",574 "supported_identity_report": true575 },576 {577 "label": "Kyrgyzstan",578 "value": "KGZ",579 "region": "Asia",580 "subregion": "Central Asia",581 "supported_identity_report": true582 },583 {584 "label": "Latvia",585 "value": "LVA",586 "region": "Europe",587 "subregion": "Northern Europe",588 "supported_identity_report": true589 },590 {591 "label": "Lebanon",592 "value": "LBN",593 "region": "Asia",594 "subregion": "Western Asia",595 "supported_identity_report": true596 },597 {598 "label": "Lesotho",599 "value": "LSO",600 "region": "Africa",601 "subregion": "Southern Africa",602 "supported_identity_report": true603 },604 {605 "label": "Libya",606 "value": "LBY",607 "region": "Africa",608 "subregion": "Northern Africa",609 "supported_identity_report": true610 },611 {612 "label": "Liechtenstein",613 "value": "LIE",614 "region": "Europe",615 "subregion": "Western Europe",616 "supported_identity_report": true617 },618 {619 "label": "Lithuania",620 "value": "LTU",621 "region": "Europe",622 "subregion": "Northern Europe",623 "supported_identity_report": true624 },625 {626 "label": "Luxembourg",627 "value": "LUX",628 "region": "Europe",629 "subregion": "Western Europe",630 "supported_identity_report": true631 },632 {633 "label": "Malawi",634 "value": "MWI",635 "region": "Africa",636 "subregion": "Eastern Africa",637 "supported_identity_report": true638 },639 {640 "label": "Malaysia",641 "value": "MYS",642 "region": "Asia",643 "subregion": "South-Eastern Asia",644 "supported_identity_report": true645 },646 {647 "label": "Mali",648 "value": "MLI",649 "region": "Africa",650 "subregion": "Western Africa",651 "supported_identity_report": true652 },653 {654 "label": "Malta",655 "value": "MLT",656 "region": "Europe",657 "subregion": "Southern Europe",658 "supported_identity_report": true659 },660 {661 "label": "Mauritania",662 "value": "MRT",663 "region": "Africa",664 "subregion": "Western Africa",665 "supported_identity_report": true666 },667 {668 "label": "Mexico",669 "value": "MEX",670 "region": "Americas",671 "subregion": "Central America",672 "supported_identity_report": true673 },674 {675 "label": "Moldova (Republic of)",676 "value": "MDA",677 "region": "Europe",678 "subregion": "Eastern Europe",679 "supported_identity_report": true680 },681 {682 "label": "Monaco",683 "value": "MCO",684 "region": "Europe",685 "subregion": "Western Europe",686 "supported_identity_report": true687 },688 {689 "label": "Montenegro",690 "value": "MNE",691 "region": "Europe",692 "subregion": "Southern Europe",693 "supported_identity_report": true694 },695 {696 "label": "Montserrat",697 "value": "MSR",698 "region": "Americas",699 "subregion": "Caribbean",700 "supported_identity_report": true701 },702 {703 "label": "Morocco",704 "value": "MAR",705 "region": "Africa",706 "subregion": "Northern Africa",707 "supported_identity_report": true708 },709 {710 "label": "Namibia",711 "value": "NAM",712 "region": "Africa",713 "subregion": "Southern Africa",714 "supported_identity_report": true715 },716 {717 "label": "Nepal",718 "value": "NPL",719 "region": "Asia",720 "subregion": "Southern Asia",721 "supported_identity_report": true722 },723 {724 "label": "Netherlands",725 "value": "NLD",726 "region": "Europe",727 "subregion": "Western Europe",728 "supported_identity_report": true729 },730 {731 "label": "New Zealand",732 "value": "NZL",733 "region": "Oceania",734 "subregion": "Australia and New Zealand",735 "supported_identity_report": true736 },737 {738 "label": "Nicaragua",739 "value": "NIC",740 "region": "Americas",741 "subregion": "Central America",742 "supported_identity_report": true743 },744 {745 "label": "Niger",746 "value": "NER",747 "region": "Africa",748 "subregion": "Western Africa",749 "supported_identity_report": true750 },751 {752 "label": "Nigeria",753 "value": "NGA",754 "region": "Africa",755 "subregion": "Western Africa",756 "supported_identity_report": true757 },758 {759 "label": "Norfolk Island",760 "value": "NFK",761 "region": "Oceania",762 "subregion": "Australia and New Zealand",763 "supported_identity_report": true764 },765 {766 "label": "Norway",767 "value": "NOR",768 "region": "Europe",769 "subregion": "Northern Europe",770 "supported_identity_report": true771 },772 {773 "label": "Oman",774 "value": "OMN",775 "region": "Asia",776 "subregion": "Western Asia",777 "supported_identity_report": true778 },779 {780 "label": "Pakistan",781 "value": "PAK",782 "region": "Asia",783 "subregion": "Southern Asia",784 "supported_identity_report": true785 },786 {787 "label": "Palestine, State of",788 "value": "PSE",789 "region": "Asia",790 "subregion": "Western Asia",791 "supported_identity_report": true792 },793 {794 "label": "Panama",795 "value": "PAN",796 "region": "Americas",797 "subregion": "Central America",798 "supported_identity_report": true799 },800 {801 "label": "Paraguay",802 "value": "PRY",803 "region": "Americas",804 "subregion": "South America",805 "supported_identity_report": true806 },807 {808 "label": "Peru",809 "value": "PER",810 "region": "Americas",811 "subregion": "South America",812 "supported_identity_report": true813 },814 {815 "label": "Philippines",816 "value": "PHL",817 "region": "Asia",818 "subregion": "South-Eastern Asia",819 "supported_identity_report": true820 },821 {822 "label": "Poland",823 "value": "POL",824 "region": "Europe",825 "subregion": "Eastern Europe",826 "supported_identity_report": true827 },828 {829 "label": "Portugal",830 "value": "PRT",831 "region": "Europe",832 "subregion": "Southern Europe",833 "supported_identity_report": true834 },835 {836 "label": "Puerto Rico",837 "value": "PRI",838 "region": "Americas",839 "subregion": "Caribbean",840 "supported_identity_report": true841 },842 {843 "label": "Qatar",844 "value": "QAT",845 "region": "Asia",846 "subregion": "Western Asia",847 "supported_identity_report": true848 },849 {850 "label": "Romania",851 "value": "ROU",852 "region": "Europe",853 "subregion": "Eastern Europe",854 "supported_identity_report": true855 },856 {857 "label": "Russian Federation",858 "value": "RUS",859 "region": "Europe",860 "subregion": "Eastern Europe",861 "supported_identity_report": true862 },863 {864 "label": "Saint Kitts and Nevis",865 "value": "KNA",866 "region": "Americas",867 "subregion": "Caribbean",868 "supported_identity_report": true869 },870 {871 "label": "Saint Lucia",872 "value": "LCA",873 "region": "Americas",874 "subregion": "Caribbean",875 "supported_identity_report": true876 },877 {878 "label": "Saint Vincent and the Grenadines",879 "value": "VCT",880 "region": "Americas",881 "subregion": "Caribbean",882 "supported_identity_report": true883 },884 {885 "label": "Samoa",886 "value": "WSM",887 "region": "Oceania",888 "subregion": "Polynesia",889 "supported_identity_report": true890 },891 {892 "label": "Saudi Arabia",893 "value": "SAU",894 "region": "Asia",895 "subregion": "Western Asia",896 "supported_identity_report": true897 },898 {899 "label": "Serbia",900 "value": "SRB",901 "region": "Europe",902 "subregion": "Southern Europe",903 "supported_identity_report": true904 },905 {906 "label": "Singapore",907 "value": "SGP",908 "region": "Asia",909 "subregion": "South-Eastern Asia",910 "supported_identity_report": true911 },912 {913 "label": "Slovakia",914 "value": "SVK",915 "region": "Europe",916 "subregion": "Eastern Europe",917 "supported_identity_report": true918 },919 {920 "label": "Slovenia",921 "value": "SVN",922 "region": "Europe",923 "subregion": "Southern Europe",924 "supported_identity_report": true925 },926 {927 "label": "Somalia",928 "value": "SOM",929 "region": "Africa",930 "subregion": "Eastern Africa",931 "supported_identity_report": true932 },933 {934 "label": "South Africa",935 "value": "ZAF",936 "region": "Africa",937 "subregion": "Southern Africa",938 "supported_identity_report": true939 },940 {941 "label": "Spain",942 "value": "ESP",943 "region": "Europe",944 "subregion": "Southern Europe",945 "supported_identity_report": true946 },947 {948 "label": "Sri Lanka",949 "value": "LKA",950 "region": "Asia",951 "subregion": "Southern Asia",952 "supported_identity_report": true953 },954 {955 "label": "Sudan",956 "value": "SDN",957 "region": "Africa",958 "subregion": "Northern Africa",959 "supported_identity_report": true960 },961 {962 "label": "Sweden",963 "value": "SWE",964 "region": "Europe",965 "subregion": "Northern Europe",966 "supported_identity_report": true967 },968 {969 "label": "Switzerland",970 "value": "CHE",971 "region": "Europe",972 "subregion": "Western Europe",973 "supported_identity_report": true974 },975 {976 "label": "Syrian Arab Republic",977 "value": "SYR",978 "region": "Asia",979 "subregion": "Western Asia",980 "supported_identity_report": true981 },982 {983 "label": "Taiwan, Province of China",984 "value": "TWN",985 "region": "Asia",986 "subregion": "Eastern Asia",987 "supported_identity_report": true988 },989 {990 "label": "Tajikistan",991 "value": "TJK",992 "region": "Asia",993 "subregion": "Central Asia",994 "supported_identity_report": true995 },996 {997 "label": "Tanzania, United Republic of",998 "value": "TZA",999 "region": "Africa",1000 "subregion": "Eastern Africa",1001 "supported_identity_report": true1002 },1003 {1004 "label": "Thailand",1005 "value": "THA",1006 "region": "Asia",1007 "subregion": "South-Eastern Asia",1008 "supported_identity_report": true1009 },1010 {1011 "label": "Togo",1012 "value": "TGO",1013 "region": "Africa",1014 "subregion": "Western Africa",1015 "supported_identity_report": true1016 },1017 {1018 "label": "Trinidad and Tobago",1019 "value": "TTO",1020 "region": "Americas",1021 "subregion": "Caribbean",1022 "supported_identity_report": true1023 },1024 {1025 "label": "Tunisia",1026 "value": "TUN",1027 "region": "Africa",1028 "subregion": "Northern Africa",1029 "supported_identity_report": true1030 },1031 {1032 "label": "Turkey",1033 "value": "TUR",1034 "region": "Asia",1035 "subregion": "Western Asia",1036 "supported_identity_report": true1037 },1038 {1039 "label": "Turkmenistan",1040 "value": "TKM",1041 "region": "Asia",1042 "subregion": "Central Asia",1043 "supported_identity_report": true1044 },1045 {1046 "label": "Turks and Caicos Islands",1047 "value": "TCA",1048 "region": "Americas",1049 "subregion": "Caribbean",1050 "supported_identity_report": true1051 },1052 {1053 "label": "Tuvalu",1054 "value": "TUV",1055 "region": "Oceania",1056 "subregion": "Polynesia",1057 "supported_identity_report": true1058 },1059 {1060 "label": "Uganda",1061 "value": "UGA",1062 "region": "Africa",1063 "subregion": "Eastern Africa",1064 "supported_identity_report": true1065 },1066 {1067 "label": "Ukraine",1068 "value": "UKR",1069 "region": "Europe",1070 "subregion": "Eastern Europe",1071 "supported_identity_report": true1072 },1073 {1074 "label": "United Arab Emirates",1075 "value": "ARE",1076 "region": "Asia",1077 "subregion": "Western Asia",1078 "supported_identity_report": true1079 },1080 {1081 "label": "United Kingdom of Great Britain and Northern Ireland",1082 "value": "GBR",1083 "region": "Europe",1084 "subregion": "Northern Europe",1085 "supported_identity_report": true1086 },1087 {1088 "label": "United States of America",1089 "value": "USA",1090 "region": "Americas",1091 "subregion": "Northern America",1092 "supported_identity_report": true1093 },1094 {1095 "label": "Uzbekistan",1096 "value": "UZB",1097 "region": "Asia",1098 "subregion": "Central Asia",1099 "supported_identity_report": true1100 },1101 {1102 "label": "Vanuatu",1103 "value": "VUT",1104 "region": "Oceania",1105 "subregion": "Melanesia",1106 "supported_identity_report": true1107 },1108 {1109 "label": "Venezuela (Bolivarian Republic of)",1110 "value": "VEN",1111 "region": "Americas",1112 "subregion": "South America",1113 "supported_identity_report": true1114 },1115 {1116 "label": "Viet Nam",1117 "value": "VNM",1118 "region": "Asia",1119 "subregion": "South-Eastern Asia",1120 "supported_identity_report": true1121 },1122 {1123 "label": "Virgin Islands (British)",1124 "value": "VGB",1125 "region": "Americas",1126 "subregion": "Caribbean",1127 "supported_identity_report": true1128 },1129 {1130 "label": "Zambia",1131 "value": "ZMB",1132 "region": "Africa",1133 "subregion": "Eastern Africa",1134 "supported_identity_report": true1135 },1136 {1137 "label": "Zimbabwe",1138 "value": "ZWE",1139 "region": "Africa",1140 "subregion": "Eastern Africa",1141 "supported_identity_report": true1142 },1143 {1144 "label": "Åland Islands",1145 "value": "ALA",1146 "region": "Europe",1147 "subregion": "Northern Europe",1148 "supported_identity_report": true1149 }...

Full Screen

Full Screen

report.js

Source:report.js Github

copy

Full Screen

1function add_window_report() {2 add_email_window_width_closefunc_ex({'id':'mail_policy_report','funcName':'name_bind_check()'});3 $("#mail_policy_report").combo('hidePanel');4}5function add_report_window() {6 if ($('#wwreport').length <= 0) {7 $(document.body).append("<div id='wwreport' class='ngtos_window'></div>"); //创建空div8 }9 open_window('wwreport', 'waf_report ', 'add_report_window', jslang.common.btn_add, 'true', add_report); //打开弹出框10 //$("#report_name").next('span').children('input :first').focus()11}12function edit_report_window() {13 if ($('#wwreport').length <= 0) {14 $(document.body).append("<div id='wwreport' class='ngtos_window'></div>"); //创建空div15 }16 open_window('wwreport', 'waf_report ', 'add_report_window', jslang.common.btn_edit, 'true', edit_report); //打开弹出框17 $("#report_name").next('span').children('input :first').focus()18}19function init_module_attack_report() {20 $("#tr_attack_type").show();21 $('#module_attack_report').attr('checked', 'checked');22 $('#module_traffic_report').attr('checked', 'checked');23 $('#module_antitamper_report').attr('checked', 'checked');24 $('#module_ddos_report').attr('checked', 'checked');25 $('#type_eventtype_report').attr('checked', 'checked');26 $('#type_source_report').attr('checked', 'checked');27 $('#type_urlattack_report').attr('checked', 'checked');28 $('#type_ruleid_report').attr('checked', 'checked');29 $('#type_action_report').attr('checked', 'checked');30}31function check_attack_module(){32 if($('#module_attack_report').attr('checked')){33 $("#tr_attack_type").show();34 setenable_addRe();35 36 }else{37 $("#tr_attack_type").hide();38 setenable_addRe();39 }40}41function setenable_addRe(){42 if($('#module_attack_report').attr('checked') == 'checked' && $('#type_eventtype_report').attr('checked') == undefined && $('#type_source_report').attr('checked') == undefined && $('#type_ruleid_report').attr('checked') == undefined && $('#type_urlattack_report').attr('checked') == undefined && $('#type_action_report').attr('checked') == undefined){43 setItemEnable('addRe', false);44 }else{45 setItemEnable('addRe', true);46 }47}48function show_modle_attack_report(module,attack) {49 var moduleArray = module.split(',');50 var attackArray = attack.split(',');51 for(var i=0; i<moduleArray.length; i++) {52 if(moduleArray[i]=='attack') {53 $('#module_attack_report').attr('checked', 'checked');54 $("#tr_attack_type").show();55 } else if(moduleArray[i]=='traffic') {56 $('#module_traffic_report').attr('checked', 'checked');57 } else if(moduleArray[i]=='anti-tamper') {58 $('#module_antitamper_report').attr('checked', 'checked');59 } else if(moduleArray[i]=='ddos') {60 $('#module_ddos_report').attr('checked', 'checked');61 }62 }63 for(var j=0; j<attackArray.length; j++) {64 if(attackArray[j]=="event-type") {65 $('#type_eventtype_report').attr('checked', 'checked');66 } else if(attackArray[j]=="source") {67 $('#type_source_report').attr('checked', 'checked');68 } else if(attackArray[j]=="rule-id") {69 $('#type_ruleid_report').attr('checked', 'checked');70 } else if(attackArray[j]=="URL-attack") {71 $('#type_urlattack_report').attr('checked', 'checked');72 } else if(attackArray[j]=="action") {73 $('#type_action_report').attr('checked', 'checked');74 }75 }76}77function show_start_end_time_report(startTime, endTime) {78 $('#dt_start_time_report').datetimebox('setValue', startTime);79 $('#dt_end_time_report').datetimebox('setValue', endTime);80}81function add_report() {82 form_reset_report();83 $('#server_policy_tr_report').css('display','none');84 $('#server_policy_all_report').attr('checked',true);85 init_module_attack_report();86 show_email_title_body($("#report_lan input[name='report_lan']:checked").val());87 setIdFocus('report_name');88 setItemEnable('addRe', false);89 $('#report_type_pdf').attr('checked', 'checked');90 //$('#report_type_xml').attr('checked','checked');91 $('#addRe').attr('disabled', 'true');92 $("#addRe").click(function() {93 var $lan = $('#report_lan input[name="report_lan"]:checked').val()94 var $email = initial_email_title_body_selected($lan);95 var e = $email[1].textbox('getValue');96 e = encodeURIComponent(e);97 e = e.replace(/'/g, '&wafsqm');98 $email[1].textbox('setValue', '');99 var m = $email[0].textbox('getValue');100 m = encodeURIComponent(m);101 m = m.replace(/'/g, '&wafsqm')102 $email[0].textbox('setValue', '');103 $('#ffre').form({104 url: '?module=waf_report&action=add_report',105 queryParams: { email_body: e, email_title: m, report_lan: $lan },106 success: function(data) {107 var obj = jQuery.parseJSON(data);108 if (obj['type'] == 1) {109 $('#wwreport').window('close')110 $('#ffre').form('clear');111 $('#ttre').datagrid('reload');112 } else if (obj['type'] == 2) {113 e = decodeURIComponent(e);114 e = e.replace(/&wafsqm/g, "'")115 m = decodeURIComponent(m);116 m = m.replace(/&wafsqm/g, "'")117 $email[1].textbox('setValue', e);118 $email[0].textbox('setValue', m);119 ngtosPopMessager("error", jslang.common.login_timeout, "login");120 } else {121 e = decodeURIComponent(e);122 e = e.replace(/&wafsqm/g, "'")123 m = decodeURIComponent(m);124 m = m.replace(/&wafsqm/g, "'")125 $email[1].textbox('setValue', e);126 $email[0].textbox('setValue', m);127 ngtosPopMessager("error", obj['info']);128 }129 }130 });131 })132 133}134function form_reset_report() {135 var combotoolbar_report = "<div id=\"combobox-toolbar\" style=\"border:#ABAFB8 1px solid;" +136 "background: #d3d3d3;padding:2px 0\"><a href=\"#\" class=\"easyui-linkbutton\" " +137 "data-options=\"iconCls:'icon-add',plain:true\"onClick=\"add_window_report();\"><span class=\"l-btn-left l-btn-icon-left\"><span class=\"l-btn-text\">" + jslang.common.btn_add +138 "</span><span class=\"l-btn-icon icon-add\"> </span></span></a></div>"139 140 $('#server_policy_report').combobox({141 url: '?module=waf_report&action=get_all_server_policy',142 valueField: 'text',143 textField: 'text',144 panelHeight: 'auto',145 panelMaxHeight: 198,146 editable:false147 });148 $("#monthday_value_report").combobox({149 url: '?module=waf_report&action=get_all_monthdays',150 multiple: true,151 multiline: true,152 valueField: 'value',153 textField: 'text',154 panelHeight:'auto',155 panelMaxHeight:198,156 editable: false157 })158 $("#report_top_n").combobox({159 url: '?module=waf_report&action=get_top_num',160 valueField: 'value',161 textField: 'text',162 panelHeight:'auto',163 panelMaxHeight:198,164 editable: false165 })166 $("#mail_policy_report").combobox({167 url: '?module=waf_email&action=get_all_email_name',168 valueField: 'text',169 textField: 'text',170 panelHeight: 'auto',171 panelMaxHeight: 198,172 editable: false173 })174 //$("#server_policy_report").combobox({175 // url:'?module=waf_report&action=get_all_server_name',176 // valueField:'text',177 // textField:'text',178 // panelHeight:'auto',179 // panelMaxHeight:198,180 // editable:false181 //});182 $("#mail_policy_report").combo('panel').after(combotoolbar_report);183 $('#weekday_report').hide()184 $('#attime_report').hide()185 $("#report_name").textbox('enable')186 $("#report_name").textbox('setValue', '')187 change_type_report('none');188 change_report_lan($.cookie("language"));189 $('#report_treport').find('input:checkbox').removeAttr('checked');190 $('#weekday_report').find('input:checkbox').removeAttr('checked');191 $("#server_policy_single_report").bind('click',function(){set_server_policy_combobox('single')});192 $("#server_policy_all_report").bind('click',function(){set_server_policy_combobox('all')});193 $("input[name='report_lan']").bind('click',function(){194 show_email_title_body($(this).val());195 });196 set_email_title_body();197 $("#mail_policy_report").combobox('setValue', jslang.alarm.mail_policy_alarm)198 $("#mail_policy_report").combobox('reload');199 $('#one_report').attr('checked', 'checked');200 $('#at_time_report').timespinner('setValue', '08:00:00');201 var curDate = new Date();202 var preDate = new Date(curDate.getTime() - 60*60*1000); //前一天203 var vEnd = curDate.getMonth()+1+'/'+curDate.getDate()+'/'+curDate.getFullYear()+' '+curDate.getHours()+':00:00';204 var vStart = preDate.getMonth()+1+'/'+preDate.getDate()+'/'+preDate.getFullYear()+' '+preDate.getHours()+':00:00';205 $('#dt_end_time_report').datetimebox('setValue',vEnd);206 $('#dt_start_time_report').datetimebox('setValue', vStart);207 $('#monthday_value_report').combobox('setValues', '1');208 $('#report_top_n').combobox('setValue', '10');209 $("#addRe").unbind('click')210 $("#report_s").css('display', 'none');211 initValidateboxStyle(check_report);212 name_bind_check();213 search();214 $("#tr_attack_type").hide();215 getHelpInformation("policy_report", getHelpInfoReport, 1);216}217function name_bind_check()218{219 $('#report_name').next('span').children('input :first').bind('input', function() {220 check_report();221 })222}223function getHelpInfoReport(msg) {224 var helpInforTemp = "<img src=\"static/images/icons/help_info.png\" style=\"vertical-align:middle;cursor: pointer; margin-left: 20px\" ";225 var itemArray = new Array();226 itemArray.push($("#report_name").next('span'));227 itemArray.push($("#report_month"));228 itemArray.push($("#report_s"));229 itemArray.push($("#email_title").next('span'));230 itemArray.push($("#email_body").next('span'));231 itemArray.push($("#mail_policy_report").next('span'));232 for (var i = 0; i < itemArray.length; i++) {233 if (msg[i] != "") {234 var helpInfor = helpInforTemp + "title=" + msg[i] + ">";235 itemArray[i].after(helpInfor);236 }237 }238}239function edit_report() {240 form_reset_report();241 setItemEnable('addRe', true);242 var rows = $('#ttre').datagrid('getSelections');243 $('#report_name').textbox('setValue', rows[0].name);244 $('#report_name').textbox('disable');245 $('#report_top_n').combobox('setValues', rows[0].topn.split(','));246 if (rows[0].schedule == 'none') {247 change_type_report('none');248 $('#schedule_none').attr('checked', 'checked');249 $('#at_time_report').timespinner('setValue', rows[0].attime);250 $('#start_time_report').css('display','table-row');251 $('#end_time_report').css('display','table-row');252 } else if (rows[0].schedule == 'daily') {253 change_type_report('daily');254 $('#schedule_daily').attr('checked', 'checked');255 $('#at_time_report').timespinner('setValue', rows[0].attime);256 $('#start_time_report').hide();257 $('#end_time_report').hide();258 } else if (rows[0].schedule == 'weekly') {259 change_type_report('weekly');260 $('#schedule_weekly').attr('checked', 'checked');261 $('#at_time_report').timespinner('setValue', rows[0].attime);262 show_weekday_report(rows[0].weekdays);263 $('#start_time_report').hide();264 $('#end_time_report').hide();265 } else if (rows[0].schedule == 'monthly') {266 change_type_report('monthly');267 $('#schedule_monthly').attr('checked', 'checked');268 $('#at_time_report').timespinner('setValue', rows[0].attime);269 $('#monthday_value_report').combobox('setValues', rows[0].monthdays.split(','));270 $('#start_time_report').hide();271 $('#end_time_report').hide();272 }273 $.post("?module=waf_report&action=show_single_report",{'name':rows[0].name},function(data){274 if(data.indexOf("parent.window.location")>=0){275 ngtosPopMessager("error", jslang.commmon.login_timeout, "login")276 }else if(data.indexOf("error -")>=0){277 ngtosPopMessager("error", jslang.commmon.get_info_failed);278 }else{279 var obj = jQuery.parseJSON(data);280 show_modle_attack_report(obj['rows'][0].module,obj['rows'][0].attack_rank);281 if(obj['rows'][0].schedule=='none') {282 show_start_end_time_report(obj['rows'][0]['start_time'],obj['rows'][0]['end_time'])283 }284 if(obj['rows'][0]['server'] == 'single')285 {286 $('#server_policy_single_report').attr('checked',true);287 set_server_policy_combobox('single');288 $('#server_policy_report').combobox('setValue',obj['rows'][0]['server_policy']);289 }else{290 $('#server_policy_all_report').attr('checked',true);291 set_server_policy_combobox('all');292 }293 }294 });295 if (rows[0].language == 'english') {296 change_report_lan('en');297 } else {298 change_report_lan('cn');299 }300 show_email_title_body(rows[0].language);301 //$('#mypanel').find('#report_type').val(formats);//html,xml302 var t_temp1 = rows[0].formats.split(',');303 for (var i = 0; i < t_temp1.length; i++) {304 if (t_temp1[i] == 'html') {305 $('#report_type_html').attr('checked', 'checked');306 } else if (t_temp1[i] == 'pdf') {307 $('#report_type_pdf').attr('checked', 'checked');308 }309 /* else if (t_temp1[i] == 'txt') {310 $('#report_type_txt').attr('checked', 'checked');311 }else if (t_temp1[i] == 'xml') {312 $('#report_type_xml').attr('checked', 'checked');313 }*/314 }315 var $email = initial_email_title_body_selected(rows[0].language);316 //给重定向url赋值317 var title = rows[0].title;318 title = title.replace(/&wafsqm/g, "'");319 $email[0].textbox('setValue', title);320 var body = rows[0].body;321 body = body.replace(/&wafsqm/g, "'");322 $email[1].textbox('setValue', body);323 var mail = rows[0].mail_policy == '' ? jslang.alarm.mail_policy_alarm : rows[0].mail_policy;324 $("#mail_policy_report").combobox('setValue', mail);325 $("#addRe").click(function() {326 var $email_final = initial_email_title_body_selected($("#report_lan input[name='report_lan']:checked").val());327 var e = $email_final[1].textbox('getValue');328 e = encodeURIComponent(e);329 e = e.replace(/'/g, '&wafsqm');330 $email_final[1].textbox('setValue', '');331 var m = $email_final[0].textbox('getValue');332 m = encodeURIComponent(m);333 m = m.replace(/'/g, '&wafsqm');334 $email_final[0].textbox('setValue', '');335 $('#ffre').form({336 url: '?module=waf_report&action=modify_report',337 queryParams: {338 name: rows[0].name,339 email_body: e,340 email_title: m341 },342 success: function(data) {343 var obj = jQuery.parseJSON(data);344 if (obj['type'] == 1) {345 $('#wwreport').window('close')346 $('#ffre').form('clear');347 $('#ttre').datagrid('reload');348 } else if (obj['type'] == 2) {349 e = decodeURIComponent(e);350 e = e.replace(/&wafsqm/g, "'")351 m = decodeURIComponent(m);352 m = m.replace(/&wafsqm/g, "'")353 $email_final[1].textbox('setValue', e);354 $email_final[0].textbox('setValue', m);355 ngtosPopMessager("error", jslang.common.login_timeout, "login");356 } else {357 e = decodeURIComponent(e);358 e = e.replace(/&wafsqm/g, "'")359 m = decodeURIComponent(m);360 m = m.replace(/&wafsqm/g, "'")361 $email_final[1].textbox('setValue', e);362 $email_final[0].textbox('setValue', m);363 ngtosPopMessager("error", obj['info']);364 }365 }366 });367 })368}369function delete_btn_report() {370 var rows = $('#ttre').datagrid('getSelections');371 if (rows.length == 0)372 ngtosPopMessager('info', jslang.common.choose_row_delete)373 else {374 ngtosPopMessager("confirm", jslang.common.confirm_delete, function(r) {375 if (r) {376 delete_report()377 }378 })379 }380}381function delete_report() {382 //ajax 删除383 var ids1 = [];384 var rows = $('#ttre').datagrid('getSelections');385 for (var i = 0; i < rows.length; i++) {386 ids1.push(rows[i].name);387 }388 var name = ids1.join(';');389 $.ajax({390 url: "?module=waf_report&action=delete_report",391 type: 'POST',392 datatype: 'text',393 data: {394 name: name395 },396 success: function(data, textStatus) {397 var obj = jQuery.parseJSON(data);398 if (obj['type'] == 1) {399 // $('#ttre').datagrid('reload');400 datagridDeleteReload("ttre");401 } else if (obj['type'] == 2) {402 ngtosPopMessager("error", jslang.common.login_timeout, "login");403 } else {404 ngtosPopMessager("error", obj['info']);405 }406 }407 });408}409function clear_btn() {410 ngtosPopMessager("confirm", jslang.common.confirm_clean, function(r) {411 if (r) {412 $.ajax({413 url: "?module=waf_report&action=clear_report",414 type: 'POST',415 datatype: 'text',416 success: function(data, textStatus) {417 if (data == 'ok') {418 $('#ttre').datagrid('reload');419 } else if (data == 2) {420 ngtosPopMessager("error", jslang.common.login_timeout, "login");421 } else {422 ngtosPopMessager("error", data);423 return false;424 }425 }426 });427 }428 })429}430function change_type_report(type) {431 //alert(type);432 if (type == 'none') {433 $('#schedule_none').attr('checked', 'checked');434 //alert($('#schedule_none').val());435 $('#weekday_report').hide()436 $('#attime_report').hide()437 $("#monthday_report").hide()438 $('#start_time_report').css('display','table-row');439 $('#end_time_report').css('display','table-row');440 } else if (type == 'daily') {441 $('#schedule_daily').attr('checked', 'checked');442 $('#weekday_report').hide()443 $('#attime_report').show()444 $("#monthday_report").hide()445 $('#start_time_report').hide();446 $('#end_time_report').hide();447 } else if (type == 'weekly') {448 $('#schedule_weekly').attr('checked', 'checked');449 $('#weekday_report').show()450 $('#attime_report').show()451 $("#monthday_report").hide()452 $('#start_time_report').hide();453 $('#end_time_report').hide();454 } else if (type == 'monthly') {455 $('#schedule_monthly').attr('checked', 'checked');456 $('#weekday_report').hide()457 $('#attime_report').show()458 $("#monthday_report").show()459 $('#start_time_report').hide();460 $('#end_time_report').hide();461 }462}463//操作按钮464function set_toolbar_report() {465 var crows = $('#ttre').datagrid('getSelections');466 //编辑按钮逻辑467 if (crows.length == 1) {468 $('#report_edit').linkbutton('enable');469 $('#report_download').linkbutton('enable');470 } else {471 $('#report_edit').linkbutton('disable');472 $('#report_download').linkbutton('disable');473 }474 //删除按钮逻辑475 if (crows.length > 0) {476 $('#report_delete').linkbutton('enable');477 } else {478 $('#report_delete').linkbutton('disable');479 }480}481function Select() {482 var value1 = $('#mail_policy_report').combobox('getValue');483 if (value1 == jslang.alarm.mail_policy_alarm_new) {484 add_email_window_width_closefunc_ex({'id':'mail_policy_report','funcName':'name_bind_check()'});485 $('#mail_policy_report').combobox('setValue', '');486 }487}488//列表搜索框489function search_data_report() {490 if ($.trim($("#addName").val()) == '') {491 $("#ttre").datagrid({492 url: '?module=waf_report&action=showall_report'493 })494 } else {495 $("#ttre").datagrid({496 url: "?module=waf_report&action=show_search&name=" + $('#addName').val()497 })498 $("#ttre").datagrid('getPager').pagination('select', 1);499 }500}501function show_weekday_report(weekday) {502 var s_temp = weekday.split(',');503 //var s='';504 $('#one_report').attr('checked', false);505 for (var i = 0; i < s_temp.length; i++) {506 if (s_temp[i] == 'mon') {507 $('#one_report').attr('checked', 'checked');508 } else if (s_temp[i] == 'tue') {509 $('#two_report').attr('checked', 'checked');510 } else if (s_temp[i] == 'wed') {511 $('#three_report').attr('checked', 'checked');512 } else if (s_temp[i] == 'thu') {513 $('#four_report').attr('checked', 'checked');514 } else if (s_temp[i] == 'fri') {515 $('#five_report').attr('checked', 'checked');516 } else if (s_temp[i] == 'sat') {517 $('#six_report').attr('checked', 'checked');518 } else if (s_temp[i] == 'sun') {519 $('#seven_report').attr('checked', 'checked');520 }521 }522}523function check_report() {524 var no = $("#report_name").textbox('getText');525 /*526 var chkbs = document.getElementsByName("report_type[]");527 var chkNum= 0;528 $(chkbs).each(function(index){529 if ($(this).attr('checked')){530 chkNum++;531 }532 })533 */534 if ($("#report_name").textbox('isValid') /*&&chkNum!=0*/ ) {535 setItemEnable('addRe', true);536 //$("#report_s").css('display','none');537 } else {...

Full Screen

Full Screen

report-test.js.es6

Source:report-test.js.es6 Github

copy

Full Screen

1import Report from "admin/models/report";2QUnit.module("Report");3function reportWithData(data) {4 return Report.create({5 type: "topics",6 data: data.map((val, index) => {7 return {8 x: moment()9 .subtract(index, "days")10 .format("YYYY-MM-DD"),11 y: val12 };13 })14 });15}16QUnit.test("counts", assert => {17 const report = reportWithData([5, 4, 3, 2, 1, 100, 99, 98, 1000]);18 assert.equal(report.get("todayCount"), 5);19 assert.equal(report.get("yesterdayCount"), 4);20 assert.equal(21 report.valueFor(2, 4),22 6,23 "adds the values for the given range of days, inclusive"24 );25 assert.equal(26 report.get("lastSevenDaysCount"),27 307,28 "sums 7 days excluding today"29 );30 report.set("method", "average");31 assert.equal(32 report.valueFor(2, 4),33 2,34 "averages the values for the given range of days"35 );36});37QUnit.test("percentChangeString", assert => {38 const report = reportWithData([]);39 assert.equal(report.percentChangeString(5, 8), "+60%", "value increased");40 assert.equal(report.percentChangeString(8, 2), "-75%", "value decreased");41 assert.equal(report.percentChangeString(8, 8), "0%", "value unchanged");42 assert.blank(43 report.percentChangeString(0, 8),44 "returns blank when previous value was 0"45 );46 assert.equal(report.percentChangeString(8, 0), "-100%", "yesterday was 0");47 assert.blank(48 report.percentChangeString(0, 0),49 "returns blank when both were 0"50 );51});52QUnit.test("yesterdayCountTitle with valid values", assert => {53 const title = reportWithData([6, 8, 5, 2, 1]).get("yesterdayCountTitle");54 assert.ok(title.indexOf("+60%") !== -1);55 assert.ok(title.match(/Was 5/));56});57QUnit.test("yesterdayCountTitle when two days ago was 0", assert => {58 const title = reportWithData([6, 8, 0, 2, 1]).get("yesterdayCountTitle");59 assert.equal(title.indexOf("%"), -1);60 assert.ok(title.match(/Was 0/));61});62QUnit.test("sevenDaysCountTitle", assert => {63 const title = reportWithData([64 100,65 1,66 1,67 1,68 1,69 1,70 1,71 1,72 2,73 2,74 2,75 2,76 2,77 2,78 2,79 100,80 10081 ]).get("sevenDaysCountTitle");82 assert.ok(title.match(/-50%/));83 assert.ok(title.match(/Was 14/));84});85QUnit.test("thirtyDaysCountTitle", assert => {86 const report = reportWithData([5, 5, 5, 5]);87 report.set("prev30Days", 10);88 const title = report.get("thirtyDaysCountTitle");89 assert.ok(title.indexOf("+50%") !== -1);90 assert.ok(title.match(/Was 10/));91});92QUnit.test("sevenDaysTrend", assert => {93 let report;94 let trend;95 report = reportWithData([0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]);96 trend = report.get("sevenDaysTrend");97 assert.ok(trend === "no-change");98 report = reportWithData([0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]);99 trend = report.get("sevenDaysTrend");100 assert.ok(trend === "high-trending-up");101 report = reportWithData([0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]);102 trend = report.get("sevenDaysTrend");103 assert.ok(trend === "trending-up");104 report = reportWithData([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]);105 trend = report.get("sevenDaysTrend");106 assert.ok(trend === "high-trending-down");107 report = reportWithData([0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]);108 trend = report.get("sevenDaysTrend");109 assert.ok(trend === "trending-down");110});111QUnit.test("yesterdayTrend", assert => {112 let report;113 let trend;114 report = reportWithData([0, 1, 1]);115 trend = report.get("yesterdayTrend");116 assert.ok(trend === "no-change");117 report = reportWithData([0, 1, 0]);118 trend = report.get("yesterdayTrend");119 assert.ok(trend === "high-trending-up");120 report = reportWithData([0, 1.1, 1]);121 trend = report.get("yesterdayTrend");122 assert.ok(trend === "trending-up");123 report = reportWithData([0, 0, 1]);124 trend = report.get("yesterdayTrend");125 assert.ok(trend === "high-trending-down");126 report = reportWithData([0, 1, 1.1]);127 trend = report.get("yesterdayTrend");128 assert.ok(trend === "trending-down");129});130QUnit.test("thirtyDaysTrend", assert => {131 let report;132 let trend;133 report = reportWithData([134 0,135 1,136 1,137 1,138 1,139 1,140 1,141 1,142 1,143 1,144 1,145 1,146 1,147 1,148 1,149 1,150 1,151 1,152 1,153 1,154 1,155 1,156 1,157 1,158 1,159 1,160 1,161 1,162 1,163 1,164 1165 ]);166 report.set("prev30Days", 30);167 trend = report.get("thirtyDaysTrend");168 assert.ok(trend === "no-change");169 report = reportWithData([170 0,171 1,172 1,173 1,174 1,175 1,176 1,177 1,178 1,179 1,180 1,181 1,182 1,183 1,184 1,185 1,186 1,187 1,188 1,189 1,190 1,191 1,192 1,193 1,194 1,195 1,196 1,197 1,198 1,199 1,200 1201 ]);202 report.set("prev30Days", 0);203 trend = report.get("thirtyDaysTrend");204 assert.ok(trend === "high-trending-up");205 report = reportWithData([206 0,207 1,208 1,209 1,210 1,211 1,212 1,213 1,214 1,215 1,216 1,217 1,218 1,219 1,220 1,221 1,222 1,223 1,224 1,225 1,226 1,227 1,228 1,229 1,230 1,231 1,232 1,233 1,234 1,235 1,236 1237 ]);238 report.set("prev30Days", 25);239 trend = report.get("thirtyDaysTrend");240 assert.ok(trend === "trending-up");241 report = reportWithData([242 0,243 0,244 0,245 0,246 0,247 0,248 0,249 0,250 0,251 0,252 0,253 0,254 0,255 0,256 0,257 0,258 0,259 0,260 0,261 0,262 0,263 0,264 0,265 0,266 0,267 0,268 0,269 0,270 0,271 0,272 0273 ]);274 report.set("prev30Days", 60);275 trend = report.get("thirtyDaysTrend");276 assert.ok(trend === "high-trending-down");277 report = reportWithData([278 0,279 1,280 1,281 1,282 1,283 1,284 1,285 1,286 1,287 1,288 1,289 1,290 1,291 1,292 1,293 1,294 1,295 1,296 1,297 1,298 1,299 1,300 1,301 1,302 1,303 1,304 1,305 1,306 1,307 1,308 0309 ]);310 report.set("prev30Days", 35);311 trend = report.get("thirtyDaysTrend");312 assert.ok(trend === "trending-down");313});314QUnit.test("higher is better false", assert => {315 let report;316 let trend;317 report = reportWithData([0, 1, 0]);318 report.set("higher_is_better", false);319 trend = report.get("yesterdayTrend");320 assert.ok(trend === "high-trending-down");321 report = reportWithData([0, 1.1, 1]);322 report.set("higher_is_better", false);323 trend = report.get("yesterdayTrend");324 assert.ok(trend === "trending-down");325 report = reportWithData([0, 0, 1]);326 report.set("higher_is_better", false);327 trend = report.get("yesterdayTrend");328 assert.ok(trend === "high-trending-up");329 report = reportWithData([0, 1, 1.1]);330 report.set("higher_is_better", false);331 trend = report.get("yesterdayTrend");332 assert.ok(trend === "trending-up");333});334QUnit.test("small variation (-2/+2% change) is no-change", assert => {335 let report;336 let trend;337 report = reportWithData([0, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 1, 1, 1, 1, 1]);338 trend = report.get("sevenDaysTrend");339 assert.ok(trend === "no-change");340 report = reportWithData([0, 1, 1, 1, 1, 1, 1, 1.1, 1, 1, 1, 1, 1, 1, 1]);341 trend = report.get("sevenDaysTrend");342 assert.ok(trend === "no-change");343});344QUnit.test("average", assert => {345 let report;346 report = reportWithData([5, 5, 5, 5, 5, 5, 5, 5]);347 report.set("average", true);348 assert.ok(report.get("lastSevenDaysCount") === 5);349 report.set("average", false);350 assert.ok(report.get("lastSevenDaysCount") === 35);351});352QUnit.test("computed labels", assert => {353 const data = [354 {355 username: "joffrey",356 user_id: 1,357 user_avatar: "/",358 flag_count: "1876",359 time_read: 287362,360 note: "This is a long note",361 topic_id: 2,362 topic_title: "Test topic <html>",363 post_number: 3,364 post_raw: "This is the beginning of <html>",365 filesize: 582641366 }367 ];368 const labels = [369 {370 type: "user",371 properties: {372 username: "username",373 id: "user_id",374 avatar: "user_avatar"375 },376 title: "Moderator"377 },378 { type: "number", property: "flag_count", title: "Flag count" },379 { type: "seconds", property: "time_read", title: "Time read" },380 { type: "text", property: "note", title: "Note" },381 {382 type: "topic",383 properties: {384 title: "topic_title",385 id: "topic_id"386 },387 title: "Topic"388 },389 {390 type: "post",391 properties: {392 topic_id: "topic_id",393 number: "post_number",394 truncated_raw: "post_raw"395 },396 title: "Post"397 },398 { type: "bytes", property: "filesize", title: "Filesize" }399 ];400 const report = Report.create({401 type: "topics",402 labels,403 data404 });405 const row = report.get("data.0");406 const computedLabels = report.get("computedLabels");407 const usernameLabel = computedLabels[0];408 assert.equal(usernameLabel.mainProperty, "username");409 assert.equal(usernameLabel.sortProperty, "username");410 assert.equal(usernameLabel.title, "Moderator");411 assert.equal(usernameLabel.type, "user");412 const computedUsernameLabel = usernameLabel.compute(row);413 assert.equal(414 computedUsernameLabel.formatedValue,415 "<a href='/admin/users/1/joffrey'><img alt='' width='20' height='20' src='/' class='avatar' title='joffrey'><span class='username'>joffrey</span></a>"416 );417 assert.equal(computedUsernameLabel.value, "joffrey");418 const flagCountLabel = computedLabels[1];419 assert.equal(flagCountLabel.mainProperty, "flag_count");420 assert.equal(flagCountLabel.sortProperty, "flag_count");421 assert.equal(flagCountLabel.title, "Flag count");422 assert.equal(flagCountLabel.type, "number");423 let computedFlagCountLabel = flagCountLabel.compute(row);424 assert.equal(computedFlagCountLabel.formatedValue, "1.9k");425 assert.strictEqual(computedFlagCountLabel.value, 1876);426 computedFlagCountLabel = flagCountLabel.compute(row, {427 formatNumbers: false428 });429 assert.equal(computedFlagCountLabel.formatedValue, 1876);430 const timeReadLabel = computedLabels[2];431 assert.equal(timeReadLabel.mainProperty, "time_read");432 assert.equal(timeReadLabel.sortProperty, "time_read");433 assert.equal(timeReadLabel.title, "Time read");434 assert.equal(timeReadLabel.type, "seconds");435 const computedTimeReadLabel = timeReadLabel.compute(row);436 assert.equal(computedTimeReadLabel.formatedValue, "3d");437 assert.equal(computedTimeReadLabel.value, 287362);438 const noteLabel = computedLabels[3];439 assert.equal(noteLabel.mainProperty, "note");440 assert.equal(noteLabel.sortProperty, "note");441 assert.equal(noteLabel.title, "Note");442 assert.equal(noteLabel.type, "text");443 const computedNoteLabel = noteLabel.compute(row);444 assert.equal(computedNoteLabel.formatedValue, "This is a long note");445 assert.equal(computedNoteLabel.value, "This is a long note");446 const topicLabel = computedLabels[4];447 assert.equal(topicLabel.mainProperty, "topic_title");448 assert.equal(topicLabel.sortProperty, "topic_title");449 assert.equal(topicLabel.title, "Topic");450 assert.equal(topicLabel.type, "topic");451 const computedTopicLabel = topicLabel.compute(row);452 assert.equal(453 computedTopicLabel.formatedValue,454 "<a href='/t/-/2'>Test topic &lt;html&gt;</a>"455 );456 assert.equal(computedTopicLabel.value, "Test topic <html>");457 const postLabel = computedLabels[5];458 assert.equal(postLabel.mainProperty, "post_raw");459 assert.equal(postLabel.sortProperty, "post_raw");460 assert.equal(postLabel.title, "Post");461 assert.equal(postLabel.type, "post");462 const computedPostLabel = postLabel.compute(row);463 assert.equal(464 computedPostLabel.formatedValue,465 "<a href='/t/-/2/3'>This is the beginning of &lt;html&gt;</a>"466 );467 assert.equal(computedPostLabel.value, "This is the beginning of <html>");468 const filesizeLabel = computedLabels[6];469 assert.equal(filesizeLabel.mainProperty, "filesize");470 assert.equal(filesizeLabel.sortProperty, "filesize");471 assert.equal(filesizeLabel.title, "Filesize");472 assert.equal(filesizeLabel.type, "bytes");473 const computedFilesizeLabel = filesizeLabel.compute(row);474 assert.equal(computedFilesizeLabel.formatedValue, "569.0 KB");475 assert.equal(computedFilesizeLabel.value, 582641);476 // subfolder support477 Discourse.BaseUri = "/forum";478 const postLink = computedLabels[5].compute(row).formatedValue;479 assert.equal(480 postLink,481 "<a href='/forum/t/-/2/3'>This is the beginning of &lt;html&gt;</a>"482 );483 const topicLink = computedLabels[4].compute(row).formatedValue;484 assert.equal(topicLink, "<a href='/forum/t/-/2'>Test topic &lt;html&gt;</a>");485 const userLink = computedLabels[0].compute(row).formatedValue;486 assert.equal(487 userLink,488 "<a href='/forum/admin/users/1/joffrey'><img alt='' width='20' height='20' src='/forum/' class='avatar' title='joffrey'><span class='username'>joffrey</span></a>"489 );...

Full Screen

Full Screen

Report.py

Source:Report.py Github

copy

Full Screen

...24 self.ReportDefs['DocumentPathGravesInvoice'] = self.DocumentPathGravesInvoice25 26 self.ReportDefs['PdfEncoding'] = self.PdfEncoding27 28 #self.report = Reports.report.report()29 30 31 def xmlrpc_server_address_phonelist1(self, dicSearchlist, dicUser):32 import Reports.report_addresses_phone133 import Address34 35 print "startReport"36 oAddress=Address.Address()37 oReports = Reports.report_addresses_phone1.report_addresses_phone1()38 repData = oReports.getReportData(dicSearchlist, dicUser, oAddress, self.ReportDefs)39 #print repData40 41 42 return self.report_server.ReportServer.createReport(repData)...

Full Screen

Full Screen

reporterb2cconfig.py

Source:reporterb2cconfig.py Github

copy

Full Screen

1__all__ = [2 "ReporterB2CConfig",3]4#import sys5import top6from top.utils.log import log7from top.utils.setter import (set_scalar,8 set_list,9 set_dict)10class ReporterB2CConfig(top.B2CConfig):11 """:class:`top.ReporterB2CConfig` captures the configuration items12 required for the ``topreporter`` facility.13 .. attribute:: report_bu_ids14 dictionary mapping between Business Unit ID (``job.bu_id``15 column) and a human-readable format16 .. attribute:: report_outdir17 temporary working directory to where report files are18 staged to for further processing19 .. attribute:: report_outfile20 basename that is used to generate the report file21 .. attribute:: report_outfile_ts_format22 the date/time string to append to the outfile23 .. attribute:: report_extension24 outbound report filename extension25 .. attribute:: report_type_outfile26 basename that is used to generate the uncollected report file27 .. attribute:: report_type_display_hdrs28 list of ordered column headers to display in the uncollected report29 .. attribute:: report_type_widths30 map of aliased header names and prefered column width31 .. attribute:: report_type_ws32 map of worksheet related items33 .. attribute:: report_email_recipients34 list of email recipients35 .. attribute:: report_type_bu_based36 flag to denote if the reports are to be based on Business Unit37 .. attribute:: report_type_delivery_partners38 string based list of Delivery Partner names to limit result set39 against. For example, ``['Nparcel', 'Toll']``. The values40 supported are as per the ``delivery_partner.name`` table set41 .. attribute:: report_bu_id_recipients42 list of Business Unit specific recipients43 .. attribute:: report_compliance_period44 time (in days) from now that is the cut off for agent compliance45 (default 7 days)46 """47 _report_type = 'uncollected'48 _report_bu_ids = {}49 _report_outdir = '/data/top/reports'50 _report_outfile = 'Report_'51 _report_outfile_ts_format = '%Y%m%d-%H:%M'52 _report_extension = 'xlsx'53 _report_type_outfile = None54 _report_type_display_hdrs = []55 _report_type_aliases = {}56 _report_type_widths = {}57 _report_type_ws = {}58 _report_type_recipients = []59 _report_type_bu_based = False60 _report_type_delivery_partners = []61 _report_bu_id_recipients = {}62 _report_compliance_period = 763 @property64 def report_type(self):65 return self._report_type66 @set_scalar67 def set_report_type(self, value=None):68 pass69 @property70 def report_bu_ids(self):71 return self._report_bu_ids72 @set_dict73 def set_report_bu_ids(self, values):74 pass75 @property76 def report_outdir(self):77 return self._report_outdir78 @set_scalar79 def set_report_outdir(self, value):80 pass81 @property82 def report_outfile(self):83 return self._report_outfile84 @set_scalar85 def set_report_outfile(self, value):86 pass87 @property88 def report_outfile_ts_format(self):89 return self._report_outfile_ts_format90 @set_scalar91 def set_report_outfile_ts_format(self, value):92 pass93 @property94 def report_extension(self):95 return self._report_extension96 @set_scalar97 def set_report_extension(self, value):98 pass99 @property100 def report_type_outfile(self):101 return self._report_type_outfile102 @set_scalar103 def set_report_type_outfile(self, value):104 pass105 @property106 def report_type_display_hdrs(self):107 return self._report_type_display_hdrs108 @set_list109 def set_report_type_display_hdrs(self, values=None):110 pass111 @property112 def report_type_aliases(self):113 return self._report_type_aliases114 @set_dict115 def set_report_type_aliases(self, values=None):116 pass117 @property118 def report_type_widths(self):119 return self._report_type_widths120 @set_dict121 def set_report_type_widths(self, values=None):122 pass123 @property124 def report_type_ws(self):125 return self._report_type_ws126 @set_dict127 def set_report_type_ws(self, values=None):128 pass129 @property130 def report_type_recipients(self):131 return self._report_type_recipients132 @set_list133 def set_report_type_recipients(self, values=None):134 pass135 @property136 def report_type_bu_based(self):137 return self._report_type_bu_based138 def set_report_type_bu_based(self, value=False):139 self.report_type_bu_based = (value.lower() == 'yes')140 log.debug('%s report_%s.bu_based flag set to "%s"' %141 (self.facility,142 self.report_type,143 self.report_type_bu_based))144 @property145 def report_type_delivery_partners(self):146 return self._report_type_delivery_partners147 @set_list148 def set_report_type_delivery_partners(self, values=None):149 pass150 @property151 def report_bu_id_recipients(self):152 return self._report_bu_id_recipients153 @set_dict154 def set_report_bu_id_recipients(self, values=None):155 pass156 @property157 def report_compliance_period(self):158 return self._report_compliance_period159 @set_scalar160 def set_report_compliance_period(self, value):161 pass162 def __init__(self, file=None, type=None):163 """ReporterB2CConfig initialisation.164 """165 top.B2CConfig.__init__(self, file)166 if type is not None:167 self.set_report_type(type)168 def parse_config(self):169 """Read config items from the configuration file.170 """171 top.Config.parse_config(self)172 kwargs = [{'section': 'report_base',173 'option': 'outdir',174 'var': 'report_outdir'},175 {'section': 'report_base',176 'option': 'outfile',177 'var': 'report_outfile'},178 {'section': 'report_base',179 'option': 'outfile_ts_format',180 'var': 'report_outfile_ts_format'},181 {'section': 'report_base',182 'option': 'extension',183 'var': 'report_extension'}]184 report_section = 'report_%s' % self.report_type185 for attr in ['outfile',186 'display_hdrs',187 'recipients',188 'bu_based',189 'delivery_partners']:190 report_attr = 'report_type_%s' % attr191 if attr in ['display_hdrs',192 'recipients',193 'delivery_partners']:194 kwargs.append({'section': report_section,195 'option': attr,196 'var': 'report_type_%s' % attr,197 'is_list': True})198 else:199 kwargs.append({'section': report_section,200 'option': attr,201 'var': 'report_type_%s' % attr})202 # Report specific options.203 if self.report_type == 'compliance':204 kwargs.append({'section': 'report_compliance',205 'option': 'period',206 'var': 'report_compliance_period',207 'cast_type': 'int'})208 for kw in kwargs:209 self.parse_scalar_config(**kw)210 del kwargs[:]211 kwargs = [{'section': 'report_bu_ids',212 'key_cast_type': 'int'},213 {'section': 'report_bu_id_recipients',214 'is_list': True,215 'key_cast_type': 'int'},216 {'section': '%s_aliases' % (report_section),217 'var': 'report_type_aliases',218 'key_case': 'upper'},219 {'section': '%s_widths' % (report_section),220 'var': 'report_type_widths',221 'key_case': 'lower',222 'cast_type': 'int'},223 {'section': '%s_ws' % (report_section),224 'var': 'report_type_ws'}]225 for kw in kwargs:...

Full Screen

Full Screen

check_reports.py

Source:check_reports.py Github

copy

Full Screen

1from datetime import datetime, timezone2from flask import request, render_template, abort, url_for, flash, redirect3from flask.views import View4from flask_login import login_required, current_user5from labs_web.extensions import (celery,6 mail,7 report_checked,8 CheckReportForm,9 ReportSearchingForm,10 Course,11 User,12 db,13 Report)14from .search_reports import ReportsSearcher15from labs_web import app16from flask_mail import Message171819@celery.task(ignore_result=True)20def send_mail_report_checked(report_id):21 """22 background task to notify students when their reports were checked by the tutor23 works inside app context, makes all needed queries itself24 """25 with app.app_context():26 report = Report.query.get(report_id)27 student = User.query.get(report.report_student)28 course = Course.query.get(report.report_course)29 msg = Message()30 msg.sender = 'labs.web.notifications'31 msg.recipients = [student.email]32 msg.subject = "Report checked"33 msg.html = render_template('mail/report-checked.html',34 report=report,35 student=student,36 course=course)37 mail.send(msg)383940class ReportRepr:41 """42 Class to query & store information about reports43 """44 def __init__(self, report: Report, course_shortened):45 """46 :param report: Report instance47 :param course_shortened: needed to generate download url without extra query48 """49 self.id = report.report_id50 self.uploaded = report.report_uploaded51 self.student = User.query.get(report.report_student)52 self.group = self.student.group[0].name53 self.number = report.report_num54 self.link = url_for('.get-report',55 course=course_shortened,56 group=self.group,57 student=report.report_student,58 number=report.report_num)5960 @classmethod61 def from_list(cls, reports: list, course_shortened: str) -> list:62 """63 :param reports: list of reports64 :param course_shortened: shortened name of course65 :return: list of ReportRepr instances to insert into template66 !initializing each ReportRepr makes 2 queries (loading user & his group) 67 """68 return [cls(report, course_shortened) for report in reports]697071class CheckReports(View):72 """View to check reports in course, commonly accessed via flask.redirect() from ChooseCourseToCheck view"""73 decorators = [login_required]74 methods = ["GET", "POST"]7576 @staticmethod77 def _set_report_mark(report: Report, mark: int, comment="") -> None:78 """79 set mark for given report and commits result to db80 all validations are done before with report_can_not_be_checked 81 :param report: Report object 82 :param mark: report mark83 :param comment: tutor comment84 :return: 85 """86 report.report_mark = mark87 report.report_checked = datetime.now(timezone.utc)88 report.report_tut_comment = comment89 db.session.commit()9091 @staticmethod92 def report_can_not_be_checked(report: Report, course: Course, report_mark: int):93 """94 :param course: Course object 95 :param report: Report object96 :param report_mark: mark to put97 :return: None if given report can be checked by the given tutor98 :return: Error string if any error occurred during validating form data99 """100 if not report:101 return "Report doesn't exist"102 if report.report_mark:103 return "Report is already checked"104 if report_mark not in range(1, course.lab_max_score + 1):105 return "Report mark should be between 1 and {} inclusive".format(course.lab_max_score)106107 def dispatch_request(self, *args, **kwargs):108 form = CheckReportForm()109 search = ReportSearchingForm()110 course = Course.query.get(kwargs.get('course_id'))111 search.report_group.choices = [(i.group_id, i.name) for i in course.groups]112 if not course or course.course_tutor != current_user.id:113 abort(404)114 if request.method == "POST":115 if form.validate_on_submit():116 report = Report.query.get(form.data.get('report_id'))117 report_mark = form.data.get('report_mark')118 error = CheckReports.report_can_not_be_checked(report, course, report_mark)119 if error:120 flash(error)121 return redirect(request.url)122 CheckReports._set_report_mark(report, report_mark, form.data.get("tutor_comment"))123 report_checked.send(report_id=report.report_id)124 return redirect(url_for('.tutor_check_reports', course_id=course.course_id))125 if search.validate_on_submit():126 searcher = ReportsSearcher(course)127 reports = ReportRepr.from_list(searcher.search(search.data.get('report_student'),128 search.data.get('report_group'),129 search.data.get('report_number')),130 course_shortened=course.course_shortened)131 return render_template('tutor/check_report.html', form=form, search=search,132 reports=reports)133 try:134 page = int(request.args.get('page'))135 except ValueError:136 page = 1137 except TypeError:138 page = 1139 default_pagination = Report.query.filter(Report.report_mark.is_(None),140 Report.report_course == course.course_id).\141 paginate(page=page if page else 1, per_page=10)142 return render_template('tutor/check_report.html',143 reports=ReportRepr.from_list(default_pagination.items, course.course_shortened),144 current=default_pagination.page,145 next=default_pagination.next_num,146 prev=default_pagination.prev_num,147 pages=default_pagination.pages, ...

Full Screen

Full Screen

report.mock.service.ts

Source:report.mock.service.ts Github

copy

Full Screen

1import {REPORT_PREVIEWS_LIST} from "../../../shared/entities/mock-data/previews/report-previews.mock-data";2import {Observable} from "rxjs/Observable";3import {ReportPreview} from "../../../shared/entities/preview.entities";4import {Report} from "../../../shared/entities/get.entities";5import {REPORTS_LIST} from "../../../shared/entities/mock-data/reports.mock-data";6import {ReportService} from "./report.service";7import {NewReport} from "../../../shared/entities/add.entities";8import {Injectable, Injector} from "@angular/core";9import {ServiceInjector} from "../../../shared/services/service.injector";10@Injectable()11export class ReportMockService extends ReportService {12 private newReportId: number = REPORTS_LIST.length + 1;13 constructor(private injector: Injector) {14 super(injector.get(ServiceInjector));15 }16 public getReportPreviews(): Observable<ReportPreview[]> {17 return Observable.create(observer => {18 // timeout is simulation of 'getting from http'19 setTimeout(() => {20 observer.next(REPORT_PREVIEWS_LIST);21 }, 500);22 setTimeout(() => {23 observer.complete();24 }, 600);25 });26 }27 public getReport(reportId: number): Observable<Report> {28 return Observable.create(observer => {29 // timeout is simulation of 'getting from http'30 setTimeout(() => {31 observer.next(REPORTS_LIST.find(report => report.reportId === reportId));32 }, 1000);33 setTimeout(() => {34 observer.complete();35 }, 1100);36 });37 }38 public addReport(reportToAdd: NewReport): Observable<any> {39 const report: Report = new Report(this.newReportId, reportToAdd.content, reportToAdd.startDate, reportToAdd.endDate);40 const reportPreview: ReportPreview = new ReportPreview(this.newReportId, reportToAdd.startDate, reportToAdd.endDate);41 this.newReportId++;42 REPORTS_LIST.push(report);43 REPORT_PREVIEWS_LIST.push(reportPreview);44 return Observable.create(observer => {45 observer.next(true);46 observer.complete();47 });48 }49 public deleteReport(reportToDelete: Report): Observable<any> {50 const reportId = REPORTS_LIST.findIndex(report => report.reportId === reportToDelete.reportId);51 REPORTS_LIST.splice(reportId, 1);52 REPORT_PREVIEWS_LIST.splice(reportId, 1);53 return Observable.create(observer => {54 observer.next(true);55 observer.complete();56 });57 }58 public editReport(reportToEdit: Report): Observable<any> {59 const reportId: number = REPORTS_LIST.findIndex(report => report.reportId === reportToEdit.reportId);60 REPORTS_LIST[reportId] = reportToEdit;61 REPORT_PREVIEWS_LIST[reportId].startDate = reportToEdit.startDate;62 REPORT_PREVIEWS_LIST[reportId].endDate = reportToEdit.endDate;63 return Observable.create(observer => {64 observer.next(true);65 observer.complete();66 });67 }...

Full Screen

Full Screen

report.service.ts

Source:report.service.ts Github

copy

Full Screen

1import {ReportPreview} from "../../../shared/entities/preview.entities";2import {Observable} from "rxjs/Observable";3import {Report} from "../../../shared/entities/get.entities";4import {NewReport} from "../../../shared/entities/add.entities";5import {DictionaryService} from "../../../shared/services/dictionary.service";6import {ServiceInjector} from "../../../shared/services/service.injector";7import {Inject} from "@angular/core";8import {DateService} from "../../../shared/services/date.service";9export abstract class ReportService {10 private dictionaryService: DictionaryService;11 private dateService: DateService;12 constructor(@Inject(ServiceInjector) protected serviceInjector: ServiceInjector) {13 this.dictionaryService = serviceInjector.getDictionaryService();14 this.dateService = serviceInjector.getDateService();15 }16 abstract getReportPreviews(): Observable<ReportPreview[]>;17 abstract getReport(reportId: number): Observable<Report>;18 abstract addReport(reportToAdd: NewReport): Observable<any>;19 abstract deleteReport(reportToDelete: Report): Observable<any>;20 abstract editReport(reportToEdit: Report): Observable<any>;21 public getPreviewTitle(reportPreview: ReportPreview): string {22 return `${this.dictionaryService.getDictionaryValue('page.reports.card.title')} ` +23 `${reportPreview.startDate.getUTCDate()} ` +24 `${this.dictionaryService.getDateDictionarySettings().monthsShort[reportPreview.startDate.getUTCMonth()]} ` +25 `${reportPreview.startDate.getUTCFullYear()} ` +26 `- ${reportPreview.endDate.getUTCDate()} ` +27 `${this.dictionaryService.getDateDictionarySettings().monthsShort[reportPreview.endDate.getUTCMonth()]} ` +28 `${reportPreview.endDate.getUTCFullYear()}`;29 }30 public parsePreviewsFromServer(reportPreviews: ReportPreview[]): ReportPreview[] {31 reportPreviews.forEach(reportPreview => {32 if (typeof reportPreview.startDate === "string") {33 reportPreview.startDate = this.dateService.parseStringFromServerToDate(reportPreview.startDate);34 }35 if (typeof reportPreview.endDate === "string") {36 reportPreview.endDate = this.dateService.parseStringFromServerToDate(reportPreview.endDate);37 }38 });39 return reportPreviews;40 }41 parseFromServer(report: Report): Report {42 if (typeof report.startDate === "string") {43 report.startDate = this.dateService.parseStringFromServerToDate(report.startDate);44 }45 if (typeof report.endDate === "string") {46 report.endDate = this.dateService.parseStringFromServerToDate(report.endDate);47 }48 return report;49 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { report } = require('fast-check-monorepo')2report('test3')3const { report } = require('fast-check-monorepo')4report('test4')5const { report } = require('fast-check-monorepo')6report('test5')7const { report } = require('fast-check-monorepo')8report('test6')9const { report } = require('fast-check-monorepo')10report('test7')11const { report } = require('fast-check-monorepo')12report('test8')13const { report } = require('fast-check-monorepo')14report('test9')15const { report } = require('fast-check-monorepo')16report('test10')17const { report } = require('fast-check-monorepo')18report('test11')19const { report } = require('fast-check-monorepo')20report('test12')21const { report } = require('fast-check-monorepo')22report('test13')23const { report } = require('fast-check-monorepo')24report('test14')25const { report } = require('fast-check-monorepo')26report('test15')27const { report }

Full Screen

Using AI Code Generation

copy

Full Screen

1const { report } = require("fast-check-monorepo");2report("Hello World!");3const { report } = require("fast-check-monorepo");4report("Hello World!");5const { report } = require("fast-check-monorepo");6report("Hello World!");7const { report } = require("fast-check-monorepo");8report("Hello World!");9const { report } = require("fast-check-monorepo");10report("Hello World!");11const { report } = require("fast-check-monorepo");12report("Hello World!");13const { report } = require("fast-check-monorepo");14report("Hello World!");15const { report } = require("fast-check-monorepo");16report("Hello World!");17const { report } = require("fast-check-monorepo");18report("Hello World!");19const { report } = require("fast-check-monorepo");20report("Hello World!");21const { report } = require("fast-check-monorepo");22report("Hello World!");23const { report } = require("fast-check-monorepo");24report("Hello World!");25const { report } = require("fast-check-monorepo");26report("Hello World!");27const { report }

Full Screen

Using AI Code Generation

copy

Full Screen

1const fastCheck = require('fast-check');2const { report } = require('fast-check-monorepo');3fastCheck.assert(4 fastCheck.property(fastCheck.integer(), (n) => n >= 0),5 { verbose: true, report }6);

Full Screen

Using AI Code Generation

copy

Full Screen

1const report = require('fast-check-monorepo')2report('test3', 'test3')3const report = require('fast-check-monorepo')4report('test4', 'test4')5const report = require('fast-check-monorepo')6report('test5', 'test5')7const report = require('fast-check-monorepo')8report('test6', 'test6')9const report = require('fast-check-monorepo')10report('test7', 'test7')11const report = require('fast-check-monorepo')12report('test8', 'test8')13const report = require('fast-check-monorepo')14report('test9', 'test9')15const report = require('fast-check-monorepo')16report('test10', 'test10')17const report = require('fast-check-monorepo')18report('test11', 'test11')19const report = require('fast-check-monorepo')20report('test12', 'test12')21const report = require('fast-check-monorepo')22report('test13', 'test13')23const report = require('fast-check-monorepo')24report('test14', 'test14')25const report = require('fast-check-monorepo')26report('test15', 'test

Full Screen

Using AI Code Generation

copy

Full Screen

1const { report } = require('fast-check-monorepo');2const { report } = require('fast-check-monorepo');3report('test2', 'test3');4const { report } = require('fast-check-monorepo');5report('test2', 'test4');6const { report } = require('fast-check-monorepo');7report('test2', 'test5');8const { report } = require('fast-check-monorepo');9report('test2', 'test6');10const { report } = require('fast-check-monorepo');11report('test2', 'test7');12const { report } = require('fast-check-monorepo');13report('test2', 'test8');14const { report } = require('fast-check-monorepo');15report('test2', 'test9');16const { report } = require('fast-check-monorepo');17report('test2', 'test10');18const { report } = require('fast-check-monorepo');19report('test2', 'test11');20const { report } = require('fast-check-monorepo');21report('test2', 'test12');22const { report } = require('fast-check-monorepo');23report('test2', 'test13');24const { report } = require('fast-check-mon

Full Screen

Using AI Code Generation

copy

Full Screen

1const report = require('fast-check-monorepo').report;2report(10, 100, 1, 1, 1, 1);3const report = require('fast-check-monorepo').report;4report(10, 100, 1, 1, 1, 1);5const report = require('fast-check-monorepo').report;6report(10, 100, 1, 1, 1, 1);7const report = require('fast-check-monorepo').report;8report(10, 100, 1, 1, 1, 1);9const report = require('fast-check-monorepo').report;10report(10, 100, 1, 1, 1, 1);11const report = require('fast-check-monorepo').report;12report(10, 100, 1, 1, 1, 1);13const report = require('fast-check-monorepo').report;14report(10, 100, 1, 1, 1, 1);15const report = require('fast-check-monorepo').report;16report(10, 100, 1, 1, 1, 1);17const report = require('fast-check-monorepo').report;18report(10, 100, 1, 1, 1, 1);19const report = require('fast-check-monorepo').report;20report(10, 100, 1, 1, 1,

Full Screen

Using AI Code Generation

copy

Full Screen

1const { report } = require('fast-check');2report(3 () => {4 },5 { seed: 42 }6);7const { report } = require('fast-check');8report(9 () => {10 },11 { seed: 42 }12);13const { report } = require('fast-check');14report(15 () => {16 },17 { seed: 42 }18);

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 fast-check-monorepo 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