How to use is method in wpt

Best JavaScript code snippet using wpt

tagmappings.js

Source:tagmappings.js Github

copy

Full Screen

1export const tagMapper = {2 school: [{3 section: "school",4 keyName: "amenity",5 isVisibleOnPopup: "FALSE",6 keyLabel: "-",7 isEditable: "FALSE",8 }, {9 section: "school",10 keyName: "name",11 isVisibleOnPopup: "TRUE",12 keyLabel: "Name",13 isEditable: "TRUE",14 }, {15 section: "school",16 keyName: "name:ne",17 isVisibleOnPopup: "TRUE",18 keyLabel: "नाम",19 isEditable: "TRUE",20 }, {21 section: "school",22 keyName: "operator:type",23 isVisibleOnPopup: "TRUE",24 keyLabel: "Operator Type",25 isEditable: "TRUE",26 }, {27 section: "school",28 keyName: "student:count",29 isVisibleOnPopup: "TRUE",30 keyLabel: "Number of students",31 isEditable: "TRUE",32 }, {33 section: "school",34 keyName: "personnel:count",35 isVisibleOnPopup: "TRUE",36 keyLabel: "Number of employees",37 isEditable: "TRUE",38 }, {39 section: "school",40 keyName: "opening_hours",41 isVisibleOnPopup: "TRUE",42 keyLabel: "Opening Hours",43 isEditable: "TRUE",44 }, {45 section: "school",46 keyName: "contact:phone",47 isVisibleOnPopup: "TRUE",48 keyLabel: "Phone Number",49 isEditable: "TRUE",50 }, {51 section: "school",52 keyName: "contact:email",53 isVisibleOnPopup: "TRUE",54 keyLabel: "Email Address",55 isEditable: "TRUE",56 }],57 hotel: [{58 section: "hotel",59 keyName: "amenity",60 isVisibleOnPopup: "FALSE",61 keyLabel: "-",62 isEditable: "FALSE",63 }, {64 section: "hotel",65 keyName: "name",66 isVisibleOnPopup: "TRUE",67 keyLabel: "Name",68 isEditable: "TRUE",69 }, {70 section: "hotel",71 keyName: "name:ne",72 isVisibleOnPopup: "TRUE",73 keyLabel: "नाम",74 isEditable: "TRUE",75 }, {76 section: "hotel",77 keyName: "stars",78 isVisibleOnPopup: "TRUE",79 keyLabel: "Stars",80 isEditable: "TRUE",81 }, {82 section: "hotel",83 keyName: "beds",84 isVisibleOnPopup: "TRUE",85 keyLabel: "Number of beds",86 isEditable: "TRUE",87 }, {88 section: "hotel",89 keyName: "rooms",90 isVisibleOnPopup: "TRUE",91 keyLabel: "Number of rooms",92 isEditable: "TRUE",93 }, {94 section: "hotel",95 keyName: "opening_hours",96 isVisibleOnPopup: "TRUE",97 keyLabel: "Opening Hours",98 isEditable: "TRUE",99 }, {100 section: "hotel",101 keyName: "contact:phone",102 isVisibleOnPopup: "TRUE",103 keyLabel: "Phone Number",104 isEditable: "TRUE",105 }, {106 section: "hotel",107 keyName: "contact:email",108 isVisibleOnPopup: "TRUE",109 keyLabel: "Email Address",110 isEditable: "TRUE",111 }],112 veterinary: [{113 section: "veterinary",114 keyName: "amenity",115 isVisibleOnPopup: "FALSE",116 keyLabel: "-",117 isEditable: "FALSE",118 }, {119 section: "veterinary",120 keyName: "name",121 isVisibleOnPopup: "TRUE",122 keyLabel: "Name",123 isEditable: "TRUE",124 }, {125 section: "veterinary",126 keyName: "name:ne",127 isVisibleOnPopup: "TRUE",128 keyLabel: "नाम",129 isEditable: "TRUE",130 }, {131 section: "veterinary",132 keyName: "opening_hours",133 isVisibleOnPopup: "TRUE",134 keyLabel: "Opening Hours",135 isEditable: "TRUE",136 }, {137 section: "veterinary",138 keyName: "contact:phone",139 isVisibleOnPopup: "TRUE",140 keyLabel: "Phone Number",141 isEditable: "TRUE",142 }, {143 section: "veterinary",144 keyName: "contact:email",145 isVisibleOnPopup: "TRUE",146 keyLabel: "Email Address",147 isEditable: "TRUE",148 }],149 hindu: [{150 section: "hindu",151 keyName: "amenity",152 isVisibleOnPopup: "FALSE",153 keyLabel: "-",154 isEditable: "FALSE",155 }, {156 section: "hindu",157 keyName: "name",158 isVisibleOnPopup: "TRUE",159 keyLabel: "Name",160 isEditable: "TRUE",161 }, {162 section: "hindu",163 keyName: "name:ne",164 isVisibleOnPopup: "TRUE",165 keyLabel: "नाम",166 isEditable: "TRUE",167 }, {168 section: "hindu",169 keyName: "religion",170 isVisibleOnPopup: "TRUE",171 keyLabel: "Religion",172 isEditable: "TRUE",173 }, {174 section: "hindu",175 keyName: "opening_hours",176 isVisibleOnPopup: "TRUE",177 keyLabel: "Opening Hours",178 isEditable: "TRUE",179 }, {180 section: "hindu",181 keyName: "contact:phone",182 isVisibleOnPopup: "TRUE",183 keyLabel: "Phone Number",184 isEditable: "TRUE",185 }, {186 section: "hindu",187 keyName: "contact:email",188 isVisibleOnPopup: "TRUE",189 keyLabel: "Email Address",190 isEditable: "TRUE",191 }, {192 section: "hindu",193 keyName: "facility:drinking_water",194 isVisibleOnPopup: "TRUE",195 keyLabel: "Drinking Water",196 isEditable: "TRUE",197 }, {198 section: "hindu",199 keyName: "facility:toilet",200 isVisibleOnPopup: "TRUE",201 keyLabel: "Toilet",202 isEditable: "TRUE",203 }],204 storage_tank: [{205 section: "storage_tank",206 keyName: "amenity",207 isVisibleOnPopup: "FALSE",208 keyLabel: "Water Storage Tank",209 isEditable: "FALSE",210 }, {211 section: "storage_tank",212 keyName: "name",213 isVisibleOnPopup: "TRUE",214 keyLabel: "Name",215 isEditable: "TRUE",216 }, {217 section: "storage_tank",218 keyName: "name:ne",219 isVisibleOnPopup: "TRUE",220 keyLabel: "नाम",221 isEditable: "TRUE",222 }, {223 section: "storage_tank",224 keyName: "opening_hours",225 isVisibleOnPopup: "TRUE",226 keyLabel: "Opening Hours",227 isEditable: "TRUE",228 }, {229 section: "storage_tank",230 keyName: "operator:type",231 isVisibleOnPopup: "TRUE",232 keyLabel: "Operator Type",233 isEditable: "TRUE",234 },{235 section: "storage_tank",236 keyName: "drinking_water",237 isVisibleOnPopup: "TRUE",238 keyLabel: "Drinking Water",239 isEditable: "TRUE",240 }],241 water_tap: [{242 section: "water_tap",243 keyName: "amenity",244 isVisibleOnPopup: "FALSE",245 keyLabel: "Water Storage Tank",246 isEditable: "FALSE",247 }, {248 section: "water_tap",249 keyName: "name",250 isVisibleOnPopup: "TRUE",251 keyLabel: "Name",252 isEditable: "TRUE",253 }, {254 section: "water_tap",255 keyName: "name:ne",256 isVisibleOnPopup: "TRUE",257 keyLabel: "नाम",258 isEditable: "TRUE",259 }, {260 section: "water_tap",261 keyName: "opening_hours",262 isVisibleOnPopup: "TRUE",263 keyLabel: "Opening Hours",264 isEditable: "TRUE",265 }, {266 section: "water_tap",267 keyName: "operator:type",268 isVisibleOnPopup: "TRUE",269 keyLabel: "Operator Type",270 isEditable: "TRUE",271 },{272 section: "water_tap",273 keyName: "drinking_water",274 isVisibleOnPopup: "TRUE",275 keyLabel: "Drinking Water",276 isEditable: "TRUE",277 }],278 water_well: [{279 section: "water_well",280 keyName: "amenity",281 isVisibleOnPopup: "FALSE",282 keyLabel: "Water Storage Tank",283 isEditable: "FALSE",284 }, {285 section: "water_well",286 keyName: "name",287 isVisibleOnPopup: "TRUE",288 keyLabel: "Name",289 isEditable: "TRUE",290 }, {291 section: "water_well",292 keyName: "name:ne",293 isVisibleOnPopup: "TRUE",294 keyLabel: "नाम",295 isEditable: "TRUE",296 }, {297 section: "water_well",298 keyName: "opening_hours",299 isVisibleOnPopup: "TRUE",300 keyLabel: "Opening Hours",301 isEditable: "TRUE",302 }, {303 section: "water_well",304 keyName: "operator:type",305 isVisibleOnPopup: "TRUE",306 keyLabel: "Operator Type",307 isEditable: "TRUE",308 },{309 section: "water_well",310 keyName: "drinking_water",311 isVisibleOnPopup: "TRUE",312 keyLabel: "Drinking Water",313 isEditable: "TRUE",314 }],315 police: [{316 section: "police",317 keyName: "amenity",318 isVisibleOnPopup: "FALSE",319 keyLabel: "Police",320 isEditable: "FALSE",321 }, {322 section: "police",323 keyName: "name",324 isVisibleOnPopup: "TRUE",325 keyLabel: "Name",326 isEditable: "TRUE",327 }, {328 section: "police",329 keyName: "name:ne",330 isVisibleOnPopup: "TRUE",331 keyLabel: "नाम",332 isEditable: "TRUE",333 }, {334 section: "police",335 keyName: "opening_hours",336 isVisibleOnPopup: "TRUE",337 keyLabel: "Opening Hours",338 isEditable: "TRUE",339 }, {340 section: "police",341 keyName: "contact:phone",342 isVisibleOnPopup: "TRUE",343 keyLabel: "Phone Number",344 isEditable: "TRUE",345 }, {346 section: "police",347 keyName: "contact:email",348 isVisibleOnPopup: "TRUE",349 keyLabel: "Email Address",350 isEditable: "TRUE",351 }],352 hospital: [{353 section: "hospital",354 keyName: "amenity",355 isVisibleOnPopup: "FALSE",356 keyLabel: "-",357 isEditable: "FALSE",358 }, {359 section: "hospital",360 keyName: "name",361 isVisibleOnPopup: "TRUE",362 keyLabel: "Name",363 isEditable: "TRUE",364 }, {365 section: "hospital",366 keyName: "name:ne",367 isVisibleOnPopup: "TRUE",368 keyLabel: "नाम",369 isEditable: "TRUE",370 }, {371 section: "hospital",372 keyName: "operator:type",373 isVisibleOnPopup: "TRUE",374 keyLabel: "Operator Type",375 isEditable: "TRUE",376 }, {377 section: "hospital",378 keyName: "opening_hours",379 isVisibleOnPopup: "TRUE",380 keyLabel: "Opening Hours",381 isEditable: "TRUE",382 }, {383 section: "hospital",384 keyName: "phone",385 isVisibleOnPopup: "TRUE",386 keyLabel: "Phone Number",387 isEditable: "TRUE",388 }, {389 section: "hospital",390 keyName: "contact:email",391 isVisibleOnPopup: "TRUE",392 keyLabel: "Email Address",393 isEditable: "TRUE",394 }, {395 section: "hospital",396 keyName: "emergency",397 isVisibleOnPopup: "TRUE",398 keyLabel: "Emergency Service",399 isEditable: "TRUE",400 }, {401 section: "hospital",402 keyName: "facility:icu",403 isVisibleOnPopup: "TRUE",404 keyLabel: "ICU",405 isEditable: "TRUE",406 }, {407 section: "hospital",408 keyName: "facility:nicu",409 isVisibleOnPopup: "TRUE",410 keyLabel: "NICU",411 isEditable: "TRUE",412 }, {413 section: "hospital",414 keyName: "facility:operating_theatre",415 isVisibleOnPopup: "TRUE",416 keyLabel: "Operating Theatre",417 isEditable: "TRUE",418 }, {419 section: "hospital",420 keyName: "facility:x-ray",421 isVisibleOnPopup: "TRUE",422 keyLabel: "X-Ray",423 isEditable: "TRUE",424 }, {425 section: "hospital",426 keyName: "facility:ambulance",427 isVisibleOnPopup: "TRUE",428 keyLabel: "Ambulance Service",429 isEditable: "TRUE",430 }, {431 section: "hospital",432 keyName: "personnel:count",433 isVisibleOnPopup: "TRUE",434 keyLabel: "Number of Staff",435 isEditable: "TRUE",436 }, {437 section: "hospital",438 keyName: "capacity:beds",439 isVisibleOnPopup: "TRUE",440 keyLabel: "Number of Beds",441 isEditable: "TRUE",442 }],443 clinic: [{444 section: "clinic",445 keyName: "amenity",446 isVisibleOnPopup: "FALSE",447 keyLabel: "-",448 isEditable: "FALSE",449 }, {450 section: "clinic",451 keyName: "healthcare",452 isVisibleOnPopup: "FALSE",453 keyLabel: "-",454 isEditable: "FALSE",455 }, {456 section: "clinic",457 keyName: "name",458 isVisibleOnPopup: "TRUE",459 keyLabel: "Name",460 isEditable: "TRUE",461 }, {462 section: "clinic",463 keyName: "name:ne",464 isVisibleOnPopup: "TRUE",465 keyLabel: "नाम",466 isEditable: "TRUE",467 }, {468 section: "clinic",469 keyName: "contact:phone",470 isVisibleOnPopup: "TRUE",471 keyLabel: "Phone",472 isEditable: "TRUE",473 }, {474 section: "clinic",475 keyName: "contact:email",476 isVisibleOnPopup: "TRUE",477 keyLabel: "Email Address",478 isEditable: "TRUE",479 }, {480 section: "clinic",481 keyName: "opening_hours",482 isVisibleOnPopup: "TRUE",483 keyLabel: "Opening Hours",484 isEditable: "TRUE",485 }, {486 section: "clinic",487 keyName: "healthcare:speciality",488 isVisibleOnPopup: "TRUE",489 keyLabel: "Specialisation",490 isEditable: "TRUE",491 }],492 health_post: [{493 section: "health_post",494 keyName: "amenity",495 isVisibleOnPopup: "FALSE",496 keyLabel: "-",497 isEditable: "FALSE",498 }, {499 section: "health_post",500 keyName: "name",501 isVisibleOnPopup: "TRUE",502 keyLabel: "Name",503 isEditable: "TRUE",504 }, {505 section: "health_post",506 keyName: "name:ne",507 isVisibleOnPopup: "TRUE",508 keyLabel: "नाम",509 isEditable: "TRUE",510 }, {511 section: "health_post",512 keyName: "contact:phone",513 isVisibleOnPopup: "TRUE",514 keyLabel: "Phone",515 isEditable: "TRUE",516 }, {517 section: "health_post",518 keyName: "contact:email",519 isVisibleOnPopup: "TRUE",520 keyLabel: "Email Address",521 isEditable: "TRUE",522 }, {523 section: "health_post",524 keyName: "opening_hours",525 isVisibleOnPopup: "TRUE",526 keyLabel: "Opening Hours",527 isEditable: "TRUE",528 }, {529 section: "health_post",530 keyName: "operator:type",531 isVisibleOnPopup: "TRUE",532 keyLabel: "Operator Type",533 isEditable: "TRUE",534 }],535 pharmacy: [{536 section: "pharmacy",537 keyName: "amenity",538 isVisibleOnPopup: "FALSE",539 keyLabel: "-",540 isEditable: "FALSE",541 }, {542 section: "pharmacy",543 keyName: "name",544 isVisibleOnPopup: "TRUE",545 keyLabel: "Name",546 isEditable: "TRUE",547 }, {548 section: "pharmacy",549 keyName: "name:ne",550 isVisibleOnPopup: "TRUE",551 keyLabel: "नाम",552 isEditable: "TRUE",553 }, {554 section: "pharmacy",555 keyName: "contact:phone",556 isVisibleOnPopup: "TRUE",557 keyLabel: "Phone",558 isEditable: "TRUE",559 }, {560 section: "pharmacy",561 keyName: "contact:email",562 isVisibleOnPopup: "TRUE",563 keyLabel: "Email Address",564 isEditable: "TRUE",565 }, {566 section: "pharmacy",567 keyName: "opening_hours",568 isVisibleOnPopup: "TRUE",569 keyLabel: "Opening Hours",570 isEditable: "TRUE",571 }],572 dentist: [{573 section: "dentist",574 keyName: "amenity",575 isVisibleOnPopup: "FALSE",576 keyLabel: "",577 isEditable: "FALSE",578 }, {579 section: "dentist",580 keyName: "name",581 isVisibleOnPopup: "TRUE",582 keyLabel: "Name",583 isEditable: "TRUE",584 }, {585 section: "dentist",586 keyName: "name:ne",587 isVisibleOnPopup: "TRUE",588 keyLabel: "नाम",589 isEditable: "TRUE",590 }, {591 section: "dentist",592 keyName: "contact:phone",593 isVisibleOnPopup: "TRUE",594 keyLabel: "Phone",595 isEditable: "TRUE",596 }, {597 section: "dentist",598 keyName: "contact:email",599 isVisibleOnPopup: "TRUE",600 keyLabel: "Email Address",601 isEditable: "TRUE",602 }, {603 section: "dentist",604 keyName: "opening_hours",605 isVisibleOnPopup: "TRUE",606 keyLabel: "Opening Hours",607 isEditable: "TRUE",608 }],609 Veterinarians: [{610 section: "Veterinarians",611 keyName: "amenity",612 isVisibleOnPopup: "FALSE",613 keyLabel: "",614 isEditable: "FALSE",615 }, {616 section: "Veterinarians",617 keyName: "name",618 isVisibleOnPopup: "TRUE",619 keyLabel: "Name",620 isEditable: "TRUE",621 }, {622 section: "Veterinarians",623 keyName: "name:ne",624 isVisibleOnPopup: "TRUE",625 keyLabel: "नाम",626 isEditable: "TRUE",627 }, {628 section: "Veterinarians",629 keyName: "contact:phone",630 isVisibleOnPopup: "TRUE",631 keyLabel: "Phone",632 isEditable: "TRUE",633 }, {634 section: "Veterinarians",635 keyName: "contact:email",636 isVisibleOnPopup: "TRUE",637 keyLabel: "Email Address",638 isEditable: "TRUE",639 }, {640 section: "Veterinarians",641 keyName: "opening_hours",642 isVisibleOnPopup: "TRUE",643 keyLabel: "Opening Hours",644 isEditable: "TRUE",645 }],646 government: [{647 section: "government",648 keyName: "office",649 isVisibleOnPopup: "FALSE",650 keyLabel: "",651 isEditable: "FALSE",652 }, {653 section: "government",654 keyName: "name",655 isVisibleOnPopup: "TRUE",656 keyLabel: "Name",657 isEditable: "TRUE",658 }, {659 section: "government",660 keyName: "name:ne",661 isVisibleOnPopup: "TRUE",662 keyLabel: "नाम",663 isEditable: "TRUE",664 }, {665 section: "government",666 keyName: "contact:phone",667 isVisibleOnPopup: "TRUE",668 keyLabel: "Phone",669 isEditable: "TRUE",670 }, {671 section: "government",672 keyName: "contact:email",673 isVisibleOnPopup: "TRUE",674 keyLabel: "Email Address",675 isEditable: "TRUE",676 }, {677 section: "government",678 keyName: "opening_hours",679 isVisibleOnPopup: "TRUE",680 keyLabel: "Opening Hours",681 isEditable: "TRUE",682 }],683 ngo: [{684 section: "ngo",685 keyName: "office",686 isVisibleOnPopup: "FALSE",687 keyLabel: "",688 isEditable: "FALSE",689 }, {690 section: "ngo",691 keyName: "name",692 isVisibleOnPopup: "TRUE",693 keyLabel: "Name",694 isEditable: "TRUE",695 }, {696 section: "ngo",697 keyName: "name:ne",698 isVisibleOnPopup: "TRUE",699 keyLabel: "नाम",700 isEditable: "TRUE",701 }, {702 section: "ngo",703 keyName: "contact:phone",704 isVisibleOnPopup: "TRUE",705 keyLabel: "Phone",706 isEditable: "TRUE",707 }, {708 section: "ngo",709 keyName: "contact:email",710 isVisibleOnPopup: "TRUE",711 keyLabel: "Email Address",712 isEditable: "TRUE",713 }, {714 section: "ngo",715 keyName: "opening_hours",716 isVisibleOnPopup: "TRUE",717 keyLabel: "Opening Hours",718 isEditable: "TRUE",719 }],720 bank: [{721 section: "bank",722 keyName: "amenity",723 isVisibleOnPopup: "FALSE",724 keyLabel: "",725 isEditable: "FALSE",726 }, {727 section: "bank",728 keyName: "name",729 isVisibleOnPopup: "TRUE",730 keyLabel: "Name",731 isEditable: "TRUE",732 }, {733 section: "bank",734 keyName: "name:ne",735 isVisibleOnPopup: "TRUE",736 keyLabel: "नाम",737 isEditable: "TRUE",738 }, {739 section: "bank",740 keyName: "contact:phone",741 isVisibleOnPopup: "TRUE",742 keyLabel: "Phone",743 isEditable: "TRUE",744 }, {745 section: "bank",746 keyName: "contact:email",747 isVisibleOnPopup: "TRUE",748 keyLabel: "Email Address",749 isEditable: "TRUE",750 }, {751 section: "bank",752 keyName: "opening_hours",753 isVisibleOnPopup: "TRUE",754 keyLabel: "Opening Hours",755 isEditable: "TRUE",756 }, {757 section: "bank",758 keyName: "operator:type",759 isVisibleOnPopup: "TRUE",760 keyLabel: "Operator Type",761 isEditable: "TRUE",762 }, {763 section: "bank",764 keyName: "nrb_class",765 isVisibleOnPopup: "TRUE",766 keyLabel: "Bank Classfication",767 isEditable: "TRUE",768 }, {769 section: "bank",770 keyName: "atm",771 isVisibleOnPopup: "TRUE",772 keyLabel: "ATM Available",773 isEditable: "TRUE",774 }],775 fuel: [{776 section: "fuel",777 keyName: "amenity",778 isVisibleOnPopup: "FALSE",779 keyLabel: "",780 isEditable: "FALSE",781 }, {782 section: "fuel",783 keyName: "name",784 isVisibleOnPopup: "TRUE",785 keyLabel: "Name",786 isEditable: "TRUE",787 }, {788 section: "fuel",789 keyName: "name:ne",790 isVisibleOnPopup: "TRUE",791 keyLabel: "नाम",792 isEditable: "TRUE",793 }, {794 section: "fuel",795 keyName: "contact:phone",796 isVisibleOnPopup: "TRUE",797 keyLabel: "Phone",798 isEditable: "TRUE",799 }, {800 section: "fuel",801 keyName: "contact:email",802 isVisibleOnPopup: "TRUE",803 keyLabel: "Email Address",804 isEditable: "TRUE",805 }, {806 section: "fuel",807 keyName: "opening_hours",808 isVisibleOnPopup: "TRUE",809 keyLabel: "Opening Hours",810 isEditable: "TRUE",811 }],812 radio: [{813 section: "radio",814 keyName: "amenity",815 isVisibleOnPopup: "FALSE",816 keyLabel: "",817 isEditable: "FALSE",818 }, {819 section: "radio",820 keyName: "studio",821 isVisibleOnPopup: "FALSE",822 keyLabel: "",823 isEditable: "FALSE",824 }, {825 section: "radio",826 keyName: "name",827 isVisibleOnPopup: "TRUE",828 keyLabel: "Name",829 isEditable: "TRUE",830 }, {831 section: "radio",832 keyName: "name:ne",833 isVisibleOnPopup: "TRUE",834 keyLabel: "नाम",835 isEditable: "TRUE",836 }, {837 section: "radio",838 keyName: "contact:phone",839 isVisibleOnPopup: "TRUE",840 keyLabel: "Phone",841 isEditable: "TRUE",842 }, {843 section: "radio",844 keyName: "contact:email",845 isVisibleOnPopup: "TRUE",846 keyLabel: "Email Address",847 isEditable: "TRUE",848 }, {849 section: "radio",850 keyName: "opening_hours",851 isVisibleOnPopup: "TRUE",852 keyLabel: "Opening Hours",853 isEditable: "TRUE",854 }, {855 section: "radio",856 keyName: "frequency",857 isVisibleOnPopup: "TRUE",858 keyLabel: "Frequency",859 isEditable: "TRUE",860 }],861 television: [{862 section: "television",863 keyName: "amenity",864 isVisibleOnPopup: "FALSE",865 keyLabel: "",866 isEditable: "FALSE",867 }, {868 section: "television",869 keyName: "studio",870 isVisibleOnPopup: "FALSE",871 keyLabel: "",872 isEditable: "FALSE",873 }, {874 section: "television",875 keyName: "name",876 isVisibleOnPopup: "TRUE",877 keyLabel: "Name",878 isEditable: "TRUE",879 }, {880 section: "television",881 keyName: "name:ne",882 isVisibleOnPopup: "TRUE",883 keyLabel: "नाम",884 isEditable: "TRUE",885 }, {886 section: "television",887 keyName: "contact:phone",888 isVisibleOnPopup: "TRUE",889 keyLabel: "Phone",890 isEditable: "TRUE",891 }, {892 section: "television",893 keyName: "contact:email",894 isVisibleOnPopup: "TRUE",895 keyLabel: "Email Address",896 isEditable: "TRUE",897 }, {898 section: "television",899 keyName: "opening_hours",900 isVisibleOnPopup: "TRUE",901 keyLabel: "Opening Hours",902 isEditable: "TRUE",903 }],904 newspaper: [{905 section: "newspaper",906 keyName: "office",907 isVisibleOnPopup: "FALSE",908 keyLabel: "",909 isEditable: "FALSE",910 }, {911 section: "newspaper",912 keyName: "name",913 isVisibleOnPopup: "TRUE",914 keyLabel: "Name",915 isEditable: "TRUE",916 }, {917 section: "newspaper",918 keyName: "name:ne",919 isVisibleOnPopup: "TRUE",920 keyLabel: "नाम",921 isEditable: "TRUE",922 }, {923 section: "newspaper",924 keyName: "contact:phone",925 isVisibleOnPopup: "TRUE",926 keyLabel: "Phone",927 isEditable: "TRUE",928 }, {929 section: "newspaper",930 keyName: "contact:email",931 isVisibleOnPopup: "TRUE",932 keyLabel: "Email Address",933 isEditable: "TRUE",934 }, {935 section: "newspaper",936 keyName: "opening_hours",937 isVisibleOnPopup: "TRUE",938 keyLabel: "Opening Hours",939 isEditable: "TRUE",940 }],941 college: [{942 section: "college",943 keyName: "amenity",944 isVisibleOnPopup: "FALSE",945 keyLabel: "-",946 isEditable: "FALSE",947 }, {948 section: "college",949 keyName: "name",950 isVisibleOnPopup: "TRUE",951 keyLabel: "Name",952 isEditable: "TRUE",953 }, {954 section: "college",955 keyName: "name:ne",956 isVisibleOnPopup: "TRUE",957 keyLabel: "नाम",958 isEditable: "TRUE",959 }, {960 section: "college",961 keyName: "operator:type",962 isVisibleOnPopup: "TRUE",963 keyLabel: "Operator Type",964 isEditable: "TRUE",965 }, {966 section: "college",967 keyName: "student:count",968 isVisibleOnPopup: "TRUE",969 keyLabel: "Number of students",970 isEditable: "TRUE",971 }, {972 section: "college",973 keyName: "personnel:count",974 isVisibleOnPopup: "TRUE",975 keyLabel: "Number of employees",976 isEditable: "TRUE",977 }, {978 section: "college",979 keyName: "opening_hours",980 isVisibleOnPopup: "TRUE",981 keyLabel: "Opening Hours",982 isEditable: "TRUE",983 }, {984 section: "college",985 keyName: "contact:phone",986 isVisibleOnPopup: "TRUE",987 keyLabel: "Phone Number",988 isEditable: "TRUE",989 }, {990 section: "college",991 keyName: "contact:email",992 isVisibleOnPopup: "TRUE",993 keyLabel: "Email Address",994 isEditable: "TRUE",995 }],996 university: [{997 section: "university",998 keyName: "amenity",999 isVisibleOnPopup: "FALSE",1000 keyLabel: "-",1001 isEditable: "FALSE",1002 }, {1003 section: "university",1004 keyName: "name",1005 isVisibleOnPopup: "TRUE",1006 keyLabel: "Name",1007 isEditable: "TRUE",1008 }, {1009 section: "university",1010 keyName: "name:ne",1011 isVisibleOnPopup: "TRUE",1012 keyLabel: "नाम",1013 isEditable: "TRUE",1014 }, {1015 section: "university",1016 keyName: "operator:type",1017 isVisibleOnPopup: "TRUE",1018 keyLabel: "Operator Type",1019 isEditable: "TRUE",1020 }, {1021 section: "university",1022 keyName: "student:count",1023 isVisibleOnPopup: "TRUE",1024 keyLabel: "Number of students",1025 isEditable: "TRUE",1026 }, {1027 section: "university",1028 keyName: "personnel:count",1029 isVisibleOnPopup: "TRUE",1030 keyLabel: "Number of employees",1031 isEditable: "TRUE",1032 }, {1033 section: "university",1034 keyName: "opening_hours",1035 isVisibleOnPopup: "TRUE",1036 keyLabel: "Opening Hours",1037 isEditable: "TRUE",1038 }, {1039 section: "university",1040 keyName: "contact:phone",1041 isVisibleOnPopup: "TRUE",1042 keyLabel: "Phone Number",1043 isEditable: "TRUE",1044 }, {1045 section: "university",1046 keyName: "contact:email",1047 isVisibleOnPopup: "TRUE",1048 keyLabel: "Email Address",1049 isEditable: "TRUE",1050 }],1051 kindergarten: [{1052 section: "kindergarten",1053 keyName: "amenity",1054 isVisibleOnPopup: "FALSE",1055 keyLabel: "-",1056 isEditable: "FALSE",1057 }, {1058 section: "kindergarten",1059 keyName: "name",1060 isVisibleOnPopup: "TRUE",1061 keyLabel: "Name",1062 isEditable: "TRUE",1063 }, {1064 section: "kindergarten",1065 keyName: "name:ne",1066 isVisibleOnPopup: "TRUE",1067 keyLabel: "नाम",1068 isEditable: "TRUE",1069 }, {1070 section: "kindergarten",1071 keyName: "operator:type",1072 isVisibleOnPopup: "TRUE",1073 keyLabel: "Operator Type",1074 isEditable: "TRUE",1075 }, {1076 section: "kindergarten",1077 keyName: "student:count",1078 isVisibleOnPopup: "TRUE",1079 keyLabel: "Number of students",1080 isEditable: "TRUE",1081 }, {1082 section: "kindergarten",1083 keyName: "personnel:count",1084 isVisibleOnPopup: "TRUE",1085 keyLabel: "Number of employees",1086 isEditable: "TRUE",1087 }, {1088 section: "kindergarten",1089 keyName: "opening_hours",1090 isVisibleOnPopup: "TRUE",1091 keyLabel: "Opening Hours",1092 isEditable: "TRUE",1093 }, {1094 section: "kindergarten",1095 keyName: "contact:phone",1096 isVisibleOnPopup: "TRUE",1097 keyLabel: "Phone Number",1098 isEditable: "TRUE",1099 }, {1100 section: "kindergarten",1101 keyName: "contact:email",1102 isVisibleOnPopup: "TRUE",1103 keyLabel: "Email Address",1104 isEditable: "TRUE",1105 }],1106 buddhist: [{1107 section: "buddhist",1108 keyName: "amenity",1109 isVisibleOnPopup: "FALSE",1110 keyLabel: "-",1111 isEditable: "FALSE",1112 }, {1113 section: "buddhist",1114 keyName: "name",1115 isVisibleOnPopup: "TRUE",1116 keyLabel: "Name",1117 isEditable: "TRUE",1118 }, {1119 section: "buddhist",1120 keyName: "name:ne",1121 isVisibleOnPopup: "TRUE",1122 keyLabel: "नाम",1123 isEditable: "TRUE",1124 }, {1125 section: "buddhist",1126 keyName: "religion",1127 isVisibleOnPopup: "TRUE",1128 keyLabel: "Religion",1129 isEditable: "TRUE",1130 }, {1131 section: "buddhist",1132 keyName: "opening_hours",1133 isVisibleOnPopup: "TRUE",1134 keyLabel: "Opening Hours",1135 isEditable: "TRUE",1136 }, {1137 section: "buddhist",1138 keyName: "contact:phone",1139 isVisibleOnPopup: "TRUE",1140 keyLabel: "Phone Number",1141 isEditable: "TRUE",1142 }, {1143 section: "buddhist",1144 keyName: "contact:email",1145 isVisibleOnPopup: "TRUE",1146 keyLabel: "Email Address",1147 isEditable: "TRUE",1148 }, {1149 section: "buddhist",1150 keyName: "facility:drinking_water",1151 isVisibleOnPopup: "TRUE",1152 keyLabel: "Drinking Water",1153 isEditable: "TRUE",1154 }, {1155 section: "buddhist",1156 keyName: "facility:toilet",1157 isVisibleOnPopup: "TRUE",1158 keyLabel: "Toilet",1159 isEditable: "TRUE",1160 }],1161 christian: [{1162 section: "christian",1163 keyName: "amenity",1164 isVisibleOnPopup: "FALSE",1165 keyLabel: "-",1166 isEditable: "FALSE",1167 }, {1168 section: "christian",1169 keyName: "name",1170 isVisibleOnPopup: "TRUE",1171 keyLabel: "Name",1172 isEditable: "TRUE",1173 }, {1174 section: "christian",1175 keyName: "name:ne",1176 isVisibleOnPopup: "TRUE",1177 keyLabel: "नाम",1178 isEditable: "TRUE",1179 }, {1180 section: "christian",1181 keyName: "religion",1182 isVisibleOnPopup: "TRUE",1183 keyLabel: "Religion",1184 isEditable: "TRUE",1185 }, {1186 section: "christian",1187 keyName: "opening_hours",1188 isVisibleOnPopup: "TRUE",1189 keyLabel: "Opening Hours",1190 isEditable: "TRUE",1191 }, {1192 section: "christian",1193 keyName: "contact:phone",1194 isVisibleOnPopup: "TRUE",1195 keyLabel: "Phone Number",1196 isEditable: "TRUE",1197 }, {1198 section: "christian",1199 keyName: "contact:email",1200 isVisibleOnPopup: "TRUE",1201 keyLabel: "Email Address",1202 isEditable: "TRUE",1203 }, {1204 section: "christian",1205 keyName: "facility:drinking_water",1206 isVisibleOnPopup: "TRUE",1207 keyLabel: "Drinking Water",1208 isEditable: "TRUE",1209 }, {1210 section: "christian",1211 keyName: "facility:toilet",1212 isVisibleOnPopup: "TRUE",1213 keyLabel: "Toilet",1214 isEditable: "TRUE",1215 }],1216 muslim: [{1217 section: "muslim",1218 keyName: "amenity",1219 isVisibleOnPopup: "FALSE",1220 keyLabel: "-",1221 isEditable: "FALSE",1222 }, {1223 section: "muslim",1224 keyName: "name",1225 isVisibleOnPopup: "TRUE",1226 keyLabel: "Name",1227 isEditable: "TRUE",1228 }, {1229 section: "muslim",1230 keyName: "name:ne",1231 isVisibleOnPopup: "TRUE",1232 keyLabel: "नाम",1233 isEditable: "TRUE",1234 }, {1235 section: "muslim",1236 keyName: "religion",1237 isVisibleOnPopup: "TRUE",1238 keyLabel: "Religion",1239 isEditable: "TRUE",1240 }, {1241 section: "muslim",1242 keyName: "opening_hours",1243 isVisibleOnPopup: "TRUE",1244 keyLabel: "Opening Hours",1245 isEditable: "TRUE",1246 }, {1247 section: "muslim",1248 keyName: "contact:phone",1249 isVisibleOnPopup: "TRUE",1250 keyLabel: "Phone Number",1251 isEditable: "TRUE",1252 }, {1253 section: "muslim",1254 keyName: "contact:email",1255 isVisibleOnPopup: "TRUE",1256 keyLabel: "Email Address",1257 isEditable: "TRUE",1258 }, {1259 section: "muslim",1260 keyName: "facility:drinking_water",1261 isVisibleOnPopup: "TRUE",1262 keyLabel: "Drinking Water",1263 isEditable: "TRUE",1264 }, {1265 section: "muslim",1266 keyName: "facility:toilet",1267 isVisibleOnPopup: "TRUE",1268 keyLabel: "Toilet",1269 isEditable: "TRUE",1270 }],1271 atm: [{1272 section: "atm",1273 keyName: "amenity",1274 isVisibleOnPopup: "FALSE",1275 keyLabel: "",1276 isEditable: "FALSE",1277 }, {1278 section: "atm",1279 keyName: "network",1280 isVisibleOnPopup: "TRUE",1281 keyLabel: "Network Supported",1282 isEditable: "TRUE",1283 }, {1284 section: "atm",1285 keyName: "opening_hours",1286 isVisibleOnPopup: "TRUE",1287 keyLabel: "Opening Hours",1288 isEditable: "TRUE",1289 }],1290 restaurant: [{1291 section: "restaurant",1292 keyName: "amenity",1293 isVisibleOnPopup: "FALSE",1294 keyLabel: "",1295 isEditable: "FALSE",1296 }, {1297 section: "restaurant",1298 keyName: "name",1299 isVisibleOnPopup: "TRUE",1300 keyLabel: "Name",1301 isEditable: "TRUE",1302 }, {1303 section: "restaurant",1304 keyName: "name:ne",1305 isVisibleOnPopup: "TRUE",1306 keyLabel: "नाम",1307 isEditable: "TRUE",1308 }],1309 museum: [{1310 section: "museum",1311 keyName: "tourism",1312 isVisibleOnPopup: "FALSE",1313 keyLabel: "",1314 isEditable: "FALSE",1315 }, {1316 section: "museum",1317 keyName: "name",1318 isVisibleOnPopup: "TRUE",1319 keyLabel: "Name",1320 isEditable: "TRUE",1321 }, {1322 section: "museum",1323 keyName: "name:ne",1324 isVisibleOnPopup: "TRUE",1325 keyLabel: "नाम",1326 isEditable: "TRUE",1327 }, {1328 section: "museum",1329 keyName: "contact:phone",1330 isVisibleOnPopup: "TRUE",1331 keyLabel: "Phone",1332 isEditable: "TRUE",1333 }, {1334 section: "museum",1335 keyName: "contact:email",1336 isVisibleOnPopup: "TRUE",1337 keyLabel: "Email Address",1338 isEditable: "TRUE",1339 }, {1340 section: "museum",1341 keyName: "opening_hours",1342 isVisibleOnPopup: "TRUE",1343 keyLabel: "Opening Hours",1344 isEditable: "TRUE",1345 }],1346 park: [{1347 section: "park",1348 keyName: "tourism",1349 isVisibleOnPopup: "FALSE",1350 keyLabel: "",1351 isEditable: "FALSE",1352 }, {1353 section: "park",1354 keyName: "name",1355 isVisibleOnPopup: "TRUE",1356 keyLabel: "Name",1357 isEditable: "TRUE",1358 }, {1359 section: "park",1360 keyName: "name:ne",1361 isVisibleOnPopup: "TRUE",1362 keyLabel: "नाम",1363 isEditable: "TRUE",1364 }, {1365 section: "park",1366 keyName: "contact:phone",1367 isVisibleOnPopup: "TRUE",1368 keyLabel: "Phone",1369 isEditable: "TRUE",1370 }, {1371 section: "park",1372 keyName: "contact:email",1373 isVisibleOnPopup: "TRUE",1374 keyLabel: "Email Address",1375 isEditable: "TRUE",1376 }, {1377 section: "park",1378 keyName: "opening_hours",1379 isVisibleOnPopup: "TRUE",1380 keyLabel: "Opening Hours",1381 isEditable: "TRUE",1382 }],...

Full Screen

Full Screen

test_Base.js

Source:test_Base.js Github

copy

Full Screen

...7 var self = {"toString": function () { return "self"; } };8 var func = function (arg) { return this.toString() + " " + arg; };9 var boundFunc = bind(func, self);10 not_self.boundFunc = boundFunc;11 t.is( isEmpty([], [], ""), true, "isEmpty true" )12 t.is( isEmpty([], [1], ""), true, "isEmpty true" )13 t.is( isNotEmpty([], [], ""), false, "isNotEmpty false" )14 t.is( isNotEmpty([], [1], ""), false, "isNotEmpty false" )15 t.is( isEmpty([1], [1], "1"), false, "isEmpty false" )16 t.is( isEmpty([1], [1], "1"), false, "isEmpty false" )17 t.is( isNotEmpty([1], [1], "1"), true, "isNotEmpty true" )18 t.is( isNotEmpty([1], [1], "1"), true, "isNotEmpty true" )19 t.is( boundFunc("foo"), "self foo", "boundFunc bound to self properly" );20 t.is( not_self.boundFunc("foo"), "self foo", "boundFunc bound to self on another obj" );21 t.is( bind(boundFunc, not_self)("foo"), "not self foo", "boundFunc successfully rebound!" );22 t.is( bind(boundFunc, undefined, "foo")(), "self foo", "boundFunc partial no self change" );23 t.is( bind(boundFunc, not_self, "foo")(), "not self foo", "boundFunc partial self change" );24 // test method25 not_self = {"toString": function () { return "not self"; } };26 self = {"toString": function () { return "self"; } };27 func = function (arg) { return this.toString() + " " + arg; };28 var boundMethod = method(self, func);29 not_self.boundMethod = boundMethod;30 t.is( boundMethod("foo"), "self foo", "boundMethod bound to self properly" );31 t.is( not_self.boundMethod("foo"), "self foo", "boundMethod bound to self on another obj" );32 t.is( method(not_self, boundMethod)("foo"), "not self foo", "boundMethod successfully rebound!" );33 t.is( method(undefined, boundMethod, "foo")(), "self foo", "boundMethod partial no self change" );34 t.is( method(not_self, boundMethod, "foo")(), "not self foo", "boundMethod partial self change" );35 // test bindMethods36 var O = function (value) {37 bindMethods(this);38 this.value = value;39 };40 O.prototype.func = function () {41 return this.value;42 };43 var o = new O("boring");44 var p = {};45 p.func = o.func;46 var func = o.func;47 t.is( o.func(), "boring", "bindMethods doesn't break shit" );48 t.is( p.func(), "boring", "bindMethods works on other objects" );49 t.is( func(), "boring", "bindMethods works on functions" );50 var p = clone(o);51 t.ok( p instanceof O, "cloned correct inheritance" );52 var q = clone(p);53 t.ok( q instanceof O, "clone-cloned correct inheritance" );54 q.foo = "bar";55 t.is( p.foo, undefined, "clone-clone is copy-on-write" );56 p.bar = "foo";57 t.is( o.bar, undefined, "clone is copy-on-write" );58 t.is( q.bar, "foo", "clone-clone has proper delegation" );59 // unbind60 p.func = bind(p.func, null);61 t.is( p.func(), "boring", "clone function calls correct" );62 q.value = "awesome";63 t.is( q.func(), "awesome", "clone really does work" );64 65 // test boring boolean funcs66 t.is( isCallable(isCallable), true, "isCallable returns true on itself" );67 t.is( isCallable(1), false, "isCallable returns false on numbers" );68 t.is( isUndefined(null), false, "null is not undefined" );69 t.is( isUndefined(""), false, "empty string is not undefined" );70 t.is( isUndefined(undefined), true, "undefined is undefined" );71 t.is( isUndefined({}.foo), true, "missing property is undefined" );72 t.is( isUndefinedOrNull(null), true, "null is undefined or null" );73 t.is( isUndefinedOrNull(""), false, "empty string is not undefined or null" );74 t.is( isUndefinedOrNull(undefined), true, "undefined is undefined or null" );75 t.is( isUndefinedOrNull({}.foo), true, "missing property is undefined or null" );76 // test extension of arrays77 var a = [];78 var b = [];79 var three = [1, 2, 3];80 extend(a, three, 1);81 t.ok( objEqual(a, [2, 3]), "extend to an empty array" );82 extend(a, three, 1)83 t.ok( objEqual(a, [2, 3, 2, 3]), "extend to a non-empty array" );84 extend(b, three);85 t.ok( objEqual(b, three), "extend of an empty array" );86 var c1 = extend(null, three);87 t.ok( objEqual(c1, three), "extend null" );88 var c2 = extend(undefined, three);89 t.ok( objEqual(c2, three), "extend undefined" );90 t.is( compare(1, 2), -1, "numbers compare lt" );91 t.is( compare(2, 1), 1, "numbers compare gt" );92 t.is( compare(1, 1), 0, "numbers compare eq" );93 t.is( compare([1], [1]), 0, "arrays compare eq" );94 t.is( compare([1], [1, 2]), -1, "arrays compare lt (length)" );95 t.is( compare([1, 2], [2, 1]), -1, "arrays compare lt (contents)" );96 t.is( compare([1, 2], [1]), 1, "arrays compare gt (length)" );97 t.is( compare([2, 1], [1, 1]), 1, "arrays compare gt (contents)" );98 99 // test partial application100 var a = [];101 var func = function (a, b) {102 if (arguments.length != 2) {103 return "bad args";104 } else {105 return this.value + a + b;106 }107 };108 var self = {"value": 1, "func": func};109 var self2 = {"value": 2};110 t.is( self.func(2, 3), 6, "setup for test is correct" );111 self.funcTwo = partial(self.func, 2);112 t.is( self.funcTwo(3), 6, "partial application works" );113 t.is( self.funcTwo(3), 6, "partial application works still" );114 t.is( bind(self.funcTwo, self2)(3), 7, "rebinding partial works" );115 self.funcTwo = bind(bind(self.funcTwo, self2), null);116 t.is( self.funcTwo(3), 6, "re-unbinding partial application works" );117 118 // nodeWalk test119 // ... looks a lot like a DOM tree on purpose120 var tree = {121 "id": "nodeWalkTestTree",122 "test:int": "1",123 "childNodes": [124 {125 "test:int": "2",126 "childNodes": [127 {"test:int": "5"},128 "ignored string",129 {"ignored": "object"},130 ["ignored", "list"],131 {132 "test:skipchildren": "1",133 "childNodes": [{"test:int": 6}]134 }135 ]136 },137 {"test:int": "3"},138 {"test:int": "4"}139 ]140 }141 var visitedNodes = [];142 nodeWalk(tree, function (node) {143 var attr = node["test:int"];144 if (attr) {145 visitedNodes.push(attr);146 }147 if (node["test:skipchildren"]) {148 return;149 }150 return node.childNodes;151 });152 t.ok( objEqual(visitedNodes, ["1", "2", "3", "4", "5"]), "nodeWalk looks like it works");153 154 // test map155 var minusOne = function (x) { return x - 1; };156 var res = map(minusOne, [1, 2, 3]);157 t.ok( objEqual(res, [0, 1, 2]), "map works" );158 var res2 = xmap(minusOne, 1, 2, 3);159 t.ok( objEqual(res2, res), "xmap works" );160 res = map(operator.add, [1, 2, 3], [2, 4, 6]);161 t.ok( objEqual(res, [3, 6, 9]), "map(fn, p, q) works" );162 res = map(operator.add, [1, 2, 3], [2, 4, 6, 8]);163 t.ok( objEqual(res, [3, 6, 9]), "map(fn, p, q) works (q long)" );164 res = map(operator.add, [1, 2, 3, 4], [2, 4, 6]);165 t.ok( objEqual(res, [3, 6, 9]), "map(fn, p, q) works (p long)" );166 res = map(null, [1, 2, 3], [2, 4, 6]);167 t.ok( objEqual(res, [[1, 2], [2, 4], [3, 6]]), "map(null, p, q) works" );168 res = zip([1, 2, 3], [2, 4, 6]);169 t.ok( objEqual(res, [[1, 2], [2, 4], [3, 6]]), "zip(p, q) works" );170 res = map(null, [1, 2, 3]);171 t.ok( objEqual(res, [1, 2, 3]), "map(null, lst) works" );172 173 174 t.is( isNotEmpty("foo"), true, "3 char string is not empty" );175 t.is( isNotEmpty(""), false, "0 char string is empty" );176 t.is( isNotEmpty([1, 2, 3]), true, "3 element list is not empty" );177 t.is( isNotEmpty([]), false, "0 element list is empty" );178 // test filter179 var greaterThanThis = function (x) { return x > this; };180 var greaterThanOne = function (x) { return x > 1; };181 var res = filter(greaterThanOne, [-1, 0, 1, 2, 3]);182 t.ok( objEqual(res, [2, 3]), "filter works" );183 var res = filter(greaterThanThis, [-1, 0, 1, 2, 3], 1);184 t.ok( objEqual(res, [2, 3]), "filter self works" );185 var res2 = xfilter(greaterThanOne, -1, 0, 1, 2, 3);186 t.ok( objEqual(res2, res), "xfilter works" );187 188 t.is(objMax(1, 2, 9, 12, 42, -16, 16), 42, "objMax works (with numbers)");189 t.is(objMin(1, 2, 9, 12, 42, -16, 16), -16, "objMin works (with numbers)");190 191 // test adapter registry192 var R = new AdapterRegistry();193 R.register("callable", isCallable, function () { return "callable"; });194 R.register("arrayLike", isArrayLike, function () { return "arrayLike"; });195 t.is( R.match(function () {}), "callable", "registry found callable" );196 t.is( R.match([]), "arrayLike", "registry found ArrayLike" );197 try {198 R.match(null);199 t.ok( false, "non-matching didn't raise!" );200 } catch (e) {201 t.is( e, NotFound, "non-matching raised correctly" );202 }203 R.register("undefinedOrNull", isUndefinedOrNull, function () { return "undefinedOrNull" });204 R.register("undefined", isUndefined, function () { return "undefined" });205 t.is( R.match(undefined), "undefinedOrNull", "priorities are as documented" );206 t.ok( R.unregister("undefinedOrNull"), "removed adapter" );207 t.is( R.match(undefined), "undefined", "adapter was removed" );208 R.register("undefinedOrNull", isUndefinedOrNull, function () { return "undefinedOrNull" }, true);209 t.is( R.match(undefined), "undefinedOrNull", "override works" );210 211 var a1 = {"a": 1, "b": 2, "c": 2};212 var a2 = {"a": 2, "b": 1, "c": 2};213 t.is( keyComparator("a")(a1, a2), -1, "keyComparator 1 lt" );214 t.is( keyComparator("c")(a1, a2), 0, "keyComparator 1 eq" );215 t.is( keyComparator("c", "b")(a1, a2), 1, "keyComparator 2 eq gt" );216 t.is( keyComparator("c", "a")(a1, a2), -1, "keyComparator 2 eq lt" );217 t.is( reverseKeyComparator("a")(a1, a2), 1, "reverseKeyComparator" );218 t.is( compare(concat([1], [2], [3]), [1, 2, 3]), 0, "concat" );219 t.is( repr("foo"), '"foo"', "string repr" );220 t.is( repr(1), '1', "number repr" );221 t.is( listMin([1, 3, 5, 3, -1]), -1, "listMin" );222 t.is( objMin(1, 3, 5, 3, -1), -1, "objMin" );223 t.is( listMax([1, 3, 5, 3, -1]), 5, "listMax" );224 t.is( objMax(1, 3, 5, 3, -1), 5, "objMax" );225 var v = keys(a1);226 v.sort();227 t.is( compare(v, ["a", "b", "c"]), 0, "keys" );228 v = items(a1);229 v.sort();230 t.is( compare(v, [["a", 1], ["b", 2], ["c", 2]]), 0, "items" );231 var StringMap = function() {};232 a = new StringMap();233 a.foo = "bar";234 b = new StringMap();235 b.foo = "bar";236 try {237 compare(a, b);238 t.ok( false, "bad comparison registered!?" );239 } catch (e) {240 t.ok( e instanceof TypeError, "bad comparison raised TypeError" );241 }242 t.is( repr(a), "[object Object]", "default repr for StringMap" );243 var isStringMap = function () {244 for (var i = 0; i < arguments.length; i++) {245 if (!(arguments[i] instanceof StringMap)) {246 return false;247 }248 }249 return true;250 };251 registerRepr("stringMap",252 isStringMap,253 function (obj) {254 return "StringMap(" + repr(items(obj)) + ")";255 }256 );257 t.is( repr(a), 'StringMap([["foo", "bar"]])', "repr worked" );258 // not public API259 MochiKit.Base.reprRegistry.unregister("stringMap");260 261 t.is( repr(a), "[object Object]", "default repr for StringMap" );262 registerComparator("stringMap",263 isStringMap,264 function (a, b) {265 // no sorted(...) in base266 a = items(a);267 b = items(b);268 a.sort(compare);269 b.sort(compare);270 return compare(a, b);271 }272 );273 t.is( compare(a, b), 0, "registerComparator" );274 update(a, {"foo": "bar"}, {"wibble": "baz"}, undefined, null, {"grr": 1});275 t.is( a.foo, "bar", "update worked (first obj)" );276 t.is( a.wibble, "baz", "update worked (second obj)" );277 t.is( a.grr, 1, "update worked (skipped undefined and null)" );278 t.is( compare(a, b), 1, "update worked (comparison)" );279 setdefault(a, {"foo": "unf"}, {"bar": "web taco"} );280 t.is( a.foo, "bar", "setdefault worked (skipped existing)" );281 t.is( a.bar, "web taco", "setdefault worked (set non-existing)" );282 a = null;283 a = setdefault(null, {"foo": "bar"});284 t.is( a.foo, "bar", "setdefault worked (self is null)" );285 a = null;286 a = setdefault(undefined, {"foo": "bar"});287 t.is( a.foo, "bar", "setdefault worked (self is undefined)" );288 a = null;289 a = update(null, {"foo": "bar"}, {"wibble": "baz"}, undefined, null, {"grr": 1});290 t.is( a.foo, "bar", "update worked (self is null, first obj)" );291 t.is( a.wibble, "baz", "update worked (self is null, second obj)" );292 t.is( a.grr, 1, "update worked (self is null, skipped undefined and null)" );293 a = null;294 a = update(undefined, {"foo": "bar"}, {"wibble": "baz"}, undefined, null, {"grr": 1});295 t.is( a.foo, "bar", "update worked (self is undefined, first obj)" );296 t.is( a.wibble, "baz", "update worked (self is undefined, second obj)" );297 t.is( a.grr, 1, "update worked (self is undefined, skipped undefined and null)" );298 var c = items(merge({"foo": "bar"}, {"wibble": "baz"}));299 c.sort(compare);300 t.is( compare(c, [["foo", "bar"], ["wibble", "baz"]]), 0, "merge worked" );301 302 // not public API303 MochiKit.Base.comparatorRegistry.unregister("stringMap");304 305 try {306 compare(a, b);307 t.ok( false, "bad comparison registered!?" );308 } catch (e) {309 t.ok( e instanceof TypeError, "bad comparison raised TypeError" );310 }311 312 var o = {"__repr__": function () { return "__repr__"; }};313 t.is( repr(o), "__repr__", "__repr__ protocol" );314 t.is( repr(MochiKit.Base), MochiKit.Base.__repr__(), "__repr__ protocol when repr is defined" );315 var o = {"NAME": "NAME"};316 t.is( repr(o), "NAME", "NAME protocol (obj)" );317 o = function () { return "TACO" };318 o.NAME = "NAME";319 t.is( repr(o), "NAME", "NAME protocol (func)" );320 321 t.is( repr(MochiKit.Base.nameFunctions), "MochiKit.Base.nameFunctions", "test nameFunctions" );322 // Done!323 t.is( urlEncode("1+2=2").toUpperCase(), "1%2B2%3D2", "urlEncode" );324 t.is( queryString(["a", "b"], [1, "two"]), "a=1&b=two", "queryString");325 t.is( queryString({"a": 1}), "a=1", "one item alternate form queryString" );326 var o = {"a": 1, "b": 2, "c": function() {}};327 var res = queryString(o).split("&");328 res.sort();329 t.is( res.join("&"), "a=1&b=2", "two item alternate form queryString, function skip" );330 var res = parseQueryString("1+1=2&b=3%3D2");331 t.is( res["1 1"], "2", "parseQueryString pathological name" );332 t.is( res.b, "3=2", "parseQueryString second name:value pair" );333 var res = parseQueryString("foo=one&foo=two", true);334 t.is( res["foo"].join(" "), "one two", "parseQueryString useArrays" );335 var res = parseQueryString("?foo=2&bar=1");336 t.is( res["foo"], "2", "parseQueryString strip leading question mark");337 var res = parseQueryString("x=1&y=2");338 t.is( typeof(res['&']), "undefined", "extra cruft in parseQueryString output");339 t.is( serializeJSON("foo\n\r\b\f\t"), "\"foo\\n\\r\\b\\f\\t\"", "string JSON" );340 t.is( serializeJSON(null), "null", "null JSON");341 try {342 serializeJSON(undefined);343 t.ok(false, "undefined should not be serializable");344 } catch (e) {345 t.ok(e instanceof TypeError, "undefined not serializable");346 }347 t.is( serializeJSON(1), "1", "1 JSON");348 t.is( serializeJSON(1.23), "1.23", "1.23 JSON");349 t.is( serializeJSON(serializeJSON), null, "function JSON (null, not string)" );350 t.is( serializeJSON([1, "2", 3.3]), "[1, \"2\", 3.3]", "array JSON" );351 var res = evalJSON(serializeJSON({"a":1, "b":2}));352 t.is( res.a, 1, "evalJSON on an object (1)" );353 t.is( res.b, 2, "evalJSON on an object (2)" );354 var res = {"a": 1, "b": 2, "json": function () { return this; }};355 var res = evalJSON(serializeJSON(res));356 t.is( res.a, 1, "evalJSON on an object that jsons self (1)" );357 t.is( res.b, 2, "evalJSON on an object that jsons self (2)" );358 var strJSON = {"a": 1, "b": 2, "json": function () { return "json"; }};359 t.is( serializeJSON(strJSON), "\"json\"", "json serialization calling" );360 t.is( serializeJSON([strJSON]), "[\"json\"]", "json serialization calling in a structure" );361 t.is( evalJSON('/* {"result": 1} */').result, 1, "json comment stripping" );362 t.is( evalJSON('/* {"*/ /*": 1} */')['*/ /*'], 1, "json comment stripping" );363 registerJSON("isDateLike",364 isDateLike,365 function (d) {366 return "this was a date";367 }368 );369 t.is( serializeJSON(new Date()), "\"this was a date\"", "json registry" );370 MochiKit.Base.jsonRegistry.unregister("isDateLike");371 var a = {"foo": {"bar": 12, "wibble": 13}};372 var b = {"foo": {"baz": 4, "bar": 16}, "bar": 4};373 updatetree(a, b);374 var expect = [["bar", 16], ["baz", 4], ["wibble", 13]];375 var got = items(a.foo);376 got.sort(compare);377 t.is( repr(got), repr(expect), "updatetree merge" );378 t.is( a.bar, 4, "updatetree insert" );379 var aa = {"foo": {"bar": 12, "wibble": 13}};380 var bb = {"foo": {"baz": 4, "bar": 16}, "bar": 4};381 382 cc = updatetree(null, aa, bb);383 got = items(cc.foo);384 got.sort(compare);385 t.is( repr(got), repr(expect), "updatetree merge (self is null)" );386 t.is( cc.bar, 4, "updatetree insert (self is null)" );387 388 cc = updatetree(undefined, aa, bb);389 got = items(cc.foo);390 got.sort(compare);391 t.is( repr(got), repr(expect), "updatetree merge (self is undefined)" );392 t.is( cc.bar, 4, "updatetree insert (self is undefined)" );393 394 var c = counter();395 t.is( c(), 1, "counter starts at 1" );396 t.is( c(), 2, "counter increases" );397 c = counter(2);398 t.is( c(), 2, "counter starts at 2" );399 t.is( c(), 3, "counter increases" );400 t.is( findValue([1, 2, 3], 4), -1, "findValue returns -1 on not found");401 t.is( findValue([1, 2, 3], 1), 0, "findValue returns correct index");402 t.is( findValue([1, 2, 3], 1, 1), -1, "findValue honors start");403 t.is( findValue([1, 2, 3], 2, 0, 1), -1, "findValue honors end");404 t.is( findIdentical([1, 2, 3], 4), -1, "findIdentical returns -1");405 t.is( findIdentical([1, 2, 3], 1), 0, "findIdentical returns correct index");406 t.is( findIdentical([1, 2, 3], 1, 1), -1, "findIdentical honors start");407 t.is( findIdentical([1, 2, 3], 2, 0, 1), -1, "findIdentical honors end");408 t.is( isNull(undefined), false, "isNull doesn't match undefined" );409 var flat = flattenArguments(1, "2", 3, [4, [5, [6, 7], 8, [], 9]]);410 var expect = [1, "2", 3, 4, 5, 6, 7, 8, 9];411 t.is( repr(flat), repr(expect), "flattenArguments" );412 var fn = function () {413 return [this, concat(arguments)];414 }415 t.is( methodcaller("toLowerCase")("FOO"), "foo", "methodcaller with a method name" );416 t.is( repr(methodcaller(fn, 2, 3)(1)), "[1, [2, 3]]", "methodcaller with a function" );417 var f1 = function (x) { return [1, x]; };418 var f2 = function (x) { return [2, x]; };419 var f3 = function (x) { return [3, x]; };420 t.is( repr(f1(f2(f3(4)))), "[1, [2, [3, 4]]]", "test the compose test" );421 t.is( repr(compose(f1,f2,f3)(4)), "[1, [2, [3, 4]]]", "three fn composition works" );422 t.is( repr(compose(compose(f1,f2),f3)(4)), "[1, [2, [3, 4]]]", "associative left" );423 t.is( repr(compose(f1,compose(f2,f3))(4)), "[1, [2, [3, 4]]]", "associative right" );424 425 try {426 compose(f1, "foo");427 t.ok( false, "wrong compose argument not raised!" );428 } catch (e) {429 t.is( e.name, 'TypeError', "wrong compose argument raised correctly" );430 }431 432 t.is(camelize('one'), 'one', 'one word');433 t.is(camelize('one-two'), 'oneTwo', 'two words');434 t.is(camelize('one-two-three'), 'oneTwoThree', 'three words');435 t.is(camelize('1-one'), '1One', 'letter and word');436 t.is(camelize('one-'), 'one', 'trailing hyphen');437 t.is(camelize('-one'), 'One', 'starting hyphen');438 t.is(camelize('o-two'), 'oTwo', 'one character and word');439 var flat = flattenArray([1, "2", 3, [4, [5, [6, 7], 8, [], 9]]]);440 var expect = [1, "2", 3, 4, 5, 6, 7, 8, 9];441 t.is( repr(flat), repr(expect), "flattenArray" );442 443 /* mean */444 try {445 mean();446 t.ok( false, "mean no arguments didn't raise!" );447 } catch (e) {448 t.is( e.name, 'TypeError', "no arguments raised correctly" );449 } 450 t.is( mean(1), 1, 'single argument (arg list)');451 t.is( mean([1]), 1, 'single argument (array)');452 t.is( mean(1,2,3), 2, 'three arguments (arg list)');453 t.is( mean([1,2,3]), 2, 'three arguments (array)');454 t.is( average(1), 1, 'test the average alias');455 /* median */456 try {457 median();458 t.ok( false, "median no arguments didn't raise!" );459 } catch (e) {460 t.is( e.name, 'TypeError', "no arguments raised correctly" );461 }462 t.is( median(1), 1, 'single argument (arg list)');463 t.is( median([1]), 1, 'single argument (array)');464 t.is( median(3,1,2), 2, 'three arguments (arg list)');465 t.is( median([3,1,2]), 2, 'three arguments (array)');466 t.is( median(3,1,2,4), 2.5, 'four arguments (arg list)');467 t.is( median([3,1,2,4]), 2.5, 'four arguments (array)');468 /* #185 */469 t.is( serializeJSON(parseQueryString("")), "{}", "parseQueryString('')" );470 t.is( serializeJSON(parseQueryString("", true)), "{}", "parseQueryString('', true)" );471 /* #109 */472 t.is( queryString({ids: [1,2,3]}), "ids=1&ids=2&ids=3", "queryString array value" );473 t.is( queryString({ids: "123"}), "ids=123", "queryString string value" );474 /* test values */475 var o = {a: 1, b: 2, c: 4, d: -1};476 var got = values(o);477 got.sort();478 t.is( repr(got), repr([-1, 1, 2, 4]), "values()" );479 t.is( queryString([["foo", "bar"], ["baz", "wibble"]]), "foo=baz&bar=wibble" );480 o = parseQueryString("foo=1=1=1&bar=2&baz&wibble=");481 t.is( o.foo, "1=1=1", "parseQueryString multiple = first" );482 t.is( o.bar, "2", "parseQueryString multiple = second" );483 t.is( o.baz, "", "parseQueryString multiple = third" );484 t.is( o.wibble, "", "parseQueryString multiple = fourth" );485 /* queryString with null values */486 t.is( queryString(["a", "b"], [1, null]), "a=1", "queryString with null value" );487 t.is( queryString({"a": 1, "b": null}), "a=1", "queryString with null value" );488 var reprFunc = function (a, b) {489 return;490 }491 t.is( repr(reprFunc), "function (a, b) {...}", "repr of function" );...

Full Screen

Full Screen

is_before.js

Source:is_before.js Github

copy

Full Screen

1import { module, test } from '../qunit';2import moment from '../../moment';3module('is before');4test('is after without units', function (assert) {5 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);6 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), true, 'year is later');7 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), false, 'year is earlier');8 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), true, 'month is later');9 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), false, 'month is earlier');10 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), true, 'day is later');11 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), false, 'day is earlier');12 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), true, 'hour is later');13 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), false, 'hour is earlier');14 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), true, 'minute is later');15 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), false, 'minute is earlier');16 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), true, 'second is later');17 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), false, 'second is earlier');18 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'millisecond match');19 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), true, 'millisecond is later');20 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), false, 'millisecond is earlier');21 assert.equal(m.isBefore(m), false, 'moments are not before themselves');22 assert.equal(+m, +mCopy, 'isBefore second should not change moment');23});24test('is before year', function (assert) {25 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);26 assert.equal(m.isBefore(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year match');27 assert.equal(m.isBefore(moment(new Date(2012, 5, 6, 7, 8, 9, 10)), 'years'), true, 'plural should work');28 assert.equal(m.isBefore(moment(new Date(2013, 5, 6, 7, 8, 9, 10)), 'year'), true, 'year is later');29 assert.equal(m.isBefore(moment(new Date(2010, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year is earlier');30 assert.equal(m.isBefore(moment(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year'), false, 'exact start of year');31 assert.equal(m.isBefore(moment(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year'), false, 'exact end of year');32 assert.equal(m.isBefore(moment(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year'), true, 'start of next year');33 assert.equal(m.isBefore(moment(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year'), false, 'end of previous year');34 assert.equal(m.isBefore(moment(new Date(1980, 11, 31, 23, 59, 59, 999)), 'year'), false, 'end of year far before');35 assert.equal(m.isBefore(m, 'year'), false, 'same moments are not before the same year');36 assert.equal(+m, +mCopy, 'isBefore year should not change moment');37});38test('is before month', function (assert) {39 var m = moment(new Date(2011, 2, 3, 4, 5, 6, 7)), mCopy = moment(m);40 assert.equal(m.isBefore(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month'), false, 'month match');41 assert.equal(m.isBefore(moment(new Date(2012, 2, 6, 7, 8, 9, 10)), 'months'), true, 'plural should work');42 assert.equal(m.isBefore(moment(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month'), true, 'year is later');43 assert.equal(m.isBefore(moment(new Date(2010, 2, 6, 7, 8, 9, 10)), 'month'), false, 'year is earlier');44 assert.equal(m.isBefore(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month'), true, 'month is later');45 assert.equal(m.isBefore(moment(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month'), false, 'month is earlier');46 assert.equal(m.isBefore(moment(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month'), false, 'exact start of month');47 assert.equal(m.isBefore(moment(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month'), false, 'exact end of month');48 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month'), true, 'start of next month');49 assert.equal(m.isBefore(moment(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month'), false, 'end of previous month');50 assert.equal(m.isBefore(moment(new Date(2010, 12, 31, 23, 59, 59, 999)), 'month'), false, 'later month but earlier year');51 assert.equal(m.isBefore(m, 'month'), false, 'same moments are not before the same month');52 assert.equal(+m, +mCopy, 'isBefore month should not change moment');53});54test('is before day', function (assert) {55 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);56 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 7, 8, 9, 10)), 'day'), false, 'day match');57 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 7, 8, 9, 10)), 'days'), true, 'plural should work');58 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 7, 8, 9, 10)), 'day'), true, 'year is later');59 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 7, 8, 9, 10)), 'day'), false, 'year is earlier');60 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 7, 8, 9, 10)), 'day'), true, 'month is later');61 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day'), false, 'month is earlier');62 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 7, 8, 9, 10)), 'day'), true, 'day is later');63 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 7, 8, 9, 10)), 'day'), false, 'day is earlier');64 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 0, 0, 0, 0)), 'day'), false, 'exact start of day');65 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 23, 59, 59, 999)), 'day'), false, 'exact end of day');66 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 0, 0, 0, 0)), 'day'), true, 'start of next day');67 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 23, 59, 59, 999)), 'day'), false, 'end of previous day');68 assert.equal(m.isBefore(moment(new Date(2010, 3, 10, 0, 0, 0, 0)), 'day'), false, 'later day but earlier year');69 assert.equal(m.isBefore(m, 'day'), false, 'same moments are not before the same day');70 assert.equal(+m, +mCopy, 'isBefore day should not change moment');71});72test('is before hour', function (assert) {73 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);74 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'hour match');75 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 8, 9, 10)), 'hours'), true, 'plural should work');76 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 8, 9, 10)), 'hour'), true, 'year is later');77 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'year is earlier');78 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 8, 9, 10)), 'hour'), true, 'month is later');79 assert.equal(m.isBefore(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour'), false, 'month is earlier');80 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 8, 9, 10)), 'hour'), true, 'day is later');81 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 3, 8, 9, 10)), 'hour'), false, 'day is earlier');82 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 8, 9, 10)), 'hour'), true, 'hour is later');83 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'hour is earlier');84 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 0, 0, 0)), 'hour'), false, 'exact start of hour');85 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 59, 59, 999)), 'hour'), false, 'exact end of hour');86 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 0, 0, 0)), 'hour'), true, 'start of next hour');87 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 2, 59, 59, 999)), 'hour'), false, 'end of previous hour');88 assert.equal(m.isBefore(m, 'hour'), false, 'same moments are not before the same hour');89 assert.equal(+m, +mCopy, 'isBefore hour should not change moment');90});91test('is before minute', function (assert) {92 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);93 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 9, 10)), 'minute'), false, 'minute match');94 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 9, 10)), 'minutes'), true, 'plural should work');95 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 9, 10)), 'minute'), true, 'year is later');96 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 4, 9, 10)), 'minute'), false, 'year is earlier');97 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 9, 10)), 'minute'), true, 'month is later');98 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute'), false, 'month is earlier');99 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 9, 10)), 'minute'), true, 'day is later');100 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 3, 4, 9, 10)), 'minute'), false, 'day is earlier');101 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 9, 10)), 'minute'), true, 'hour is later');102 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 2, 4, 9, 10)), 'minute'), false, 'hour is earler');103 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 9, 10)), 'minute'), true, 'minute is later');104 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 9, 10)), 'minute'), false, 'minute is earlier');105 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 0, 0)), 'minute'), false, 'exact start of minute');106 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 59, 999)), 'minute'), false, 'exact end of minute');107 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 0, 0)), 'minute'), true, 'start of next minute');108 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 59, 999)), 'minute'), false, 'end of previous minute');109 assert.equal(m.isBefore(m, 'minute'), false, 'same moments are not before the same minute');110 assert.equal(+m, +mCopy, 'isBefore minute should not change moment');111});112test('is before second', function (assert) {113 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);114 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'second'), false, 'second match');115 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'seconds'), true, 'plural should work');116 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'second'), true, 'year is later');117 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'second'), false, 'year is earlier');118 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'second'), true, 'month is later');119 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second'), false, 'month is earlier');120 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'second'), true, 'day is later');121 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'second'), false, 'day is earlier');122 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'second'), true, 'hour is later');123 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'second'), false, 'hour is earlier');124 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'second'), true, 'minute is later');125 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'second'), false, 'minute is earlier');126 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'second'), true, 'second is later');127 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'second'), false, 'second is earlier');128 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 0)), 'second'), false, 'exact start of second');129 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 999)), 'second'), false, 'exact end of second');130 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 0)), 'second'), true, 'start of next second');131 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 999)), 'second'), false, 'end of previous second');132 assert.equal(m.isBefore(m, 'second'), false, 'same moments are not before the same second');133 assert.equal(+m, +mCopy, 'isBefore second should not change moment');134});135test('is before millisecond', function (assert) {136 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);137 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'millisecond match');138 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds'), false, 'plural should work');139 assert.equal(m.isBefore(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond'), true, 'year is later');140 assert.equal(m.isBefore(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'year is earlier');141 assert.equal(m.isBefore(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond'), true, 'month is later');142 assert.equal(m.isBefore(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond'), false, 'month is earlier');143 assert.equal(m.isBefore(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond'), true, 'day is later');144 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond'), false, 'day is earlier');145 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond'), true, 'hour is later');146 assert.equal(m.isBefore(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond'), false, 'hour is earlier');147 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond'), true, 'minute is later');148 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond'), false, 'minute is earlier');149 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond'), true, 'second is later');150 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond'), false, 'second is earlier');151 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond'), true, 'millisecond is later');152 assert.equal(m.isBefore(moment(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond'), false, 'millisecond is earlier');153 assert.equal(m.isBefore(m, 'millisecond'), false, 'same moments are not before the same millisecond');154 assert.equal(+m, +mCopy, 'isBefore millisecond should not change moment');...

Full Screen

Full Screen

is_after.js

Source:is_after.js Github

copy

Full Screen

1import { module, test } from '../qunit';2import moment from '../../moment';3module('is after');4test('is after without units', function (assert) {5 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);6 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), false, 'year is later');7 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), true, 'year is earlier');8 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), false, 'month is later');9 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), true, 'month is earlier');10 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), false, 'day is later');11 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), true, 'day is earlier');12 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), false, 'hour is later');13 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), true, 'hour is earlier');14 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), false, 'minute is later');15 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), true, 'minute is earlier');16 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), false, 'second is later');17 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), true, 'second is earlier');18 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), false, 'millisecond match');19 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), false, 'millisecond is later');20 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), true, 'millisecond is earlier');21 assert.equal(m.isAfter(m), false, 'moments are not after themselves');22 assert.equal(+m, +mCopy, 'isAfter second should not change moment');23});24test('is after year', function (assert) {25 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);26 assert.equal(m.isAfter(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year match');27 assert.equal(m.isAfter(moment(new Date(2010, 5, 6, 7, 8, 9, 10)), 'years'), true, 'plural should work');28 assert.equal(m.isAfter(moment(new Date(2013, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year is later');29 assert.equal(m.isAfter(moment(new Date(2010, 5, 6, 7, 8, 9, 10)), 'year'), true, 'year is earlier');30 assert.equal(m.isAfter(moment(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year'), false, 'exact start of year');31 assert.equal(m.isAfter(moment(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year'), false, 'exact end of year');32 assert.equal(m.isAfter(moment(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year'), false, 'start of next year');33 assert.equal(m.isAfter(moment(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year'), true, 'end of previous year');34 assert.equal(m.isAfter(moment(new Date(1980, 11, 31, 23, 59, 59, 999)), 'year'), true, 'end of year far before');35 assert.equal(m.isAfter(m, 'year'), false, 'same moments are not after the same year');36 assert.equal(+m, +mCopy, 'isAfter year should not change moment');37});38test('is after month', function (assert) {39 var m = moment(new Date(2011, 2, 3, 4, 5, 6, 7)), mCopy = moment(m);40 assert.equal(m.isAfter(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month'), false, 'month match');41 assert.equal(m.isAfter(moment(new Date(2010, 2, 6, 7, 8, 9, 10)), 'months'), true, 'plural should work');42 assert.equal(m.isAfter(moment(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month'), false, 'year is later');43 assert.equal(m.isAfter(moment(new Date(2010, 2, 6, 7, 8, 9, 10)), 'month'), true, 'year is earlier');44 assert.equal(m.isAfter(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month'), false, 'month is later');45 assert.equal(m.isAfter(moment(new Date(2011, 1, 6, 7, 8, 9, 10)), 'month'), true, 'month is earlier');46 assert.equal(m.isAfter(moment(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month'), false, 'exact start of month');47 assert.equal(m.isAfter(moment(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month'), false, 'exact end of month');48 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month'), false, 'start of next month');49 assert.equal(m.isAfter(moment(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month'), true, 'end of previous month');50 assert.equal(m.isAfter(moment(new Date(2010, 12, 31, 23, 59, 59, 999)), 'month'), true, 'later month but earlier year');51 assert.equal(m.isAfter(m, 'month'), false, 'same moments are not after the same month');52 assert.equal(+m, +mCopy, 'isAfter month should not change moment');53});54test('is after day', function (assert) {55 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);56 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 7, 8, 9, 10)), 'day'), false, 'day match');57 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 7, 8, 9, 10)), 'days'), true, 'plural should work');58 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 7, 8, 9, 10)), 'day'), false, 'year is later');59 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 7, 8, 9, 10)), 'day'), true, 'year is earlier');60 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 7, 8, 9, 10)), 'day'), false, 'month is later');61 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day'), true, 'month is earlier');62 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 7, 8, 9, 10)), 'day'), false, 'day is later');63 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 7, 8, 9, 10)), 'day'), true, 'day is earlier');64 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 0, 0, 0, 0)), 'day'), false, 'exact start of day');65 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 23, 59, 59, 999)), 'day'), false, 'exact end of day');66 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 0, 0, 0, 0)), 'day'), false, 'start of next day');67 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 23, 59, 59, 999)), 'day'), true, 'end of previous day');68 assert.equal(m.isAfter(moment(new Date(2010, 3, 10, 0, 0, 0, 0)), 'day'), true, 'later day but earlier year');69 assert.equal(m.isAfter(m, 'day'), false, 'same moments are not after the same day');70 assert.equal(+m, +mCopy, 'isAfter day should not change moment');71});72test('is after hour', function (assert) {73 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);74 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'hour match');75 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 8, 9, 10)), 'hours'), true, 'plural should work');76 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'year is later');77 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 8, 9, 10)), 'hour'), true, 'year is earlier');78 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 8, 9, 10)), 'hour'), false, 'month is later');79 assert.equal(m.isAfter(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour'), true, 'month is earlier');80 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 8, 9, 10)), 'hour'), false, 'day is later');81 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 3, 8, 9, 10)), 'hour'), true, 'day is earlier');82 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 8, 9, 10)), 'hour'), false, 'hour is later');83 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 8, 9, 10)), 'hour'), false, 'hour is earlier');84 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 0, 0, 0)), 'hour'), false, 'exact start of hour');85 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 59, 59, 999)), 'hour'), false, 'exact end of hour');86 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 0, 0, 0)), 'hour'), false, 'start of next hour');87 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 2, 59, 59, 999)), 'hour'), true, 'end of previous hour');88 assert.equal(m.isAfter(m, 'hour'), false, 'same moments are not after the same hour');89 assert.equal(+m, +mCopy, 'isAfter hour should not change moment');90});91test('is after minute', function (assert) {92 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 6)), mCopy = moment(m);93 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 9, 10)), 'minute'), false, 'minute match');94 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 9, 10)), 'minutes'), true, 'plural should work');95 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 4, 9, 10)), 'minute'), false, 'year is later');96 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 9, 10)), 'minute'), true, 'year is earlier');97 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 9, 10)), 'minute'), false, 'month is later');98 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute'), true, 'month is earlier');99 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 9, 10)), 'minute'), false, 'day is later');100 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 3, 4, 9, 10)), 'minute'), true, 'day is earlier');101 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 9, 10)), 'minute'), false, 'hour is later');102 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 2, 4, 9, 10)), 'minute'), true, 'hour is earler');103 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 9, 10)), 'minute'), false, 'minute is later');104 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 9, 10)), 'minute'), true, 'minute is earlier');105 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 0, 0)), 'minute'), false, 'exact start of minute');106 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 59, 999)), 'minute'), false, 'exact end of minute');107 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 0, 0)), 'minute'), false, 'start of next minute');108 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 59, 999)), 'minute'), true, 'end of previous minute');109 assert.equal(m.isAfter(m, 'minute'), false, 'same moments are not after the same minute');110 assert.equal(+m, +mCopy, 'isAfter minute should not change moment');111});112test('is after second', function (assert) {113 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);114 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'second'), false, 'second match');115 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'seconds'), true, 'plural should work');116 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'second'), false, 'year is later');117 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'second'), true, 'year is earlier');118 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'second'), false, 'month is later');119 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second'), true, 'month is earlier');120 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'second'), false, 'day is later');121 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'second'), true, 'day is earlier');122 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'second'), false, 'hour is later');123 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'second'), true, 'hour is earlier');124 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'second'), false, 'minute is later');125 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'second'), true, 'minute is earlier');126 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'second'), false, 'second is later');127 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'second'), true, 'second is earlier');128 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 0)), 'second'), false, 'exact start of second');129 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 999)), 'second'), false, 'exact end of second');130 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 0)), 'second'), false, 'start of next second');131 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 999)), 'second'), true, 'end of previous second');132 assert.equal(m.isAfter(m, 'second'), false, 'same moments are not after the same second');133 assert.equal(+m, +mCopy, 'isAfter second should not change moment');134});135test('is after millisecond', function (assert) {136 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);137 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'millisecond match');138 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'milliseconds'), true, 'plural should work');139 assert.equal(m.isAfter(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'year is later');140 assert.equal(m.isAfter(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond'), true, 'year is earlier');141 assert.equal(m.isAfter(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond'), false, 'month is later');142 assert.equal(m.isAfter(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond'), true, 'month is earlier');143 assert.equal(m.isAfter(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond'), false, 'day is later');144 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond'), true, 'day is earlier');145 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond'), false, 'hour is later');146 assert.equal(m.isAfter(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond'), true, 'hour is earlier');147 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond'), false, 'minute is later');148 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond'), true, 'minute is earlier');149 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond'), false, 'second is later');150 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond'), true, 'second is earlier');151 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond'), false, 'millisecond is later');152 assert.equal(m.isAfter(moment(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond'), true, 'millisecond is earlier');153 assert.equal(m.isAfter(m, 'millisecond'), false, 'same moments are not after the same millisecond');154 assert.equal(+m, +mCopy, 'isAfter millisecond should not change moment');...

Full Screen

Full Screen

is_same.js

Source:is_same.js Github

copy

Full Screen

1import { module, test } from '../qunit';2import moment from '../../moment';3module('is same');4test('is same without units', function (assert) {5 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);6 assert.equal(m.isSame(moment(new Date(2012, 3, 2, 3, 5, 5, 10))), false, 'year is later');7 assert.equal(m.isSame(moment(new Date(2010, 3, 2, 3, 3, 5, 10))), false, 'year is earlier');8 assert.equal(m.isSame(moment(new Date(2011, 4, 2, 3, 4, 5, 10))), false, 'month is later');9 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 5, 10))), false, 'month is earlier');10 assert.equal(m.isSame(moment(new Date(2011, 3, 3, 3, 4, 5, 10))), false, 'day is later');11 assert.equal(m.isSame(moment(new Date(2011, 3, 1, 3, 4, 5, 10))), false, 'day is earlier');12 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 4, 4, 5, 10))), false, 'hour is later');13 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 2, 4, 5, 10))), false, 'hour is earlier');14 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 5, 5, 10))), false, 'minute is later');15 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 3, 5, 10))), false, 'minute is earlier');16 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 6, 10))), false, 'second is later');17 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 4, 11))), false, 'second is earlier');18 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 10))), true, 'millisecond match');19 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 11))), false, 'millisecond is later');20 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 9))), false, 'millisecond is earlier');21 assert.equal(m.isSame(m), true, 'moments are the same as themselves');22 assert.equal(+m, +mCopy, 'isSame second should not change moment');23});24test('is same year', function (assert) {25 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);26 assert.equal(m.isSame(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'year'), true, 'year match');27 assert.equal(m.isSame(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'years'), true, 'plural should work');28 assert.equal(m.isSame(moment(new Date(2012, 5, 6, 7, 8, 9, 10)), 'year'), false, 'year mismatch');29 assert.equal(m.isSame(moment(new Date(2011, 0, 1, 0, 0, 0, 0)), 'year'), true, 'exact start of year');30 assert.equal(m.isSame(moment(new Date(2011, 11, 31, 23, 59, 59, 999)), 'year'), true, 'exact end of year');31 assert.equal(m.isSame(moment(new Date(2012, 0, 1, 0, 0, 0, 0)), 'year'), false, 'start of next year');32 assert.equal(m.isSame(moment(new Date(2010, 11, 31, 23, 59, 59, 999)), 'year'), false, 'end of previous year');33 assert.equal(m.isSame(m, 'year'), true, 'same moments are in the same year');34 assert.equal(+m, +mCopy, 'isSame year should not change moment');35});36test('is same month', function (assert) {37 var m = moment(new Date(2011, 2, 3, 4, 5, 6, 7)), mCopy = moment(m);38 assert.equal(m.isSame(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'month'), true, 'month match');39 assert.equal(m.isSame(moment(new Date(2011, 2, 6, 7, 8, 9, 10)), 'months'), true, 'plural should work');40 assert.equal(m.isSame(moment(new Date(2012, 2, 6, 7, 8, 9, 10)), 'month'), false, 'year mismatch');41 assert.equal(m.isSame(moment(new Date(2011, 5, 6, 7, 8, 9, 10)), 'month'), false, 'month mismatch');42 assert.equal(m.isSame(moment(new Date(2011, 2, 1, 0, 0, 0, 0)), 'month'), true, 'exact start of month');43 assert.equal(m.isSame(moment(new Date(2011, 2, 31, 23, 59, 59, 999)), 'month'), true, 'exact end of month');44 assert.equal(m.isSame(moment(new Date(2011, 3, 1, 0, 0, 0, 0)), 'month'), false, 'start of next month');45 assert.equal(m.isSame(moment(new Date(2011, 1, 27, 23, 59, 59, 999)), 'month'), false, 'end of previous month');46 assert.equal(m.isSame(m, 'month'), true, 'same moments are in the same month');47 assert.equal(+m, +mCopy, 'isSame month should not change moment');48});49test('is same day', function (assert) {50 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);51 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'day'), true, 'day match');52 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 7, 8, 9, 10)), 'days'), true, 'plural should work');53 assert.equal(m.isSame(moment(new Date(2012, 1, 2, 7, 8, 9, 10)), 'day'), false, 'year mismatch');54 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 7, 8, 9, 10)), 'day'), false, 'month mismatch');55 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 7, 8, 9, 10)), 'day'), false, 'day mismatch');56 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 0, 0, 0, 0)), 'day'), true, 'exact start of day');57 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 23, 59, 59, 999)), 'day'), true, 'exact end of day');58 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 0, 0, 0, 0)), 'day'), false, 'start of next day');59 assert.equal(m.isSame(moment(new Date(2011, 1, 1, 23, 59, 59, 999)), 'day'), false, 'end of previous day');60 assert.equal(m.isSame(m, 'day'), true, 'same moments are in the same day');61 assert.equal(+m, +mCopy, 'isSame day should not change moment');62});63test('is same hour', function (assert) {64 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);65 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hour'), true, 'hour match');66 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 8, 9, 10)), 'hours'), true, 'plural should work');67 assert.equal(m.isSame(moment(new Date(2012, 1, 2, 3, 8, 9, 10)), 'hour'), false, 'year mismatch');68 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 8, 9, 10)), 'hour'), false, 'month mismatch');69 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 3, 8, 9, 10)), 'hour'), false, 'day mismatch');70 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 8, 9, 10)), 'hour'), false, 'hour mismatch');71 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 0, 0, 0)), 'hour'), true, 'exact start of hour');72 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 59, 59, 999)), 'hour'), true, 'exact end of hour');73 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 0, 0, 0)), 'hour'), false, 'start of next hour');74 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 2, 59, 59, 999)), 'hour'), false, 'end of previous hour');75 assert.equal(m.isSame(m, 'hour'), true, 'same moments are in the same hour');76 assert.equal(+m, +mCopy, 'isSame hour should not change moment');77});78test('is same minute', function (assert) {79 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);80 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minute'), true, 'minute match');81 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 9, 10)), 'minutes'), true, 'plural should work');82 assert.equal(m.isSame(moment(new Date(2012, 1, 2, 3, 4, 9, 10)), 'minute'), false, 'year mismatch');83 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 9, 10)), 'minute'), false, 'month mismatch');84 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 3, 4, 9, 10)), 'minute'), false, 'day mismatch');85 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 4, 9, 10)), 'minute'), false, 'hour mismatch');86 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 5, 9, 10)), 'minute'), false, 'minute mismatch');87 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 0, 0)), 'minute'), true, 'exact start of minute');88 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 59, 999)), 'minute'), true, 'exact end of minute');89 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 5, 0, 0)), 'minute'), false, 'start of next minute');90 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 3, 59, 999)), 'minute'), false, 'end of previous minute');91 assert.equal(m.isSame(m, 'minute'), true, 'same moments are in the same minute');92 assert.equal(+m, +mCopy, 'isSame minute should not change moment');93});94test('is same second', function (assert) {95 var m = moment(new Date(2011, 1, 2, 3, 4, 5, 6)), mCopy = moment(m);96 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 10)), 'second'), true, 'second match');97 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 10)), 'seconds'), true, 'plural should work');98 assert.equal(m.isSame(moment(new Date(2012, 1, 2, 3, 4, 5, 10)), 'second'), false, 'year mismatch');99 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'second'), false, 'month mismatch');100 assert.equal(m.isSame(moment(new Date(2011, 1, 3, 3, 4, 5, 10)), 'second'), false, 'day mismatch');101 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 4, 4, 5, 10)), 'second'), false, 'hour mismatch');102 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 5, 5, 10)), 'second'), false, 'minute mismatch');103 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 6, 10)), 'second'), false, 'second mismatch');104 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 0)), 'second'), true, 'exact start of second');105 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 5, 999)), 'second'), true, 'exact end of second');106 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 6, 0)), 'second'), false, 'start of next second');107 assert.equal(m.isSame(moment(new Date(2011, 1, 2, 3, 4, 4, 999)), 'second'), false, 'end of previous second');108 assert.equal(m.isSame(m, 'second'), true, 'same moments are in the same second');109 assert.equal(+m, +mCopy, 'isSame second should not change moment');110});111test('is same millisecond', function (assert) {112 var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m);113 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'millisecond'), true, 'millisecond match');114 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 5, 10)), 'milliseconds'), true, 'plural should work');115 assert.equal(m.isSame(moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'year is later');116 assert.equal(m.isSame(moment(new Date(2010, 3, 2, 3, 4, 5, 10)), 'millisecond'), false, 'year is earlier');117 assert.equal(m.isSame(moment(new Date(2011, 4, 2, 3, 4, 5, 10)), 'millisecond'), false, 'month is later');118 assert.equal(m.isSame(moment(new Date(2011, 2, 2, 3, 4, 5, 10)), 'millisecond'), false, 'month is earlier');119 assert.equal(m.isSame(moment(new Date(2011, 3, 3, 3, 4, 5, 10)), 'millisecond'), false, 'day is later');120 assert.equal(m.isSame(moment(new Date(2011, 3, 1, 1, 4, 5, 10)), 'millisecond'), false, 'day is earlier');121 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 4, 4, 5, 10)), 'millisecond'), false, 'hour is later');122 assert.equal(m.isSame(moment(new Date(2011, 3, 1, 4, 1, 5, 10)), 'millisecond'), false, 'hour is earlier');123 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 5, 5, 10)), 'millisecond'), false, 'minute is later');124 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 3, 5, 10)), 'millisecond'), false, 'minute is earlier');125 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 6, 10)), 'millisecond'), false, 'second is later');126 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 4, 5)), 'millisecond'), false, 'second is earlier');127 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 6, 11)), 'millisecond'), false, 'millisecond is later');128 assert.equal(m.isSame(moment(new Date(2011, 3, 2, 3, 4, 4, 9)), 'millisecond'), false, 'millisecond is earlier');129 assert.equal(m.isSame(m, 'millisecond'), true, 'same moments are in the same millisecond');130 assert.equal(+m, +mCopy, 'isSame millisecond should not change moment');131});132test('is same with utc offset moments', function (assert) {133 assert.ok(moment.parseZone('2013-02-01T-05:00').isSame(moment('2013-02-01'), 'year'), 'zoned vs local moment');134 assert.ok(moment('2013-02-01').isSame(moment('2013-02-01').utcOffset('-05:00'), 'year'), 'local vs zoned moment');135 assert.ok(moment.parseZone('2013-02-01T-05:00').isSame(moment.parseZone('2013-02-01T-06:30'), 'year'),136 'zoned vs (differently) zoned moment');...

Full Screen

Full Screen

browser_details.js

Source:browser_details.js Github

copy

Full Screen

1//<!--2// Ultimate client-side JavaScript client sniff. Version 3.033// (C) Netscape Communications 1999-2001. Permission granted to reuse and distribute.4// Revised 17 May 99 to add is_nav5up and is_ie5up (see below).5// Revised 20 Dec 00 to add is_gecko and change is_nav5up to is_nav6up6// also added support for IE5.5 Opera4&5 HotJava3 AOLTV7// Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4, 8// correct Opera 5 detection9// add support for winME and win2k10// synch with browser-type-oo.js11// Revised 26 Mar 01 to correct Opera detection12// Revised 02 Oct 01 to add IE6 detection13// Everything you always wanted to know about your JavaScript client14// but were afraid to ask. Creates "is_" variables indicating:15// (1) browser vendor:16// is_nav, is_ie, is_opera, is_hotjava, is_webtv, is_TVNavigator, is_AOLTV17// (2) browser version number:18// is_major (integer indicating major version number: 2, 3, 4 ...)19// is_minor (float indicating full version number: 2.02, 3.01, 4.04 ...)20// (3) browser vendor AND major version number21// is_nav2, is_nav3, is_nav4, is_nav4up, is_nav6, is_nav6up, is_gecko, is_ie3,22// is_ie4, is_ie4up, is_ie5, is_ie5up, is_ie5_5, is_ie5_5up, is_ie6, is_ie6up, is_hotjava3, is_hotjava3up,23// is_opera2, is_opera3, is_opera4, is_opera5, is_opera5up24// (4) JavaScript version number:25// is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)26// (5) OS platform and version:27// is_win, is_win16, is_win32, is_win31, is_win95, is_winnt, is_win98, is_winme, is_win2k28// is_os229// is_mac, is_mac68k, is_macppc30// is_unix31// is_sun, is_sun4, is_sun5, is_suni8632// is_irix, is_irix5, is_irix633// is_hpux, is_hpux9, is_hpux1034// is_aix, is_aix1, is_aix2, is_aix3, is_aix435// is_linux, is_sco, is_unixware, is_mpras, is_reliant36// is_dec, is_sinix, is_freebsd, is_bsd37// is_vms38//39// See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and40// http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html41// for detailed lists of userAgent strings.42//43// Note: you don't want your Nav4 or IE4 code to "turn off" or44// stop working when new versions of browsers are released, so45// in conditional code forks, use is_ie5up ("IE 5.0 or greater") 46// is_opera5up ("Opera 5.0 or greater") instead of is_ie5 or is_opera547// to check version in code which you want to work on future48// versions.49 // convert all characters to lowercase to simplify testing50 var agt=navigator.userAgent.toLowerCase();51 // *** BROWSER VERSION ***52 // Note: On IE5, these return 4, so use is_ie5up to detect IE5.53 var is_major = parseInt(navigator.appVersion);54 var is_minor = parseFloat(navigator.appVersion);55 // Note: Opera and WebTV spoof Navigator. We do strict client detection.56 // If you want to allow spoofing, take out the tests for opera and webtv.57 var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)58 && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)59 && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));60 var is_nav2 = (is_nav && (is_major == 2));61 var is_nav3 = (is_nav && (is_major == 3));62 var is_nav4 = (is_nav && (is_major == 4));63 var is_nav4up = (is_nav && (is_major >= 4));64 var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) ||65 (agt.indexOf("; nav") != -1)) );66 var is_nav6 = (is_nav && (is_major == 5));67 var is_nav6up = (is_nav && (is_major >= 5));68 var is_gecko = (agt.indexOf('gecko') != -1);69 var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));70 var is_ie3 = (is_ie && (is_major < 4));71 var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );72 var is_ie4up = (is_ie && (is_major >= 4));73 var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );74 var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));75 var is_ie5up = (is_ie && !is_ie3 && !is_ie4);76 var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);77 var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );78 var is_ie6up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);79 // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser80 // or if this is the first browser window opened. Thus the81 // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.82 var is_aol = (agt.indexOf("aol") != -1);83 var is_aol3 = (is_aol && is_ie3);84 var is_aol4 = (is_aol && is_ie4);85 var is_aol5 = (agt.indexOf("aol 5") != -1);86 var is_aol6 = (agt.indexOf("aol 6") != -1);87 var is_opera = (agt.indexOf("opera") != -1);88 var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);89 var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);90 var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);91 var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);92 var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);93 var is_webtv = (agt.indexOf("webtv") != -1); 94 var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 95 var is_AOLTV = is_TVNavigator;96 var is_hotjava = (agt.indexOf("hotjava") != -1);97 var is_hotjava3 = (is_hotjava && (is_major == 3));98 var is_hotjava3up = (is_hotjava && (is_major >= 3));99 // *** JAVASCRIPT VERSION CHECK ***100 var is_js;101 if (is_nav2 || is_ie3) is_js = 1.0;102 else if (is_nav3) is_js = 1.1;103 else if (is_opera5up) is_js = 1.3;104 else if (is_opera) is_js = 1.1;105 else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2;106 else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3;107 else if (is_hotjava3up) is_js = 1.4;108 else if (is_nav6 || is_gecko) is_js = 1.5;109 // NOTE: In the future, update this code when newer versions of JS110 // are released. For now, we try to provide some upward compatibility111 // so that future versions of Nav and IE will show they are at112 // *least* JS 1.x capable. Always check for JS version compatibility113 // with > or >=.114 else if (is_nav6up) is_js = 1.5;115 // NOTE: ie5up on mac is 1.4116 else if (is_ie5up) is_js = 1.3117 // HACK: no idea for other browsers; always check for JS version with > or >=118 else is_js = 0.0;119 // *** PLATFORM ***120 var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );121 // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all122 // Win32, so you can't distinguish between Win95 and WinNT.123 var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));124 // is this a 16 bit compiled version?125 var is_win16 = ((agt.indexOf("win16")!=-1) || 126 (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 127 (agt.indexOf("windows 16-bit")!=-1) ); 128 var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||129 (agt.indexOf("windows 16-bit")!=-1));130 var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));131 var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));132 // NOTE: Reliable detection of Win98 may not be possible. It appears that:133 // - On Nav 4.x and before you'll get plain "Windows" in userAgent.134 // - On Mercury client, the 32-bit version will return "Win98", but135 // the 16-bit version running on Win98 will still return "Win95".136 var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));137 var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));138 var is_win32 = (is_win95 || is_winnt || is_win98 || 139 ((is_major >= 4) && (navigator.platform == "Win32")) ||140 (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));141 var is_os2 = ((agt.indexOf("os/2")!=-1) || 142 (navigator.appVersion.indexOf("OS/2")!=-1) || 143 (agt.indexOf("ibm-webexplorer")!=-1));144 var is_mac = (agt.indexOf("mac")!=-1);145 // hack ie5 js version for mac146 if (is_mac && is_ie5up) is_js = 1.4;147 var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) || 148 (agt.indexOf("68000")!=-1)));149 var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) || 150 (agt.indexOf("powerpc")!=-1)));151 var is_sun = (agt.indexOf("sunos")!=-1);152 var is_sun4 = (agt.indexOf("sunos 4")!=-1);153 var is_sun5 = (agt.indexOf("sunos 5")!=-1);154 var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));155 var is_irix = (agt.indexOf("irix") !=-1); // SGI156 var is_irix5 = (agt.indexOf("irix 5") !=-1);157 var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));158 var is_hpux = (agt.indexOf("hp-ux")!=-1);159 var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));160 var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));161 var is_aix = (agt.indexOf("aix") !=-1); // IBM162 var is_aix1 = (agt.indexOf("aix 1") !=-1); 163 var is_aix2 = (agt.indexOf("aix 2") !=-1); 164 var is_aix3 = (agt.indexOf("aix 3") !=-1); 165 var is_aix4 = (agt.indexOf("aix 4") !=-1); 166 var is_linux = (agt.indexOf("inux")!=-1);167 var is_sco = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);168 var is_unixware = (agt.indexOf("unix_system_v")!=-1); 169 var is_mpras = (agt.indexOf("ncr")!=-1); 170 var is_reliant = (agt.indexOf("reliantunix")!=-1);171 var is_dec = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || 172 (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || 173 (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 174 var is_sinix = (agt.indexOf("sinix")!=-1);175 var is_freebsd = (agt.indexOf("freebsd")!=-1);176 var is_bsd = (agt.indexOf("bsd")!=-1);177 var is_unix = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux || 178 is_sco ||is_unixware || is_mpras || is_reliant || 179 is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);180 var is_vms = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));...

Full Screen

Full Screen

ReactIs-test.js

Source:ReactIs-test.js Github

copy

Full Screen

1/**2 * Copyright (c) Facebook, Inc. and its affiliates.3 *4 * This source code is licensed under the MIT license found in the5 * LICENSE file in the root directory of this source tree.6 *7 * @emails react-core8 */9'use strict';10let React;11let ReactDOM;12let ReactIs;13describe('ReactIs', () => {14 beforeEach(() => {15 jest.resetModules();16 React = require('react');17 ReactDOM = require('react-dom');18 ReactIs = require('react-is');19 });20 it('should return undefined for unknown/invalid types', () => {21 expect(ReactIs.typeOf('abc')).toBe(undefined);22 expect(ReactIs.typeOf(true)).toBe(undefined);23 expect(ReactIs.typeOf(123)).toBe(undefined);24 expect(ReactIs.typeOf({})).toBe(undefined);25 expect(ReactIs.typeOf(null)).toBe(undefined);26 expect(ReactIs.typeOf(undefined)).toBe(undefined);27 });28 it('identifies valid element types', () => {29 class Component extends React.Component {30 render() {31 return React.createElement('div');32 }33 }34 const FunctionComponent = () => React.createElement('div');35 const ForwardRefComponent = React.forwardRef((props, ref) =>36 React.createElement(Component, {forwardedRef: ref, ...props}),37 );38 const Context = React.createContext(false);39 expect(ReactIs.isValidElementType('div')).toEqual(true);40 expect(ReactIs.isValidElementType(Component)).toEqual(true);41 expect(ReactIs.isValidElementType(FunctionComponent)).toEqual(true);42 expect(ReactIs.isValidElementType(ForwardRefComponent)).toEqual(true);43 expect(ReactIs.isValidElementType(Context.Provider)).toEqual(true);44 expect(ReactIs.isValidElementType(Context.Consumer)).toEqual(true);45 expect(ReactIs.isValidElementType(React.createFactory('div'))).toEqual(46 true,47 );48 expect(ReactIs.isValidElementType(React.Fragment)).toEqual(true);49 expect(ReactIs.isValidElementType(React.unstable_ConcurrentMode)).toEqual(50 true,51 );52 expect(ReactIs.isValidElementType(React.StrictMode)).toEqual(true);53 expect(ReactIs.isValidElementType(true)).toEqual(false);54 expect(ReactIs.isValidElementType(123)).toEqual(false);55 expect(ReactIs.isValidElementType({})).toEqual(false);56 expect(ReactIs.isValidElementType(null)).toEqual(false);57 expect(ReactIs.isValidElementType(undefined)).toEqual(false);58 expect(ReactIs.isValidElementType({type: 'div', props: {}})).toEqual(false);59 });60 it('should identify concurrent mode', () => {61 expect(ReactIs.typeOf(<React.unstable_ConcurrentMode />)).toBe(62 ReactIs.ConcurrentMode,63 );64 expect(ReactIs.isConcurrentMode(<React.unstable_ConcurrentMode />)).toBe(65 true,66 );67 expect(ReactIs.isConcurrentMode({type: ReactIs.ConcurrentMode})).toBe(68 false,69 );70 expect(ReactIs.isConcurrentMode(<React.StrictMode />)).toBe(false);71 expect(ReactIs.isConcurrentMode(<div />)).toBe(false);72 });73 it('should identify context consumers', () => {74 const Context = React.createContext(false);75 expect(ReactIs.typeOf(<Context.Consumer />)).toBe(ReactIs.ContextConsumer);76 expect(ReactIs.isContextConsumer(<Context.Consumer />)).toBe(true);77 expect(ReactIs.isContextConsumer(<Context.Provider />)).toBe(false);78 expect(ReactIs.isContextConsumer(<div />)).toBe(false);79 });80 it('should identify context providers', () => {81 const Context = React.createContext(false);82 expect(ReactIs.typeOf(<Context.Provider />)).toBe(ReactIs.ContextProvider);83 expect(ReactIs.isContextProvider(<Context.Provider />)).toBe(true);84 expect(ReactIs.isContextProvider(<Context.Consumer />)).toBe(false);85 expect(ReactIs.isContextProvider(<div />)).toBe(false);86 });87 it('should identify elements', () => {88 expect(ReactIs.typeOf(<div />)).toBe(ReactIs.Element);89 expect(ReactIs.isElement(<div />)).toBe(true);90 expect(ReactIs.isElement('div')).toBe(false);91 expect(ReactIs.isElement(true)).toBe(false);92 expect(ReactIs.isElement(123)).toBe(false);93 expect(ReactIs.isElement(null)).toBe(false);94 expect(ReactIs.isElement(undefined)).toBe(false);95 expect(ReactIs.isElement({})).toBe(false);96 // It should also identify more specific types as elements97 const Context = React.createContext(false);98 expect(ReactIs.isElement(<Context.Provider />)).toBe(true);99 expect(ReactIs.isElement(<Context.Consumer />)).toBe(true);100 expect(ReactIs.isElement(<React.Fragment />)).toBe(true);101 expect(ReactIs.isElement(<React.unstable_ConcurrentMode />)).toBe(true);102 expect(ReactIs.isElement(<React.StrictMode />)).toBe(true);103 });104 it('should identify ref forwarding component', () => {105 const RefForwardingComponent = React.forwardRef((props, ref) => null);106 expect(ReactIs.typeOf(<RefForwardingComponent />)).toBe(ReactIs.ForwardRef);107 expect(ReactIs.isForwardRef(<RefForwardingComponent />)).toBe(true);108 expect(ReactIs.isForwardRef({type: ReactIs.StrictMode})).toBe(false);109 expect(ReactIs.isForwardRef(<React.unstable_ConcurrentMode />)).toBe(false);110 expect(ReactIs.isForwardRef(<div />)).toBe(false);111 });112 it('should identify fragments', () => {113 expect(ReactIs.typeOf(<React.Fragment />)).toBe(ReactIs.Fragment);114 expect(ReactIs.isFragment(<React.Fragment />)).toBe(true);115 expect(ReactIs.isFragment({type: ReactIs.Fragment})).toBe(false);116 expect(ReactIs.isFragment('React.Fragment')).toBe(false);117 expect(ReactIs.isFragment(<div />)).toBe(false);118 expect(ReactIs.isFragment([])).toBe(false);119 });120 it('should identify portals', () => {121 const div = document.createElement('div');122 const portal = ReactDOM.createPortal(<div />, div);123 expect(ReactIs.typeOf(portal)).toBe(ReactIs.Portal);124 expect(ReactIs.isPortal(portal)).toBe(true);125 expect(ReactIs.isPortal(div)).toBe(false);126 });127 it('should identify memo', () => {128 const Component = () => React.createElement('div');129 const memoized = React.memo(Component);130 expect(ReactIs.typeOf(memoized)).toBe(ReactIs.Memo);131 expect(ReactIs.isMemo(memoized)).toBe(true);132 expect(ReactIs.isMemo(Component)).toBe(false);133 });134 it('should identify strict mode', () => {135 expect(ReactIs.typeOf(<React.StrictMode />)).toBe(ReactIs.StrictMode);136 expect(ReactIs.isStrictMode(<React.StrictMode />)).toBe(true);137 expect(ReactIs.isStrictMode({type: ReactIs.StrictMode})).toBe(false);138 expect(ReactIs.isStrictMode(<React.unstable_ConcurrentMode />)).toBe(false);139 expect(ReactIs.isStrictMode(<div />)).toBe(false);140 });141 it('should identify profile root', () => {142 expect(143 ReactIs.typeOf(<React.unstable_Profiler id="foo" onRender={jest.fn()} />),144 ).toBe(ReactIs.Profiler);145 expect(146 ReactIs.isProfiler(147 <React.unstable_Profiler id="foo" onRender={jest.fn()} />,148 ),149 ).toBe(true);150 expect(ReactIs.isProfiler({type: ReactIs.unstable_Profiler})).toBe(false);151 expect(ReactIs.isProfiler(<React.unstable_ConcurrentMode />)).toBe(false);152 expect(ReactIs.isProfiler(<div />)).toBe(false);153 });...

Full Screen

Full Screen

detect.js

Source:detect.js Github

copy

Full Screen

1/* from Nicholas C. Zakas 2005 */2/* ch 10 browser detection */3/* downloaded from wrox.com by bdc34 */4var sUserAgent = navigator.userAgent;5var fAppVersion = parseFloat(navigator.appVersion);6function compareVersions(sVersion1, sVersion2) {7 var aVersion1 = sVersion1.split(".");8 var aVersion2 = sVersion2.split(".");9 10 if (aVersion1.length > aVersion2.length) {11 for (var i=0; i < aVersion1.length - aVersion2.length; i++) {12 aVersion2.push("0");13 }14 } else if (aVersion1.length < aVersion2.length) {15 for (var i=0; i < aVersion2.length - aVersion1.length; i++) {16 aVersion1.push("0");17 } 18 }19 20 for (var i=0; i < aVersion1.length; i++) {21 22 if (aVersion1[i] < aVersion2[i]) {23 return -1;24 } else if (aVersion1[i] > aVersion2[i]) {25 return 1;26 } 27 }28 29 return 0;30}31var isOpera = sUserAgent.indexOf("Opera") > -1;32var isMinOpera4 = isMinOpera5 = isMinOpera6 = isMinOpera7 = isMinOpera7_5 = false;33if (isOpera) {34 var fOperaVersion;35 if(navigator.appName == "Opera") {36 fOperaVersion = fAppVersion;37 } else {38 var reOperaVersion = new RegExp("Opera (\\d+\\.\\d+)");39 reOperaVersion.test(sUserAgent);40 fOperaVersion = parseFloat(RegExp["$1"]);41 }42 isMinOpera4 = fOperaVersion >= 4;43 isMinOpera5 = fOperaVersion >= 5;44 isMinOpera6 = fOperaVersion >= 6;45 isMinOpera7 = fOperaVersion >= 7;46 isMinOpera7_5 = fOperaVersion >= 7.5;47}48var isKHTML = sUserAgent.indexOf("KHTML") > -1 49 || sUserAgent.indexOf("Konqueror") > -1 50 || sUserAgent.indexOf("AppleWebKit") > -1; 51 52var isMinSafari1 = isMinSafari1_2 = false;53var isMinKonq2_2 = isMinKonq3 = isMinKonq3_1 = isMinKonq3_2 = false;54if (isKHTML) {55 isSafari = sUserAgent.indexOf("AppleWebKit") > -1;56 isKonq = sUserAgent.indexOf("Konqueror") > -1;57 if (isSafari) {58 var reAppleWebKit = new RegExp("AppleWebKit\\/(\\d+(?:\\.\\d*)?)");59 reAppleWebKit.test(sUserAgent);60 var fAppleWebKitVersion = parseFloat(RegExp["$1"]);61 isMinSafari1 = fAppleWebKitVersion >= 85;62 isMinSafari1_2 = fAppleWebKitVersion >= 124;63 } else if (isKonq) {64 var reKonq = new RegExp("Konqueror\\/(\\d+(?:\\.\\d+(?:\\.\\d)?)?)");65 reKonq.test(sUserAgent);66 isMinKonq2_2 = compareVersions(RegExp["$1"], "2.2") >= 0;67 isMinKonq3 = compareVersions(RegExp["$1"], "3.0") >= 0;68 isMinKonq3_1 = compareVersions(RegExp["$1"], "3.1") >= 0;69 isMinKonq3_2 = compareVersions(RegExp["$1"], "3.2") >= 0;70 } 71 72}73var isIE = sUserAgent.indexOf("compatible") > -1 74 && sUserAgent.indexOf("MSIE") > -175 && !isOpera;76 77var isMinIE4 = isMinIE5 = isMinIE5_5 = isMinIE6 = false;78if (isIE) {79 var reIE = new RegExp("MSIE (\\d+\\.\\d+);");80 reIE.test(sUserAgent);81 var fIEVersion = parseFloat(RegExp["$1"]);82 isMinIE4 = fIEVersion >= 4;83 isMinIE5 = fIEVersion >= 5;84 isMinIE5_5 = fIEVersion >= 5.5;85 isMinIE6 = fIEVersion >= 6.0;86}87var isMoz = sUserAgent.indexOf("Gecko") > -188 && !isKHTML;89var isMinMoz1 = sMinMoz1_4 = isMinMoz1_5 = false;90if (isMoz) {91 var reMoz = new RegExp("rv:(\\d+\\.\\d+(?:\\.\\d+)?)");92 reMoz.test(sUserAgent);93 isMinMoz1 = compareVersions(RegExp["$1"], "1.0") >= 0;94 isMinMoz1_4 = compareVersions(RegExp["$1"], "1.4") >= 0;95 isMinMoz1_5 = compareVersions(RegExp["$1"], "1.5") >= 0;96}97var isNS4 = !isIE && !isOpera && !isMoz && !isKHTML 98 && (sUserAgent.indexOf("Mozilla") == 0) 99 && (navigator.appName == "Netscape") 100 && (fAppVersion >= 4.0 && fAppVersion < 5.0);101var isMinNS4 = isMinNS4_5 = isMinNS4_7 = isMinNS4_8 = false;102if (isNS4) {103 isMinNS4 = true;104 isMinNS4_5 = fAppVersion >= 4.5;105 isMinNS4_7 = fAppVersion >= 4.7;106 isMinNS4_8 = fAppVersion >= 4.8;107}108var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");109var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") 110 || (navigator.platform == "Macintosh");111var isUnix = (navigator.platform == "X11") && !isWin && !isMac;112var isWin95 = isWin98 = isWinNT4 = isWin2K = isWinME = isWinXP = false;113var isMac68K = isMacPPC = false;114var isSunOS = isMinSunOS4 = isMinSunOS5 = isMinSunOS5_5 = false;115if (isWin) {116 isWin95 = sUserAgent.indexOf("Win95") > -1 117 || sUserAgent.indexOf("Windows 95") > -1;118 isWin98 = sUserAgent.indexOf("Win98") > -1 119 || sUserAgent.indexOf("Windows 98") > -1;120 isWinME = sUserAgent.indexOf("Win 9x 4.90") > -1 121 || sUserAgent.indexOf("Windows ME") > -1;122 isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 123 || sUserAgent.indexOf("Windows 2000") > -1;124 isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 125 || sUserAgent.indexOf("Windows XP") > -1;126 isWinNT4 = sUserAgent.indexOf("WinNT") > -1 127 || sUserAgent.indexOf("Windows NT") > -1 128 || sUserAgent.indexOf("WinNT4.0") > -1 129 || sUserAgent.indexOf("Windows NT 4.0") > -1 130 && (!isWinME && !isWin2K && !isWinXP);131} 132if (isMac) {133 isMac68K = sUserAgent.indexOf("Mac_68000") > -1 134 || sUserAgent.indexOf("68K") > -1;135 isMacPPC = sUserAgent.indexOf("Mac_PowerPC") > -1 136 || sUserAgent.indexOf("PPC") > -1; 137}138if (isUnix) {139 isSunOS = sUserAgent.indexOf("SunOS") > -1;140 if (isSunOS) {141 var reSunOS = new RegExp("SunOS (\\d+\\.\\d+(?:\\.\\d+)?)");142 reSunOS.test(sUserAgent);143 isMinSunOS4 = compareVersions(RegExp["$1"], "4.0") >= 0;144 isMinSunOS5 = compareVersions(RegExp["$1"], "5.0") >= 0;145 isMinSunOS5_5 = compareVersions(RegExp["$1"], "5.5") >= 0;146 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.runTest(url, function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10{ statusCode: 400,11 { server: 'nginx/1.6.2',12 connection: 'close' } }

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var api = new wpt('www.webpagetest.org');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9{ statusCode: 200,10 { statusCode: 200,11 { testId: '150320_1A_1',12var wpt = require('webpagetest');13var api = new wpt('www.webpagetest.org');14 if (err) {15 console.log(err);16 } else {17 console.log(data);18 }19});20var wpt = require('webpagetest');21var api = new wpt('www.webpagetest.org');22api.getTestResults('150320_1A_1', function(err, data) {23 if (err) {24 console.log(err);25 } else {26 console.log(data);27 }28});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var page = wptools.page('Barack Obama');3page.get(function(err,resp) {4 console.log(resp);5});6var wptools = require('wptools');7var page = wptools.page('Barack Obama');8page.get(function(err,resp) {9 console.log(resp);10});11var wptools = require('wptools');12var page = wptools.page('Barack Obama');13page.get(function(err,resp) {14 console.log(resp);15});16var wptools = require('wptools');17var page = wptools.page('Barack Obama');18page.get(function(err,resp) {19 console.log(resp);20});21var wptools = require('wptools');22var page = wptools.page('Barack Obama');23page.get(function(err,resp) {24 console.log(resp);25});26var wptools = require('wptools');27var page = wptools.page('Barack Obama');28page.get(function(err,resp) {29 console.log(resp);30});31var wptools = require('wptools');32var page = wptools.page('Barack Obama');33page.get(function(err,resp) {34 console.log(resp);35});36var wptools = require('wptools');37var page = wptools.page('Barack Obama');38page.get(function(err,resp) {39 console.log(resp);40});41var wptools = require('wptools');42var page = wptools.page('Barack Obama');43page.get(function(err,resp) {44 console.log(resp);45});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var api = new wpt('www.webpagetest.org', 'A.2d3e5f7g9h0j1k3l5n7p9q0r2s4t6v8x');3 if (err) return console.error(err);4 console.log('Test status: ' + data.statusText);5 console.log('Test ID: ' + data.data.testId);6 api.getTestResults(data.data.testId, function(err, data) {7 if (err) return console.error(err);8 console.log('Test results: ' + JSON.stringify(data.data));9 });10});11{ [Error: connect ECONNREFUSED

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