123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393 |
- /*!
- * (The MIT License)
- *
- * Copyright (c) 2012-2014 Marcin Warpechowski
- * Copyright (c) 2015 Handsoncode sp. z o.o. <hello@handsoncode.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * 'Software'), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Version: 0.32.0-beta2
- * Date: Tue May 30 2017 12:10:57 GMT+0200 (CEST)
- */
- /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // identity function for calling harmony imports with the correct context
- /******/ __webpack_require__.i = function(value) { return value; };
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, {
- /******/ configurable: false,
- /******/ enumerable: true,
- /******/ get: getter
- /******/ });
- /******/ }
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 216);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ (function(module, exports, __webpack_require__) {
- var global = __webpack_require__(2)
- , core = __webpack_require__(20)
- , hide = __webpack_require__(13)
- , redefine = __webpack_require__(14)
- , ctx = __webpack_require__(10)
- , PROTOTYPE = 'prototype';
- var $export = function(type, name, source){
- var IS_FORCED = type & $export.F
- , IS_GLOBAL = type & $export.G
- , IS_STATIC = type & $export.S
- , IS_PROTO = type & $export.P
- , IS_BIND = type & $export.B
- , target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE]
- , exports = IS_GLOBAL ? core : core[name] || (core[name] = {})
- , expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {})
- , key, own, out, exp;
- if(IS_GLOBAL)source = name;
- for(key in source){
- // contains in native
- own = !IS_FORCED && target && target[key] !== undefined;
- // export native or passed
- out = (own ? target : source)[key];
- // bind timers to global for call from export context
- exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
- // extend global
- if(target)redefine(target, key, out, type & $export.U);
- // export
- if(exports[key] != out)hide(exports, key, exp);
- if(IS_PROTO && expProto[key] != out)expProto[key] = out;
- }
- };
- global.core = core;
- // type bitmap
- $export.F = 1; // forced
- $export.G = 2; // global
- $export.S = 4; // static
- $export.P = 8; // proto
- $export.B = 16; // bind
- $export.W = 32; // wrap
- $export.U = 64; // safe
- $export.R = 128; // real proto method for `library`
- module.exports = $export;
- /***/ }),
- /* 1 */
- /***/ (function(module, exports, __webpack_require__) {
- var store = __webpack_require__(47)('wks')
- , uid = __webpack_require__(25)
- , Symbol = __webpack_require__(2).Symbol
- , USE_SYMBOL = typeof Symbol == 'function';
- var $exports = module.exports = function(name){
- return store[name] || (store[name] =
- USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
- };
- $exports.store = store;
- /***/ }),
- /* 2 */
- /***/ (function(module, exports) {
- // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
- var global = module.exports = typeof window != 'undefined' && window.Math == Math
- ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
- if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
- /***/ }),
- /* 3 */
- /***/ (function(module, exports) {
- module.exports = function(it){
- return typeof it === 'object' ? it !== null : typeof it === 'function';
- };
- /***/ }),
- /* 4 */
- /***/ (function(module, exports, __webpack_require__) {
- var isObject = __webpack_require__(3);
- module.exports = function(it){
- if(!isObject(it))throw TypeError(it + ' is not an object!');
- return it;
- };
- /***/ }),
- /* 5 */
- /***/ (function(module, exports, __webpack_require__) {
- var anObject = __webpack_require__(4)
- , IE8_DOM_DEFINE = __webpack_require__(57)
- , toPrimitive = __webpack_require__(50)
- , dP = Object.defineProperty;
- exports.f = __webpack_require__(6) ? Object.defineProperty : function defineProperty(O, P, Attributes){
- anObject(O);
- P = toPrimitive(P, true);
- anObject(Attributes);
- if(IE8_DOM_DEFINE)try {
- return dP(O, P, Attributes);
- } catch(e){ /* empty */ }
- if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
- if('value' in Attributes)O[P] = Attributes.value;
- return O;
- };
- /***/ }),
- /* 6 */
- /***/ (function(module, exports, __webpack_require__) {
- // Thank's IE8 for his funny defineProperty
- module.exports = !__webpack_require__(12)(function(){
- return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
- });
- /***/ }),
- /* 7 */
- /***/ (function(module, exports) {
- var hasOwnProperty = {}.hasOwnProperty;
- module.exports = function(it, key){
- return hasOwnProperty.call(it, key);
- };
- /***/ }),
- /* 8 */
- /***/ (function(module, exports, __webpack_require__) {
- // to indexed object, toObject with fallback for non-array-like ES3 strings
- var IObject = __webpack_require__(41)
- , defined = __webpack_require__(11);
- module.exports = function(it){
- return IObject(defined(it));
- };
- /***/ }),
- /* 9 */
- /***/ (function(module, exports, __webpack_require__) {
- // 7.1.15 ToLength
- var toInteger = __webpack_require__(35)
- , min = Math.min;
- module.exports = function(it){
- return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
- };
- /***/ }),
- /* 10 */
- /***/ (function(module, exports, __webpack_require__) {
- // optional / simple context binding
- var aFunction = __webpack_require__(36);
- module.exports = function(fn, that, length){
- aFunction(fn);
- if(that === undefined)return fn;
- switch(length){
- case 1: return function(a){
- return fn.call(that, a);
- };
- case 2: return function(a, b){
- return fn.call(that, a, b);
- };
- case 3: return function(a, b, c){
- return fn.call(that, a, b, c);
- };
- }
- return function(/* ...args */){
- return fn.apply(that, arguments);
- };
- };
- /***/ }),
- /* 11 */
- /***/ (function(module, exports) {
- // 7.2.1 RequireObjectCoercible(argument)
- module.exports = function(it){
- if(it == undefined)throw TypeError("Can't call method on " + it);
- return it;
- };
- /***/ }),
- /* 12 */
- /***/ (function(module, exports) {
- module.exports = function(exec){
- try {
- return !!exec();
- } catch(e){
- return true;
- }
- };
- /***/ }),
- /* 13 */
- /***/ (function(module, exports, __webpack_require__) {
- var dP = __webpack_require__(5)
- , createDesc = __webpack_require__(18);
- module.exports = __webpack_require__(6) ? function(object, key, value){
- return dP.f(object, key, createDesc(1, value));
- } : function(object, key, value){
- object[key] = value;
- return object;
- };
- /***/ }),
- /* 14 */
- /***/ (function(module, exports, __webpack_require__) {
- var global = __webpack_require__(2)
- , hide = __webpack_require__(13)
- , has = __webpack_require__(7)
- , SRC = __webpack_require__(25)('src')
- , TO_STRING = 'toString'
- , $toString = Function[TO_STRING]
- , TPL = ('' + $toString).split(TO_STRING);
- __webpack_require__(20).inspectSource = function(it){
- return $toString.call(it);
- };
- (module.exports = function(O, key, val, safe){
- var isFunction = typeof val == 'function';
- if(isFunction)has(val, 'name') || hide(val, 'name', key);
- if(O[key] === val)return;
- if(isFunction)has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
- if(O === global){
- O[key] = val;
- } else {
- if(!safe){
- delete O[key];
- hide(O, key, val);
- } else {
- if(O[key])O[key] = val;
- else hide(O, key, val);
- }
- }
- // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
- })(Function.prototype, TO_STRING, function toString(){
- return typeof this == 'function' && this[SRC] || $toString.call(this);
- });
- /***/ }),
- /* 15 */
- /***/ (function(module, exports, __webpack_require__) {
- // 22.1.3.31 Array.prototype[@@unscopables]
- var UNSCOPABLES = __webpack_require__(1)('unscopables')
- , ArrayProto = Array.prototype;
- if(ArrayProto[UNSCOPABLES] == undefined)__webpack_require__(13)(ArrayProto, UNSCOPABLES, {});
- module.exports = function(key){
- ArrayProto[UNSCOPABLES][key] = true;
- };
- /***/ }),
- /* 16 */
- /***/ (function(module, exports) {
- var toString = {}.toString;
- module.exports = function(it){
- return toString.call(it).slice(8, -1);
- };
- /***/ }),
- /* 17 */
- /***/ (function(module, exports, __webpack_require__) {
- // 19.1.2.14 / 15.2.3.14 Object.keys(O)
- var $keys = __webpack_require__(66)
- , enumBugKeys = __webpack_require__(39);
- module.exports = Object.keys || function keys(O){
- return $keys(O, enumBugKeys);
- };
- /***/ }),
- /* 18 */
- /***/ (function(module, exports) {
- module.exports = function(bitmap, value){
- return {
- enumerable : !(bitmap & 1),
- configurable: !(bitmap & 2),
- writable : !(bitmap & 4),
- value : value
- };
- };
- /***/ }),
- /* 19 */
- /***/ (function(module, exports, __webpack_require__) {
- // 7.1.13 ToObject(argument)
- var defined = __webpack_require__(11);
- module.exports = function(it){
- return Object(defined(it));
- };
- /***/ }),
- /* 20 */
- /***/ (function(module, exports) {
- var core = module.exports = {version: '2.4.0'};
- if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
- /***/ }),
- /* 21 */
- /***/ (function(module, exports) {
- module.exports = {};
- /***/ }),
- /* 22 */
- /***/ (function(module, exports, __webpack_require__) {
- var META = __webpack_require__(25)('meta')
- , isObject = __webpack_require__(3)
- , has = __webpack_require__(7)
- , setDesc = __webpack_require__(5).f
- , id = 0;
- var isExtensible = Object.isExtensible || function(){
- return true;
- };
- var FREEZE = !__webpack_require__(12)(function(){
- return isExtensible(Object.preventExtensions({}));
- });
- var setMeta = function(it){
- setDesc(it, META, {value: {
- i: 'O' + ++id, // object ID
- w: {} // weak collections IDs
- }});
- };
- var fastKey = function(it, create){
- // return primitive with prefix
- if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
- if(!has(it, META)){
- // can't set metadata to uncaught frozen object
- if(!isExtensible(it))return 'F';
- // not necessary to add metadata
- if(!create)return 'E';
- // add missing metadata
- setMeta(it);
- // return object ID
- } return it[META].i;
- };
- var getWeak = function(it, create){
- if(!has(it, META)){
- // can't set metadata to uncaught frozen object
- if(!isExtensible(it))return true;
- // not necessary to add metadata
- if(!create)return false;
- // add missing metadata
- setMeta(it);
- // return hash weak collections IDs
- } return it[META].w;
- };
- // add metadata on freeze-family methods calling
- var onFreeze = function(it){
- if(FREEZE && meta.NEED && isExtensible(it) && !has(it, META))setMeta(it);
- return it;
- };
- var meta = module.exports = {
- KEY: META,
- NEED: false,
- fastKey: fastKey,
- getWeak: getWeak,
- onFreeze: onFreeze
- };
- /***/ }),
- /* 23 */
- /***/ (function(module, exports) {
- exports.f = {}.propertyIsEnumerable;
- /***/ }),
- /* 24 */
- /***/ (function(module, exports, __webpack_require__) {
- var def = __webpack_require__(5).f
- , has = __webpack_require__(7)
- , TAG = __webpack_require__(1)('toStringTag');
- module.exports = function(it, tag, stat){
- if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag});
- };
- /***/ }),
- /* 25 */
- /***/ (function(module, exports) {
- var id = 0
- , px = Math.random();
- module.exports = function(key){
- return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
- };
- /***/ }),
- /* 26 */
- /***/ (function(module, exports) {
- module.exports = function(it, Constructor, name, forbiddenField){
- if(!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)){
- throw TypeError(name + ': incorrect invocation!');
- } return it;
- };
- /***/ }),
- /* 27 */
- /***/ (function(module, exports, __webpack_require__) {
- // 0 -> Array#forEach
- // 1 -> Array#map
- // 2 -> Array#filter
- // 3 -> Array#some
- // 4 -> Array#every
- // 5 -> Array#find
- // 6 -> Array#findIndex
- var ctx = __webpack_require__(10)
- , IObject = __webpack_require__(41)
- , toObject = __webpack_require__(19)
- , toLength = __webpack_require__(9)
- , asc = __webpack_require__(250);
- module.exports = function(TYPE, $create){
- var IS_MAP = TYPE == 1
- , IS_FILTER = TYPE == 2
- , IS_SOME = TYPE == 3
- , IS_EVERY = TYPE == 4
- , IS_FIND_INDEX = TYPE == 6
- , NO_HOLES = TYPE == 5 || IS_FIND_INDEX
- , create = $create || asc;
- return function($this, callbackfn, that){
- var O = toObject($this)
- , self = IObject(O)
- , f = ctx(callbackfn, that, 3)
- , length = toLength(self.length)
- , index = 0
- , result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined
- , val, res;
- for(;length > index; index++)if(NO_HOLES || index in self){
- val = self[index];
- res = f(val, index, O);
- if(TYPE){
- if(IS_MAP)result[index] = res; // map
- else if(res)switch(TYPE){
- case 3: return true; // some
- case 5: return val; // find
- case 6: return index; // findIndex
- case 2: result.push(val); // filter
- } else if(IS_EVERY)return false; // every
- }
- }
- return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
- };
- };
- /***/ }),
- /* 28 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var global = __webpack_require__(2)
- , $export = __webpack_require__(0)
- , redefine = __webpack_require__(14)
- , redefineAll = __webpack_require__(33)
- , meta = __webpack_require__(22)
- , forOf = __webpack_require__(30)
- , anInstance = __webpack_require__(26)
- , isObject = __webpack_require__(3)
- , fails = __webpack_require__(12)
- , $iterDetect = __webpack_require__(42)
- , setToStringTag = __webpack_require__(24)
- , inheritIfRequired = __webpack_require__(253);
- module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){
- var Base = global[NAME]
- , C = Base
- , ADDER = IS_MAP ? 'set' : 'add'
- , proto = C && C.prototype
- , O = {};
- var fixMethod = function(KEY){
- var fn = proto[KEY];
- redefine(proto, KEY,
- KEY == 'delete' ? function(a){
- return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
- } : KEY == 'has' ? function has(a){
- return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
- } : KEY == 'get' ? function get(a){
- return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
- } : KEY == 'add' ? function add(a){ fn.call(this, a === 0 ? 0 : a); return this; }
- : function set(a, b){ fn.call(this, a === 0 ? 0 : a, b); return this; }
- );
- };
- if(typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function(){
- new C().entries().next();
- }))){
- // create collection constructor
- C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
- redefineAll(C.prototype, methods);
- meta.NEED = true;
- } else {
- var instance = new C
- // early implementations not supports chaining
- , HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance
- // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
- , THROWS_ON_PRIMITIVES = fails(function(){ instance.has(1); })
- // most early implementations doesn't supports iterables, most modern - not close it correctly
- , ACCEPT_ITERABLES = $iterDetect(function(iter){ new C(iter); }) // eslint-disable-line no-new
- // for early implementations -0 and +0 not the same
- , BUGGY_ZERO = !IS_WEAK && fails(function(){
- // V8 ~ Chromium 42- fails only with 5+ elements
- var $instance = new C()
- , index = 5;
- while(index--)$instance[ADDER](index, index);
- return !$instance.has(-0);
- });
- if(!ACCEPT_ITERABLES){
- C = wrapper(function(target, iterable){
- anInstance(target, C, NAME);
- var that = inheritIfRequired(new Base, target, C);
- if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
- return that;
- });
- C.prototype = proto;
- proto.constructor = C;
- }
- if(THROWS_ON_PRIMITIVES || BUGGY_ZERO){
- fixMethod('delete');
- fixMethod('has');
- IS_MAP && fixMethod('get');
- }
- if(BUGGY_ZERO || HASNT_CHAINING)fixMethod(ADDER);
- // weak collections should not contains .clear method
- if(IS_WEAK && proto.clear)delete proto.clear;
- }
- setToStringTag(C, NAME);
- O[NAME] = C;
- $export($export.G + $export.W + $export.F * (C != Base), O);
- if(!IS_WEAK)common.setStrong(C, NAME, IS_MAP);
- return C;
- };
- /***/ }),
- /* 29 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var hide = __webpack_require__(13)
- , redefine = __webpack_require__(14)
- , fails = __webpack_require__(12)
- , defined = __webpack_require__(11)
- , wks = __webpack_require__(1);
- module.exports = function(KEY, length, exec){
- var SYMBOL = wks(KEY)
- , fns = exec(defined, SYMBOL, ''[KEY])
- , strfn = fns[0]
- , rxfn = fns[1];
- if(fails(function(){
- var O = {};
- O[SYMBOL] = function(){ return 7; };
- return ''[KEY](O) != 7;
- })){
- redefine(String.prototype, KEY, strfn);
- hide(RegExp.prototype, SYMBOL, length == 2
- // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
- // 21.2.5.11 RegExp.prototype[@@split](string, limit)
- ? function(string, arg){ return rxfn.call(string, this, arg); }
- // 21.2.5.6 RegExp.prototype[@@match](string)
- // 21.2.5.9 RegExp.prototype[@@search](string)
- : function(string){ return rxfn.call(string, this); }
- );
- }
- };
- /***/ }),
- /* 30 */
- /***/ (function(module, exports, __webpack_require__) {
- var ctx = __webpack_require__(10)
- , call = __webpack_require__(62)
- , isArrayIter = __webpack_require__(58)
- , anObject = __webpack_require__(4)
- , toLength = __webpack_require__(9)
- , getIterFn = __webpack_require__(73)
- , BREAK = {}
- , RETURN = {};
- var exports = module.exports = function(iterable, entries, fn, that, ITERATOR){
- var iterFn = ITERATOR ? function(){ return iterable; } : getIterFn(iterable)
- , f = ctx(fn, that, entries ? 2 : 1)
- , index = 0
- , length, step, iterator, result;
- if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!');
- // fast case for arrays with default iterator
- if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){
- result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
- if(result === BREAK || result === RETURN)return result;
- } else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){
- result = call(iterator, f, step.value, entries);
- if(result === BREAK || result === RETURN)return result;
- }
- };
- exports.BREAK = BREAK;
- exports.RETURN = RETURN;
- /***/ }),
- /* 31 */
- /***/ (function(module, exports) {
- module.exports = false;
- /***/ }),
- /* 32 */
- /***/ (function(module, exports) {
- exports.f = Object.getOwnPropertySymbols;
- /***/ }),
- /* 33 */
- /***/ (function(module, exports, __webpack_require__) {
- var redefine = __webpack_require__(14);
- module.exports = function(target, src, safe){
- for(var key in src)redefine(target, key, src[key], safe);
- return target;
- };
- /***/ }),
- /* 34 */
- /***/ (function(module, exports, __webpack_require__) {
- var toInteger = __webpack_require__(35)
- , max = Math.max
- , min = Math.min;
- module.exports = function(index, length){
- index = toInteger(index);
- return index < 0 ? max(index + length, 0) : min(index, length);
- };
- /***/ }),
- /* 35 */
- /***/ (function(module, exports) {
- // 7.1.4 ToInteger
- var ceil = Math.ceil
- , floor = Math.floor;
- module.exports = function(it){
- return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
- };
- /***/ }),
- /* 36 */
- /***/ (function(module, exports) {
- module.exports = function(it){
- if(typeof it != 'function')throw TypeError(it + ' is not a function!');
- return it;
- };
- /***/ }),
- /* 37 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var $defineProperty = __webpack_require__(5)
- , createDesc = __webpack_require__(18);
- module.exports = function(object, index, value){
- if(index in object)$defineProperty.f(object, index, createDesc(0, value));
- else object[index] = value;
- };
- /***/ }),
- /* 38 */
- /***/ (function(module, exports, __webpack_require__) {
- var isObject = __webpack_require__(3)
- , document = __webpack_require__(2).document
- // in old IE typeof document.createElement is 'object'
- , is = isObject(document) && isObject(document.createElement);
- module.exports = function(it){
- return is ? document.createElement(it) : {};
- };
- /***/ }),
- /* 39 */
- /***/ (function(module, exports) {
- // IE 8- don't enum bug keys
- module.exports = (
- 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
- ).split(',');
- /***/ }),
- /* 40 */
- /***/ (function(module, exports, __webpack_require__) {
- var MATCH = __webpack_require__(1)('match');
- module.exports = function(KEY){
- var re = /./;
- try {
- '/./'[KEY](re);
- } catch(e){
- try {
- re[MATCH] = false;
- return !'/./'[KEY](re);
- } catch(f){ /* empty */ }
- } return true;
- };
- /***/ }),
- /* 41 */
- /***/ (function(module, exports, __webpack_require__) {
- // fallback for non-array-like ES3 and non-enumerable old V8 strings
- var cof = __webpack_require__(16);
- module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){
- return cof(it) == 'String' ? it.split('') : Object(it);
- };
- /***/ }),
- /* 42 */
- /***/ (function(module, exports, __webpack_require__) {
- var ITERATOR = __webpack_require__(1)('iterator')
- , SAFE_CLOSING = false;
- try {
- var riter = [7][ITERATOR]();
- riter['return'] = function(){ SAFE_CLOSING = true; };
- Array.from(riter, function(){ throw 2; });
- } catch(e){ /* empty */ }
- module.exports = function(exec, skipClosing){
- if(!skipClosing && !SAFE_CLOSING)return false;
- var safe = false;
- try {
- var arr = [7]
- , iter = arr[ITERATOR]();
- iter.next = function(){ return {done: safe = true}; };
- arr[ITERATOR] = function(){ return iter; };
- exec(arr);
- } catch(e){ /* empty */ }
- return safe;
- };
- /***/ }),
- /* 43 */
- /***/ (function(module, exports, __webpack_require__) {
- // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
- var anObject = __webpack_require__(4)
- , dPs = __webpack_require__(258)
- , enumBugKeys = __webpack_require__(39)
- , IE_PROTO = __webpack_require__(46)('IE_PROTO')
- , Empty = function(){ /* empty */ }
- , PROTOTYPE = 'prototype';
- // Create object with fake `null` prototype: use iframe Object with cleared prototype
- var createDict = function(){
- // Thrash, waste and sodomy: IE GC bug
- var iframe = __webpack_require__(38)('iframe')
- , i = enumBugKeys.length
- , lt = '<'
- , gt = '>'
- , iframeDocument;
- iframe.style.display = 'none';
- __webpack_require__(56).appendChild(iframe);
- iframe.src = 'javascript:'; // eslint-disable-line no-script-url
- // createDict = iframe.contentWindow.Object;
- // html.removeChild(iframe);
- iframeDocument = iframe.contentWindow.document;
- iframeDocument.open();
- iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
- iframeDocument.close();
- createDict = iframeDocument.F;
- while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]];
- return createDict();
- };
- module.exports = Object.create || function create(O, Properties){
- var result;
- if(O !== null){
- Empty[PROTOTYPE] = anObject(O);
- result = new Empty;
- Empty[PROTOTYPE] = null;
- // add "__proto__" for Object.getPrototypeOf polyfill
- result[IE_PROTO] = O;
- } else result = createDict();
- return Properties === undefined ? result : dPs(result, Properties);
- };
- /***/ }),
- /* 44 */
- /***/ (function(module, exports, __webpack_require__) {
- var pIE = __webpack_require__(23)
- , createDesc = __webpack_require__(18)
- , toIObject = __webpack_require__(8)
- , toPrimitive = __webpack_require__(50)
- , has = __webpack_require__(7)
- , IE8_DOM_DEFINE = __webpack_require__(57)
- , gOPD = Object.getOwnPropertyDescriptor;
- exports.f = __webpack_require__(6) ? gOPD : function getOwnPropertyDescriptor(O, P){
- O = toIObject(O);
- P = toPrimitive(P, true);
- if(IE8_DOM_DEFINE)try {
- return gOPD(O, P);
- } catch(e){ /* empty */ }
- if(has(O, P))return createDesc(!pIE.f.call(O, P), O[P]);
- };
- /***/ }),
- /* 45 */
- /***/ (function(module, exports, __webpack_require__) {
- // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
- var $keys = __webpack_require__(66)
- , hiddenKeys = __webpack_require__(39).concat('length', 'prototype');
- exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O){
- return $keys(O, hiddenKeys);
- };
- /***/ }),
- /* 46 */
- /***/ (function(module, exports, __webpack_require__) {
- var shared = __webpack_require__(47)('keys')
- , uid = __webpack_require__(25);
- module.exports = function(key){
- return shared[key] || (shared[key] = uid(key));
- };
- /***/ }),
- /* 47 */
- /***/ (function(module, exports, __webpack_require__) {
- var global = __webpack_require__(2)
- , SHARED = '__core-js_shared__'
- , store = global[SHARED] || (global[SHARED] = {});
- module.exports = function(key){
- return store[key] || (store[key] = {});
- };
- /***/ }),
- /* 48 */
- /***/ (function(module, exports, __webpack_require__) {
- // helper for String#{startsWith, endsWith, includes}
- var isRegExp = __webpack_require__(61)
- , defined = __webpack_require__(11);
- module.exports = function(that, searchString, NAME){
- if(isRegExp(searchString))throw TypeError('String#' + NAME + " doesn't accept regex!");
- return String(defined(that));
- };
- /***/ }),
- /* 49 */
- /***/ (function(module, exports, __webpack_require__) {
- var ctx = __webpack_require__(10)
- , invoke = __webpack_require__(254)
- , html = __webpack_require__(56)
- , cel = __webpack_require__(38)
- , global = __webpack_require__(2)
- , process = global.process
- , setTask = global.setImmediate
- , clearTask = global.clearImmediate
- , MessageChannel = global.MessageChannel
- , counter = 0
- , queue = {}
- , ONREADYSTATECHANGE = 'onreadystatechange'
- , defer, channel, port;
- var run = function(){
- var id = +this;
- if(queue.hasOwnProperty(id)){
- var fn = queue[id];
- delete queue[id];
- fn();
- }
- };
- var listener = function(event){
- run.call(event.data);
- };
- // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
- if(!setTask || !clearTask){
- setTask = function setImmediate(fn){
- var args = [], i = 1;
- while(arguments.length > i)args.push(arguments[i++]);
- queue[++counter] = function(){
- invoke(typeof fn == 'function' ? fn : Function(fn), args);
- };
- defer(counter);
- return counter;
- };
- clearTask = function clearImmediate(id){
- delete queue[id];
- };
- // Node.js 0.8-
- if(__webpack_require__(16)(process) == 'process'){
- defer = function(id){
- process.nextTick(ctx(run, id, 1));
- };
- // Browsers with MessageChannel, includes WebWorkers
- } else if(MessageChannel){
- channel = new MessageChannel;
- port = channel.port2;
- channel.port1.onmessage = listener;
- defer = ctx(port.postMessage, port, 1);
- // Browsers with postMessage, skip WebWorkers
- // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
- } else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){
- defer = function(id){
- global.postMessage(id + '', '*');
- };
- global.addEventListener('message', listener, false);
- // IE8-
- } else if(ONREADYSTATECHANGE in cel('script')){
- defer = function(id){
- html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function(){
- html.removeChild(this);
- run.call(id);
- };
- };
- // Rest old browsers
- } else {
- defer = function(id){
- setTimeout(ctx(run, id, 1), 0);
- };
- }
- }
- module.exports = {
- set: setTask,
- clear: clearTask
- };
- /***/ }),
- /* 50 */
- /***/ (function(module, exports, __webpack_require__) {
- // 7.1.1 ToPrimitive(input [, PreferredType])
- var isObject = __webpack_require__(3);
- // instead of the ES6 spec version, we didn't implement @@toPrimitive case
- // and the second argument - flag - preferred type is a string
- module.exports = function(it, S){
- if(!isObject(it))return it;
- var fn, val;
- if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
- if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
- if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
- throw TypeError("Can't convert object to primitive value");
- };
- /***/ }),
- /* 51 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var addToUnscopables = __webpack_require__(15)
- , step = __webpack_require__(64)
- , Iterators = __webpack_require__(21)
- , toIObject = __webpack_require__(8);
- // 22.1.3.4 Array.prototype.entries()
- // 22.1.3.13 Array.prototype.keys()
- // 22.1.3.29 Array.prototype.values()
- // 22.1.3.30 Array.prototype[@@iterator]()
- module.exports = __webpack_require__(63)(Array, 'Array', function(iterated, kind){
- this._t = toIObject(iterated); // target
- this._i = 0; // next index
- this._k = kind; // kind
- // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
- }, function(){
- var O = this._t
- , kind = this._k
- , index = this._i++;
- if(!O || index >= O.length){
- this._t = undefined;
- return step(1);
- }
- if(kind == 'keys' )return step(0, index);
- if(kind == 'values')return step(0, O[index]);
- return step(0, [index, O[index]]);
- }, 'values');
- // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
- Iterators.Arguments = Iterators.Array;
- addToUnscopables('keys');
- addToUnscopables('values');
- addToUnscopables('entries');
- /***/ }),
- /* 52 */
- /***/ (function(module, exports, __webpack_require__) {
- // false -> Array#indexOf
- // true -> Array#includes
- var toIObject = __webpack_require__(8)
- , toLength = __webpack_require__(9)
- , toIndex = __webpack_require__(34);
- module.exports = function(IS_INCLUDES){
- return function($this, el, fromIndex){
- var O = toIObject($this)
- , length = toLength(O.length)
- , index = toIndex(fromIndex, length)
- , value;
- // Array#includes uses SameValueZero equality algorithm
- if(IS_INCLUDES && el != el)while(length > index){
- value = O[index++];
- if(value != value)return true;
- // Array#toIndex ignores holes, Array#includes - not
- } else for(;length > index; index++)if(IS_INCLUDES || index in O){
- if(O[index] === el)return IS_INCLUDES || index || 0;
- } return !IS_INCLUDES && -1;
- };
- };
- /***/ }),
- /* 53 */
- /***/ (function(module, exports, __webpack_require__) {
- // getting tag from 19.1.3.6 Object.prototype.toString()
- var cof = __webpack_require__(16)
- , TAG = __webpack_require__(1)('toStringTag')
- // ES3 wrong here
- , ARG = cof(function(){ return arguments; }()) == 'Arguments';
- // fallback for IE11 Script Access Denied error
- var tryGet = function(it, key){
- try {
- return it[key];
- } catch(e){ /* empty */ }
- };
- module.exports = function(it){
- var O, T, B;
- return it === undefined ? 'Undefined' : it === null ? 'Null'
- // @@toStringTag case
- : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
- // builtinTag case
- : ARG ? cof(O)
- // ES3 arguments fallback
- : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
- };
- /***/ }),
- /* 54 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var dP = __webpack_require__(5).f
- , create = __webpack_require__(43)
- , redefineAll = __webpack_require__(33)
- , ctx = __webpack_require__(10)
- , anInstance = __webpack_require__(26)
- , defined = __webpack_require__(11)
- , forOf = __webpack_require__(30)
- , $iterDefine = __webpack_require__(63)
- , step = __webpack_require__(64)
- , setSpecies = __webpack_require__(69)
- , DESCRIPTORS = __webpack_require__(6)
- , fastKey = __webpack_require__(22).fastKey
- , SIZE = DESCRIPTORS ? '_s' : 'size';
- var getEntry = function(that, key){
- // fast case
- var index = fastKey(key), entry;
- if(index !== 'F')return that._i[index];
- // frozen object case
- for(entry = that._f; entry; entry = entry.n){
- if(entry.k == key)return entry;
- }
- };
- module.exports = {
- getConstructor: function(wrapper, NAME, IS_MAP, ADDER){
- var C = wrapper(function(that, iterable){
- anInstance(that, C, NAME, '_i');
- that._i = create(null); // index
- that._f = undefined; // first entry
- that._l = undefined; // last entry
- that[SIZE] = 0; // size
- if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
- });
- redefineAll(C.prototype, {
- // 23.1.3.1 Map.prototype.clear()
- // 23.2.3.2 Set.prototype.clear()
- clear: function clear(){
- for(var that = this, data = that._i, entry = that._f; entry; entry = entry.n){
- entry.r = true;
- if(entry.p)entry.p = entry.p.n = undefined;
- delete data[entry.i];
- }
- that._f = that._l = undefined;
- that[SIZE] = 0;
- },
- // 23.1.3.3 Map.prototype.delete(key)
- // 23.2.3.4 Set.prototype.delete(value)
- 'delete': function(key){
- var that = this
- , entry = getEntry(that, key);
- if(entry){
- var next = entry.n
- , prev = entry.p;
- delete that._i[entry.i];
- entry.r = true;
- if(prev)prev.n = next;
- if(next)next.p = prev;
- if(that._f == entry)that._f = next;
- if(that._l == entry)that._l = prev;
- that[SIZE]--;
- } return !!entry;
- },
- // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
- // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
- forEach: function forEach(callbackfn /*, that = undefined */){
- anInstance(this, C, 'forEach');
- var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3)
- , entry;
- while(entry = entry ? entry.n : this._f){
- f(entry.v, entry.k, this);
- // revert to the last existing entry
- while(entry && entry.r)entry = entry.p;
- }
- },
- // 23.1.3.7 Map.prototype.has(key)
- // 23.2.3.7 Set.prototype.has(value)
- has: function has(key){
- return !!getEntry(this, key);
- }
- });
- if(DESCRIPTORS)dP(C.prototype, 'size', {
- get: function(){
- return defined(this[SIZE]);
- }
- });
- return C;
- },
- def: function(that, key, value){
- var entry = getEntry(that, key)
- , prev, index;
- // change existing entry
- if(entry){
- entry.v = value;
- // create new entry
- } else {
- that._l = entry = {
- i: index = fastKey(key, true), // <- index
- k: key, // <- key
- v: value, // <- value
- p: prev = that._l, // <- previous entry
- n: undefined, // <- next entry
- r: false // <- removed
- };
- if(!that._f)that._f = entry;
- if(prev)prev.n = entry;
- that[SIZE]++;
- // add to index
- if(index !== 'F')that._i[index] = entry;
- } return that;
- },
- getEntry: getEntry,
- setStrong: function(C, NAME, IS_MAP){
- // add .keys, .values, .entries, [@@iterator]
- // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
- $iterDefine(C, NAME, function(iterated, kind){
- this._t = iterated; // target
- this._k = kind; // kind
- this._l = undefined; // previous
- }, function(){
- var that = this
- , kind = that._k
- , entry = that._l;
- // revert to the last existing entry
- while(entry && entry.r)entry = entry.p;
- // get next entry
- if(!that._t || !(that._l = entry = entry ? entry.n : that._t._f)){
- // or finish the iteration
- that._t = undefined;
- return step(1);
- }
- // return step by kind
- if(kind == 'keys' )return step(0, entry.k);
- if(kind == 'values')return step(0, entry.v);
- return step(0, [entry.k, entry.v]);
- }, IS_MAP ? 'entries' : 'values' , !IS_MAP, true);
- // add [@@species], 23.1.2.2, 23.2.2.2
- setSpecies(NAME);
- }
- };
- /***/ }),
- /* 55 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var redefineAll = __webpack_require__(33)
- , getWeak = __webpack_require__(22).getWeak
- , anObject = __webpack_require__(4)
- , isObject = __webpack_require__(3)
- , anInstance = __webpack_require__(26)
- , forOf = __webpack_require__(30)
- , createArrayMethod = __webpack_require__(27)
- , $has = __webpack_require__(7)
- , arrayFind = createArrayMethod(5)
- , arrayFindIndex = createArrayMethod(6)
- , id = 0;
- // fallback for uncaught frozen keys
- var uncaughtFrozenStore = function(that){
- return that._l || (that._l = new UncaughtFrozenStore);
- };
- var UncaughtFrozenStore = function(){
- this.a = [];
- };
- var findUncaughtFrozen = function(store, key){
- return arrayFind(store.a, function(it){
- return it[0] === key;
- });
- };
- UncaughtFrozenStore.prototype = {
- get: function(key){
- var entry = findUncaughtFrozen(this, key);
- if(entry)return entry[1];
- },
- has: function(key){
- return !!findUncaughtFrozen(this, key);
- },
- set: function(key, value){
- var entry = findUncaughtFrozen(this, key);
- if(entry)entry[1] = value;
- else this.a.push([key, value]);
- },
- 'delete': function(key){
- var index = arrayFindIndex(this.a, function(it){
- return it[0] === key;
- });
- if(~index)this.a.splice(index, 1);
- return !!~index;
- }
- };
- module.exports = {
- getConstructor: function(wrapper, NAME, IS_MAP, ADDER){
- var C = wrapper(function(that, iterable){
- anInstance(that, C, NAME, '_i');
- that._i = id++; // collection id
- that._l = undefined; // leak store for uncaught frozen objects
- if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
- });
- redefineAll(C.prototype, {
- // 23.3.3.2 WeakMap.prototype.delete(key)
- // 23.4.3.3 WeakSet.prototype.delete(value)
- 'delete': function(key){
- if(!isObject(key))return false;
- var data = getWeak(key);
- if(data === true)return uncaughtFrozenStore(this)['delete'](key);
- return data && $has(data, this._i) && delete data[this._i];
- },
- // 23.3.3.4 WeakMap.prototype.has(key)
- // 23.4.3.4 WeakSet.prototype.has(value)
- has: function has(key){
- if(!isObject(key))return false;
- var data = getWeak(key);
- if(data === true)return uncaughtFrozenStore(this).has(key);
- return data && $has(data, this._i);
- }
- });
- return C;
- },
- def: function(that, key, value){
- var data = getWeak(anObject(key), true);
- if(data === true)uncaughtFrozenStore(that).set(key, value);
- else data[that._i] = value;
- return that;
- },
- ufstore: uncaughtFrozenStore
- };
- /***/ }),
- /* 56 */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(2).document && document.documentElement;
- /***/ }),
- /* 57 */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = !__webpack_require__(6) && !__webpack_require__(12)(function(){
- return Object.defineProperty(__webpack_require__(38)('div'), 'a', {get: function(){ return 7; }}).a != 7;
- });
- /***/ }),
- /* 58 */
- /***/ (function(module, exports, __webpack_require__) {
- // check on default Array iterator
- var Iterators = __webpack_require__(21)
- , ITERATOR = __webpack_require__(1)('iterator')
- , ArrayProto = Array.prototype;
- module.exports = function(it){
- return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
- };
- /***/ }),
- /* 59 */
- /***/ (function(module, exports, __webpack_require__) {
- // 7.2.2 IsArray(argument)
- var cof = __webpack_require__(16);
- module.exports = Array.isArray || function isArray(arg){
- return cof(arg) == 'Array';
- };
- /***/ }),
- /* 60 */
- /***/ (function(module, exports, __webpack_require__) {
- // 20.1.2.3 Number.isInteger(number)
- var isObject = __webpack_require__(3)
- , floor = Math.floor;
- module.exports = function isInteger(it){
- return !isObject(it) && isFinite(it) && floor(it) === it;
- };
- /***/ }),
- /* 61 */
- /***/ (function(module, exports, __webpack_require__) {
- // 7.2.8 IsRegExp(argument)
- var isObject = __webpack_require__(3)
- , cof = __webpack_require__(16)
- , MATCH = __webpack_require__(1)('match');
- module.exports = function(it){
- var isRegExp;
- return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
- };
- /***/ }),
- /* 62 */
- /***/ (function(module, exports, __webpack_require__) {
- // call something on iterator step with safe closing on error
- var anObject = __webpack_require__(4);
- module.exports = function(iterator, fn, value, entries){
- try {
- return entries ? fn(anObject(value)[0], value[1]) : fn(value);
- // 7.4.6 IteratorClose(iterator, completion)
- } catch(e){
- var ret = iterator['return'];
- if(ret !== undefined)anObject(ret.call(iterator));
- throw e;
- }
- };
- /***/ }),
- /* 63 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var LIBRARY = __webpack_require__(31)
- , $export = __webpack_require__(0)
- , redefine = __webpack_require__(14)
- , hide = __webpack_require__(13)
- , has = __webpack_require__(7)
- , Iterators = __webpack_require__(21)
- , $iterCreate = __webpack_require__(255)
- , setToStringTag = __webpack_require__(24)
- , getPrototypeOf = __webpack_require__(260)
- , ITERATOR = __webpack_require__(1)('iterator')
- , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`
- , FF_ITERATOR = '@@iterator'
- , KEYS = 'keys'
- , VALUES = 'values';
- var returnThis = function(){ return this; };
- module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){
- $iterCreate(Constructor, NAME, next);
- var getMethod = function(kind){
- if(!BUGGY && kind in proto)return proto[kind];
- switch(kind){
- case KEYS: return function keys(){ return new Constructor(this, kind); };
- case VALUES: return function values(){ return new Constructor(this, kind); };
- } return function entries(){ return new Constructor(this, kind); };
- };
- var TAG = NAME + ' Iterator'
- , DEF_VALUES = DEFAULT == VALUES
- , VALUES_BUG = false
- , proto = Base.prototype
- , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
- , $default = $native || getMethod(DEFAULT)
- , $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined
- , $anyNative = NAME == 'Array' ? proto.entries || $native : $native
- , methods, key, IteratorPrototype;
- // Fix native
- if($anyNative){
- IteratorPrototype = getPrototypeOf($anyNative.call(new Base));
- if(IteratorPrototype !== Object.prototype){
- // Set @@toStringTag to native iterators
- setToStringTag(IteratorPrototype, TAG, true);
- // fix for some old engines
- if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis);
- }
- }
- // fix Array#{values, @@iterator}.name in V8 / FF
- if(DEF_VALUES && $native && $native.name !== VALUES){
- VALUES_BUG = true;
- $default = function values(){ return $native.call(this); };
- }
- // Define iterator
- if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){
- hide(proto, ITERATOR, $default);
- }
- // Plug for library
- Iterators[NAME] = $default;
- Iterators[TAG] = returnThis;
- if(DEFAULT){
- methods = {
- values: DEF_VALUES ? $default : getMethod(VALUES),
- keys: IS_SET ? $default : getMethod(KEYS),
- entries: $entries
- };
- if(FORCED)for(key in methods){
- if(!(key in proto))redefine(proto, key, methods[key]);
- } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
- }
- return methods;
- };
- /***/ }),
- /* 64 */
- /***/ (function(module, exports) {
- module.exports = function(done, value){
- return {value: value, done: !!done};
- };
- /***/ }),
- /* 65 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // 19.1.2.1 Object.assign(target, source, ...)
- var getKeys = __webpack_require__(17)
- , gOPS = __webpack_require__(32)
- , pIE = __webpack_require__(23)
- , toObject = __webpack_require__(19)
- , IObject = __webpack_require__(41)
- , $assign = Object.assign;
- // should work with symbols and should have deterministic property order (V8 bug)
- module.exports = !$assign || __webpack_require__(12)(function(){
- var A = {}
- , B = {}
- , S = Symbol()
- , K = 'abcdefghijklmnopqrst';
- A[S] = 7;
- K.split('').forEach(function(k){ B[k] = k; });
- return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
- }) ? function assign(target, source){ // eslint-disable-line no-unused-vars
- var T = toObject(target)
- , aLen = arguments.length
- , index = 1
- , getSymbols = gOPS.f
- , isEnum = pIE.f;
- while(aLen > index){
- var S = IObject(arguments[index++])
- , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S)
- , length = keys.length
- , j = 0
- , key;
- while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key];
- } return T;
- } : $assign;
- /***/ }),
- /* 66 */
- /***/ (function(module, exports, __webpack_require__) {
- var has = __webpack_require__(7)
- , toIObject = __webpack_require__(8)
- , arrayIndexOf = __webpack_require__(52)(false)
- , IE_PROTO = __webpack_require__(46)('IE_PROTO');
- module.exports = function(object, names){
- var O = toIObject(object)
- , i = 0
- , result = []
- , key;
- for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
- // Don't enum bug & hidden keys
- while(names.length > i)if(has(O, key = names[i++])){
- ~arrayIndexOf(result, key) || result.push(key);
- }
- return result;
- };
- /***/ }),
- /* 67 */
- /***/ (function(module, exports, __webpack_require__) {
- var getKeys = __webpack_require__(17)
- , toIObject = __webpack_require__(8)
- , isEnum = __webpack_require__(23).f;
- module.exports = function(isEntries){
- return function(it){
- var O = toIObject(it)
- , keys = getKeys(O)
- , length = keys.length
- , i = 0
- , result = []
- , key;
- while(length > i)if(isEnum.call(O, key = keys[i++])){
- result.push(isEntries ? [key, O[key]] : O[key]);
- } return result;
- };
- };
- /***/ }),
- /* 68 */
- /***/ (function(module, exports, __webpack_require__) {
- // Works with __proto__ only. Old v8 can't work with null proto objects.
- /* eslint-disable no-proto */
- var isObject = __webpack_require__(3)
- , anObject = __webpack_require__(4);
- var check = function(O, proto){
- anObject(O);
- if(!isObject(proto) && proto !== null)throw TypeError(proto + ": can't set as prototype!");
- };
- module.exports = {
- set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line
- function(test, buggy, set){
- try {
- set = __webpack_require__(10)(Function.call, __webpack_require__(44).f(Object.prototype, '__proto__').set, 2);
- set(test, []);
- buggy = !(test instanceof Array);
- } catch(e){ buggy = true; }
- return function setPrototypeOf(O, proto){
- check(O, proto);
- if(buggy)O.__proto__ = proto;
- else set(O, proto);
- return O;
- };
- }({}, false) : undefined),
- check: check
- };
- /***/ }),
- /* 69 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var global = __webpack_require__(2)
- , dP = __webpack_require__(5)
- , DESCRIPTORS = __webpack_require__(6)
- , SPECIES = __webpack_require__(1)('species');
- module.exports = function(KEY){
- var C = global[KEY];
- if(DESCRIPTORS && C && !C[SPECIES])dP.f(C, SPECIES, {
- configurable: true,
- get: function(){ return this; }
- });
- };
- /***/ }),
- /* 70 */
- /***/ (function(module, exports, __webpack_require__) {
- // https://github.com/tc39/proposal-string-pad-start-end
- var toLength = __webpack_require__(9)
- , repeat = __webpack_require__(71)
- , defined = __webpack_require__(11);
- module.exports = function(that, maxLength, fillString, left){
- var S = String(defined(that))
- , stringLength = S.length
- , fillStr = fillString === undefined ? ' ' : String(fillString)
- , intMaxLength = toLength(maxLength);
- if(intMaxLength <= stringLength || fillStr == '')return S;
- var fillLen = intMaxLength - stringLength
- , stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
- if(stringFiller.length > fillLen)stringFiller = stringFiller.slice(0, fillLen);
- return left ? stringFiller + S : S + stringFiller;
- };
- /***/ }),
- /* 71 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var toInteger = __webpack_require__(35)
- , defined = __webpack_require__(11);
- module.exports = function repeat(count){
- var str = String(defined(this))
- , res = ''
- , n = toInteger(count);
- if(n < 0 || n == Infinity)throw RangeError("Count can't be negative");
- for(;n > 0; (n >>>= 1) && (str += str))if(n & 1)res += str;
- return res;
- };
- /***/ }),
- /* 72 */
- /***/ (function(module, exports, __webpack_require__) {
- exports.f = __webpack_require__(1);
- /***/ }),
- /* 73 */
- /***/ (function(module, exports, __webpack_require__) {
- var classof = __webpack_require__(53)
- , ITERATOR = __webpack_require__(1)('iterator')
- , Iterators = __webpack_require__(21);
- module.exports = __webpack_require__(20).getIteratorMethod = function(it){
- if(it != undefined)return it[ITERATOR]
- || it['@@iterator']
- || Iterators[classof(it)];
- };
- /***/ }),
- /* 74 */
- /***/ (function(module, exports) {
- var g;
- // This works in non-strict mode
- g = (function() {
- return this;
- })();
- try {
- // This works if eval is allowed (see CSP)
- g = g || Function("return this")() || (1,eval)("this");
- } catch(e) {
- // This works if the window reference is available
- if(typeof window === "object")
- g = window;
- }
- // g can still be undefined, but nothing to do about it...
- // We return undefined, instead of nothing here, so it's
- // easier to handle this case. if(!global) { ...}
- module.exports = g;
- /***/ }),
- /* 75 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // this file is called MemoryLeakTest.js (not MemoryLeak.spec.js) to make sure it is manually executed as the last suite
- describe('MemoryLeakTest', function () {
- it('after all Handsontable instances are destroy()\'d, there should be no more active listeners', function () {
- expect(Handsontable._getListenersCounter()).toBe(0);
- });
- });
- /***/ }),
- /* 76 */,
- /* 77 */,
- /* 78 */
- /***/ (function(module, exports, __webpack_require__) {
- // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
- var $export = __webpack_require__(0);
- $export($export.P, 'Array', {copyWithin: __webpack_require__(247)});
- __webpack_require__(15)('copyWithin');
- /***/ }),
- /* 79 */
- /***/ (function(module, exports, __webpack_require__) {
- // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
- var $export = __webpack_require__(0);
- $export($export.P, 'Array', {fill: __webpack_require__(248)});
- __webpack_require__(15)('fill');
- /***/ }),
- /* 80 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
- var $export = __webpack_require__(0)
- , $find = __webpack_require__(27)(6)
- , KEY = 'findIndex'
- , forced = true;
- // Shouldn't skip holes
- if(KEY in [])Array(1)[KEY](function(){ forced = false; });
- $export($export.P + $export.F * forced, 'Array', {
- findIndex: function findIndex(callbackfn/*, that = undefined */){
- return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- __webpack_require__(15)(KEY);
- /***/ }),
- /* 81 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
- var $export = __webpack_require__(0)
- , $find = __webpack_require__(27)(5)
- , KEY = 'find'
- , forced = true;
- // Shouldn't skip holes
- if(KEY in [])Array(1)[KEY](function(){ forced = false; });
- $export($export.P + $export.F * forced, 'Array', {
- find: function find(callbackfn/*, that = undefined */){
- return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- __webpack_require__(15)(KEY);
- /***/ }),
- /* 82 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var ctx = __webpack_require__(10)
- , $export = __webpack_require__(0)
- , toObject = __webpack_require__(19)
- , call = __webpack_require__(62)
- , isArrayIter = __webpack_require__(58)
- , toLength = __webpack_require__(9)
- , createProperty = __webpack_require__(37)
- , getIterFn = __webpack_require__(73);
- $export($export.S + $export.F * !__webpack_require__(42)(function(iter){ Array.from(iter); }), 'Array', {
- // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
- from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
- var O = toObject(arrayLike)
- , C = typeof this == 'function' ? this : Array
- , aLen = arguments.length
- , mapfn = aLen > 1 ? arguments[1] : undefined
- , mapping = mapfn !== undefined
- , index = 0
- , iterFn = getIterFn(O)
- , length, result, step, iterator;
- if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
- // if object isn't iterable or it's array with default iterator - use simple case
- if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){
- for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){
- createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
- }
- } else {
- length = toLength(O.length);
- for(result = new C(length); length > index; index++){
- createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
- }
- }
- result.length = index;
- return result;
- }
- });
- /***/ }),
- /* 83 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var $export = __webpack_require__(0)
- , createProperty = __webpack_require__(37);
- // WebKit Array.of isn't generic
- $export($export.S + $export.F * __webpack_require__(12)(function(){
- function F(){}
- return !(Array.of.call(F) instanceof F);
- }), 'Array', {
- // 22.1.2.3 Array.of( ...items)
- of: function of(/* ...args */){
- var index = 0
- , aLen = arguments.length
- , result = new (typeof this == 'function' ? this : Array)(aLen);
- while(aLen > index)createProperty(result, index, arguments[index++]);
- result.length = aLen;
- return result;
- }
- });
- /***/ }),
- /* 84 */
- /***/ (function(module, exports, __webpack_require__) {
- var dP = __webpack_require__(5).f
- , createDesc = __webpack_require__(18)
- , has = __webpack_require__(7)
- , FProto = Function.prototype
- , nameRE = /^\s*function ([^ (]*)/
- , NAME = 'name';
- var isExtensible = Object.isExtensible || function(){
- return true;
- };
- // 19.2.4.2 name
- NAME in FProto || __webpack_require__(6) && dP(FProto, NAME, {
- configurable: true,
- get: function(){
- try {
- var that = this
- , name = ('' + that).match(nameRE)[1];
- has(that, NAME) || !isExtensible(that) || dP(that, NAME, createDesc(5, name));
- return name;
- } catch(e){
- return '';
- }
- }
- });
- /***/ }),
- /* 85 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var strong = __webpack_require__(54);
- // 23.1 Map Objects
- module.exports = __webpack_require__(28)('Map', function(get){
- return function Map(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
- }, {
- // 23.1.3.6 Map.prototype.get(key)
- get: function get(key){
- var entry = strong.getEntry(this, key);
- return entry && entry.v;
- },
- // 23.1.3.9 Map.prototype.set(key, value)
- set: function set(key, value){
- return strong.def(this, key === 0 ? 0 : key, value);
- }
- }, strong, true);
- /***/ }),
- /* 86 */
- /***/ (function(module, exports, __webpack_require__) {
- // 20.1.2.1 Number.EPSILON
- var $export = __webpack_require__(0);
- $export($export.S, 'Number', {EPSILON: Math.pow(2, -52)});
- /***/ }),
- /* 87 */
- /***/ (function(module, exports, __webpack_require__) {
- // 20.1.2.2 Number.isFinite(number)
- var $export = __webpack_require__(0)
- , _isFinite = __webpack_require__(2).isFinite;
- $export($export.S, 'Number', {
- isFinite: function isFinite(it){
- return typeof it == 'number' && _isFinite(it);
- }
- });
- /***/ }),
- /* 88 */
- /***/ (function(module, exports, __webpack_require__) {
- // 20.1.2.3 Number.isInteger(number)
- var $export = __webpack_require__(0);
- $export($export.S, 'Number', {isInteger: __webpack_require__(60)});
- /***/ }),
- /* 89 */
- /***/ (function(module, exports, __webpack_require__) {
- // 20.1.2.4 Number.isNaN(number)
- var $export = __webpack_require__(0);
- $export($export.S, 'Number', {
- isNaN: function isNaN(number){
- return number != number;
- }
- });
- /***/ }),
- /* 90 */
- /***/ (function(module, exports, __webpack_require__) {
- // 20.1.2.5 Number.isSafeInteger(number)
- var $export = __webpack_require__(0)
- , isInteger = __webpack_require__(60)
- , abs = Math.abs;
- $export($export.S, 'Number', {
- isSafeInteger: function isSafeInteger(number){
- return isInteger(number) && abs(number) <= 0x1fffffffffffff;
- }
- });
- /***/ }),
- /* 91 */
- /***/ (function(module, exports, __webpack_require__) {
- // 20.1.2.6 Number.MAX_SAFE_INTEGER
- var $export = __webpack_require__(0);
- $export($export.S, 'Number', {MAX_SAFE_INTEGER: 0x1fffffffffffff});
- /***/ }),
- /* 92 */
- /***/ (function(module, exports, __webpack_require__) {
- // 20.1.2.10 Number.MIN_SAFE_INTEGER
- var $export = __webpack_require__(0);
- $export($export.S, 'Number', {MIN_SAFE_INTEGER: -0x1fffffffffffff});
- /***/ }),
- /* 93 */
- /***/ (function(module, exports, __webpack_require__) {
- // 19.1.3.1 Object.assign(target, source)
- var $export = __webpack_require__(0);
- $export($export.S + $export.F, 'Object', {assign: __webpack_require__(65)});
- /***/ }),
- /* 94 */
- /***/ (function(module, exports, __webpack_require__) {
- // 19.1.3.10 Object.is(value1, value2)
- var $export = __webpack_require__(0);
- $export($export.S, 'Object', {is: __webpack_require__(262)});
- /***/ }),
- /* 95 */
- /***/ (function(module, exports, __webpack_require__) {
- // 19.1.3.19 Object.setPrototypeOf(O, proto)
- var $export = __webpack_require__(0);
- $export($export.S, 'Object', {setPrototypeOf: __webpack_require__(68).set});
- /***/ }),
- /* 96 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var LIBRARY = __webpack_require__(31)
- , global = __webpack_require__(2)
- , ctx = __webpack_require__(10)
- , classof = __webpack_require__(53)
- , $export = __webpack_require__(0)
- , isObject = __webpack_require__(3)
- , aFunction = __webpack_require__(36)
- , anInstance = __webpack_require__(26)
- , forOf = __webpack_require__(30)
- , speciesConstructor = __webpack_require__(263)
- , task = __webpack_require__(49).set
- , microtask = __webpack_require__(257)()
- , PROMISE = 'Promise'
- , TypeError = global.TypeError
- , process = global.process
- , $Promise = global[PROMISE]
- , process = global.process
- , isNode = classof(process) == 'process'
- , empty = function(){ /* empty */ }
- , Internal, GenericPromiseCapability, Wrapper;
- var USE_NATIVE = !!function(){
- try {
- // correct subclassing with @@species support
- var promise = $Promise.resolve(1)
- , FakePromise = (promise.constructor = {})[__webpack_require__(1)('species')] = function(exec){ exec(empty, empty); };
- // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
- return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
- } catch(e){ /* empty */ }
- }();
- // helpers
- var sameConstructor = function(a, b){
- // with library wrapper special case
- return a === b || a === $Promise && b === Wrapper;
- };
- var isThenable = function(it){
- var then;
- return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
- };
- var newPromiseCapability = function(C){
- return sameConstructor($Promise, C)
- ? new PromiseCapability(C)
- : new GenericPromiseCapability(C);
- };
- var PromiseCapability = GenericPromiseCapability = function(C){
- var resolve, reject;
- this.promise = new C(function($$resolve, $$reject){
- if(resolve !== undefined || reject !== undefined)throw TypeError('Bad Promise constructor');
- resolve = $$resolve;
- reject = $$reject;
- });
- this.resolve = aFunction(resolve);
- this.reject = aFunction(reject);
- };
- var perform = function(exec){
- try {
- exec();
- } catch(e){
- return {error: e};
- }
- };
- var notify = function(promise, isReject){
- if(promise._n)return;
- promise._n = true;
- var chain = promise._c;
- microtask(function(){
- var value = promise._v
- , ok = promise._s == 1
- , i = 0;
- var run = function(reaction){
- var handler = ok ? reaction.ok : reaction.fail
- , resolve = reaction.resolve
- , reject = reaction.reject
- , domain = reaction.domain
- , result, then;
- try {
- if(handler){
- if(!ok){
- if(promise._h == 2)onHandleUnhandled(promise);
- promise._h = 1;
- }
- if(handler === true)result = value;
- else {
- if(domain)domain.enter();
- result = handler(value);
- if(domain)domain.exit();
- }
- if(result === reaction.promise){
- reject(TypeError('Promise-chain cycle'));
- } else if(then = isThenable(result)){
- then.call(result, resolve, reject);
- } else resolve(result);
- } else reject(value);
- } catch(e){
- reject(e);
- }
- };
- while(chain.length > i)run(chain[i++]); // variable length - can't use forEach
- promise._c = [];
- promise._n = false;
- if(isReject && !promise._h)onUnhandled(promise);
- });
- };
- var onUnhandled = function(promise){
- task.call(global, function(){
- var value = promise._v
- , abrupt, handler, console;
- if(isUnhandled(promise)){
- abrupt = perform(function(){
- if(isNode){
- process.emit('unhandledRejection', value, promise);
- } else if(handler = global.onunhandledrejection){
- handler({promise: promise, reason: value});
- } else if((console = global.console) && console.error){
- console.error('Unhandled promise rejection', value);
- }
- });
- // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
- promise._h = isNode || isUnhandled(promise) ? 2 : 1;
- } promise._a = undefined;
- if(abrupt)throw abrupt.error;
- });
- };
- var isUnhandled = function(promise){
- if(promise._h == 1)return false;
- var chain = promise._a || promise._c
- , i = 0
- , reaction;
- while(chain.length > i){
- reaction = chain[i++];
- if(reaction.fail || !isUnhandled(reaction.promise))return false;
- } return true;
- };
- var onHandleUnhandled = function(promise){
- task.call(global, function(){
- var handler;
- if(isNode){
- process.emit('rejectionHandled', promise);
- } else if(handler = global.onrejectionhandled){
- handler({promise: promise, reason: promise._v});
- }
- });
- };
- var $reject = function(value){
- var promise = this;
- if(promise._d)return;
- promise._d = true;
- promise = promise._w || promise; // unwrap
- promise._v = value;
- promise._s = 2;
- if(!promise._a)promise._a = promise._c.slice();
- notify(promise, true);
- };
- var $resolve = function(value){
- var promise = this
- , then;
- if(promise._d)return;
- promise._d = true;
- promise = promise._w || promise; // unwrap
- try {
- if(promise === value)throw TypeError("Promise can't be resolved itself");
- if(then = isThenable(value)){
- microtask(function(){
- var wrapper = {_w: promise, _d: false}; // wrap
- try {
- then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
- } catch(e){
- $reject.call(wrapper, e);
- }
- });
- } else {
- promise._v = value;
- promise._s = 1;
- notify(promise, false);
- }
- } catch(e){
- $reject.call({_w: promise, _d: false}, e); // wrap
- }
- };
- // constructor polyfill
- if(!USE_NATIVE){
- // 25.4.3.1 Promise(executor)
- $Promise = function Promise(executor){
- anInstance(this, $Promise, PROMISE, '_h');
- aFunction(executor);
- Internal.call(this);
- try {
- executor(ctx($resolve, this, 1), ctx($reject, this, 1));
- } catch(err){
- $reject.call(this, err);
- }
- };
- Internal = function Promise(executor){
- this._c = []; // <- awaiting reactions
- this._a = undefined; // <- checked in isUnhandled reactions
- this._s = 0; // <- state
- this._d = false; // <- done
- this._v = undefined; // <- value
- this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
- this._n = false; // <- notify
- };
- Internal.prototype = __webpack_require__(33)($Promise.prototype, {
- // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
- then: function then(onFulfilled, onRejected){
- var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
- reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
- reaction.fail = typeof onRejected == 'function' && onRejected;
- reaction.domain = isNode ? process.domain : undefined;
- this._c.push(reaction);
- if(this._a)this._a.push(reaction);
- if(this._s)notify(this, false);
- return reaction.promise;
- },
- // 25.4.5.1 Promise.prototype.catch(onRejected)
- 'catch': function(onRejected){
- return this.then(undefined, onRejected);
- }
- });
- PromiseCapability = function(){
- var promise = new Internal;
- this.promise = promise;
- this.resolve = ctx($resolve, promise, 1);
- this.reject = ctx($reject, promise, 1);
- };
- }
- $export($export.G + $export.W + $export.F * !USE_NATIVE, {Promise: $Promise});
- __webpack_require__(24)($Promise, PROMISE);
- __webpack_require__(69)(PROMISE);
- Wrapper = __webpack_require__(20)[PROMISE];
- // statics
- $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
- // 25.4.4.5 Promise.reject(r)
- reject: function reject(r){
- var capability = newPromiseCapability(this)
- , $$reject = capability.reject;
- $$reject(r);
- return capability.promise;
- }
- });
- $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
- // 25.4.4.6 Promise.resolve(x)
- resolve: function resolve(x){
- // instanceof instead of internal slot check because we should fix it without replacement native Promise core
- if(x instanceof $Promise && sameConstructor(x.constructor, this))return x;
- var capability = newPromiseCapability(this)
- , $$resolve = capability.resolve;
- $$resolve(x);
- return capability.promise;
- }
- });
- $export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(42)(function(iter){
- $Promise.all(iter)['catch'](empty);
- })), PROMISE, {
- // 25.4.4.1 Promise.all(iterable)
- all: function all(iterable){
- var C = this
- , capability = newPromiseCapability(C)
- , resolve = capability.resolve
- , reject = capability.reject;
- var abrupt = perform(function(){
- var values = []
- , index = 0
- , remaining = 1;
- forOf(iterable, false, function(promise){
- var $index = index++
- , alreadyCalled = false;
- values.push(undefined);
- remaining++;
- C.resolve(promise).then(function(value){
- if(alreadyCalled)return;
- alreadyCalled = true;
- values[$index] = value;
- --remaining || resolve(values);
- }, reject);
- });
- --remaining || resolve(values);
- });
- if(abrupt)reject(abrupt.error);
- return capability.promise;
- },
- // 25.4.4.4 Promise.race(iterable)
- race: function race(iterable){
- var C = this
- , capability = newPromiseCapability(C)
- , reject = capability.reject;
- var abrupt = perform(function(){
- forOf(iterable, false, function(promise){
- C.resolve(promise).then(capability.resolve, reject);
- });
- });
- if(abrupt)reject(abrupt.error);
- return capability.promise;
- }
- });
- /***/ }),
- /* 97 */
- /***/ (function(module, exports, __webpack_require__) {
- // 21.2.5.3 get RegExp.prototype.flags()
- if(__webpack_require__(6) && /./g.flags != 'g')__webpack_require__(5).f(RegExp.prototype, 'flags', {
- configurable: true,
- get: __webpack_require__(252)
- });
- /***/ }),
- /* 98 */
- /***/ (function(module, exports, __webpack_require__) {
- // @@match logic
- __webpack_require__(29)('match', 1, function(defined, MATCH, $match){
- // 21.1.3.11 String.prototype.match(regexp)
- return [function match(regexp){
- 'use strict';
- var O = defined(this)
- , fn = regexp == undefined ? undefined : regexp[MATCH];
- return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
- }, $match];
- });
- /***/ }),
- /* 99 */
- /***/ (function(module, exports, __webpack_require__) {
- // @@replace logic
- __webpack_require__(29)('replace', 2, function(defined, REPLACE, $replace){
- // 21.1.3.14 String.prototype.replace(searchValue, replaceValue)
- return [function replace(searchValue, replaceValue){
- 'use strict';
- var O = defined(this)
- , fn = searchValue == undefined ? undefined : searchValue[REPLACE];
- return fn !== undefined
- ? fn.call(searchValue, O, replaceValue)
- : $replace.call(String(O), searchValue, replaceValue);
- }, $replace];
- });
- /***/ }),
- /* 100 */
- /***/ (function(module, exports, __webpack_require__) {
- // @@search logic
- __webpack_require__(29)('search', 1, function(defined, SEARCH, $search){
- // 21.1.3.15 String.prototype.search(regexp)
- return [function search(regexp){
- 'use strict';
- var O = defined(this)
- , fn = regexp == undefined ? undefined : regexp[SEARCH];
- return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
- }, $search];
- });
- /***/ }),
- /* 101 */
- /***/ (function(module, exports, __webpack_require__) {
- // @@split logic
- __webpack_require__(29)('split', 2, function(defined, SPLIT, $split){
- 'use strict';
- var isRegExp = __webpack_require__(61)
- , _split = $split
- , $push = [].push
- , $SPLIT = 'split'
- , LENGTH = 'length'
- , LAST_INDEX = 'lastIndex';
- if(
- 'abbc'[$SPLIT](/(b)*/)[1] == 'c' ||
- 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 ||
- 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 ||
- '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 ||
- '.'[$SPLIT](/()()/)[LENGTH] > 1 ||
- ''[$SPLIT](/.?/)[LENGTH]
- ){
- var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group
- // based on es5-shim implementation, need to rework it
- $split = function(separator, limit){
- var string = String(this);
- if(separator === undefined && limit === 0)return [];
- // If `separator` is not a regex, use native split
- if(!isRegExp(separator))return _split.call(string, separator, limit);
- var output = [];
- var flags = (separator.ignoreCase ? 'i' : '') +
- (separator.multiline ? 'm' : '') +
- (separator.unicode ? 'u' : '') +
- (separator.sticky ? 'y' : '');
- var lastLastIndex = 0;
- var splitLimit = limit === undefined ? 4294967295 : limit >>> 0;
- // Make `global` and avoid `lastIndex` issues by working with a copy
- var separatorCopy = new RegExp(separator.source, flags + 'g');
- var separator2, match, lastIndex, lastLength, i;
- // Doesn't need flags gy, but they don't hurt
- if(!NPCG)separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
- while(match = separatorCopy.exec(string)){
- // `separatorCopy.lastIndex` is not reliable cross-browser
- lastIndex = match.index + match[0][LENGTH];
- if(lastIndex > lastLastIndex){
- output.push(string.slice(lastLastIndex, match.index));
- // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG
- if(!NPCG && match[LENGTH] > 1)match[0].replace(separator2, function(){
- for(i = 1; i < arguments[LENGTH] - 2; i++)if(arguments[i] === undefined)match[i] = undefined;
- });
- if(match[LENGTH] > 1 && match.index < string[LENGTH])$push.apply(output, match.slice(1));
- lastLength = match[0][LENGTH];
- lastLastIndex = lastIndex;
- if(output[LENGTH] >= splitLimit)break;
- }
- if(separatorCopy[LAST_INDEX] === match.index)separatorCopy[LAST_INDEX]++; // Avoid an infinite loop
- }
- if(lastLastIndex === string[LENGTH]){
- if(lastLength || !separatorCopy.test(''))output.push('');
- } else output.push(string.slice(lastLastIndex));
- return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;
- };
- // Chakra, V8
- } else if('0'[$SPLIT](undefined, 0)[LENGTH]){
- $split = function(separator, limit){
- return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit);
- };
- }
- // 21.1.3.17 String.prototype.split(separator, limit)
- return [function split(separator, limit){
- var O = defined(this)
- , fn = separator == undefined ? undefined : separator[SPLIT];
- return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit);
- }, $split];
- });
- /***/ }),
- /* 102 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var strong = __webpack_require__(54);
- // 23.2 Set Objects
- module.exports = __webpack_require__(28)('Set', function(get){
- return function Set(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
- }, {
- // 23.2.3.1 Set.prototype.add(value)
- add: function add(value){
- return strong.def(this, value = value === 0 ? 0 : value, value);
- }
- }, strong);
- /***/ }),
- /* 103 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var $export = __webpack_require__(0)
- , $at = __webpack_require__(264)(false);
- $export($export.P, 'String', {
- // 21.1.3.3 String.prototype.codePointAt(pos)
- codePointAt: function codePointAt(pos){
- return $at(this, pos);
- }
- });
- /***/ }),
- /* 104 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
- var $export = __webpack_require__(0)
- , toLength = __webpack_require__(9)
- , context = __webpack_require__(48)
- , ENDS_WITH = 'endsWith'
- , $endsWith = ''[ENDS_WITH];
- $export($export.P + $export.F * __webpack_require__(40)(ENDS_WITH), 'String', {
- endsWith: function endsWith(searchString /*, endPosition = @length */){
- var that = context(this, searchString, ENDS_WITH)
- , endPosition = arguments.length > 1 ? arguments[1] : undefined
- , len = toLength(that.length)
- , end = endPosition === undefined ? len : Math.min(toLength(endPosition), len)
- , search = String(searchString);
- return $endsWith
- ? $endsWith.call(that, search, end)
- : that.slice(end - search.length, end) === search;
- }
- });
- /***/ }),
- /* 105 */
- /***/ (function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0)
- , toIndex = __webpack_require__(34)
- , fromCharCode = String.fromCharCode
- , $fromCodePoint = String.fromCodePoint;
- // length should be 1, old FF problem
- $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
- // 21.1.2.2 String.fromCodePoint(...codePoints)
- fromCodePoint: function fromCodePoint(x){ // eslint-disable-line no-unused-vars
- var res = []
- , aLen = arguments.length
- , i = 0
- , code;
- while(aLen > i){
- code = +arguments[i++];
- if(toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point');
- res.push(code < 0x10000
- ? fromCharCode(code)
- : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
- );
- } return res.join('');
- }
- });
- /***/ }),
- /* 106 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // 21.1.3.7 String.prototype.includes(searchString, position = 0)
- var $export = __webpack_require__(0)
- , context = __webpack_require__(48)
- , INCLUDES = 'includes';
- $export($export.P + $export.F * __webpack_require__(40)(INCLUDES), 'String', {
- includes: function includes(searchString /*, position = 0 */){
- return !!~context(this, searchString, INCLUDES)
- .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- /***/ }),
- /* 107 */
- /***/ (function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0)
- , toIObject = __webpack_require__(8)
- , toLength = __webpack_require__(9);
- $export($export.S, 'String', {
- // 21.1.2.4 String.raw(callSite, ...substitutions)
- raw: function raw(callSite){
- var tpl = toIObject(callSite.raw)
- , len = toLength(tpl.length)
- , aLen = arguments.length
- , res = []
- , i = 0;
- while(len > i){
- res.push(String(tpl[i++]));
- if(i < aLen)res.push(String(arguments[i]));
- } return res.join('');
- }
- });
- /***/ }),
- /* 108 */
- /***/ (function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0);
- $export($export.P, 'String', {
- // 21.1.3.13 String.prototype.repeat(count)
- repeat: __webpack_require__(71)
- });
- /***/ }),
- /* 109 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // 21.1.3.18 String.prototype.startsWith(searchString [, position ])
- var $export = __webpack_require__(0)
- , toLength = __webpack_require__(9)
- , context = __webpack_require__(48)
- , STARTS_WITH = 'startsWith'
- , $startsWith = ''[STARTS_WITH];
- $export($export.P + $export.F * __webpack_require__(40)(STARTS_WITH), 'String', {
- startsWith: function startsWith(searchString /*, position = 0 */){
- var that = context(this, searchString, STARTS_WITH)
- , index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length))
- , search = String(searchString);
- return $startsWith
- ? $startsWith.call(that, search, index)
- : that.slice(index, index + search.length) === search;
- }
- });
- /***/ }),
- /* 110 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // ECMAScript 6 symbols shim
- var global = __webpack_require__(2)
- , has = __webpack_require__(7)
- , DESCRIPTORS = __webpack_require__(6)
- , $export = __webpack_require__(0)
- , redefine = __webpack_require__(14)
- , META = __webpack_require__(22).KEY
- , $fails = __webpack_require__(12)
- , shared = __webpack_require__(47)
- , setToStringTag = __webpack_require__(24)
- , uid = __webpack_require__(25)
- , wks = __webpack_require__(1)
- , wksExt = __webpack_require__(72)
- , wksDefine = __webpack_require__(265)
- , keyOf = __webpack_require__(256)
- , enumKeys = __webpack_require__(251)
- , isArray = __webpack_require__(59)
- , anObject = __webpack_require__(4)
- , toIObject = __webpack_require__(8)
- , toPrimitive = __webpack_require__(50)
- , createDesc = __webpack_require__(18)
- , _create = __webpack_require__(43)
- , gOPNExt = __webpack_require__(259)
- , $GOPD = __webpack_require__(44)
- , $DP = __webpack_require__(5)
- , $keys = __webpack_require__(17)
- , gOPD = $GOPD.f
- , dP = $DP.f
- , gOPN = gOPNExt.f
- , $Symbol = global.Symbol
- , $JSON = global.JSON
- , _stringify = $JSON && $JSON.stringify
- , PROTOTYPE = 'prototype'
- , HIDDEN = wks('_hidden')
- , TO_PRIMITIVE = wks('toPrimitive')
- , isEnum = {}.propertyIsEnumerable
- , SymbolRegistry = shared('symbol-registry')
- , AllSymbols = shared('symbols')
- , OPSymbols = shared('op-symbols')
- , ObjectProto = Object[PROTOTYPE]
- , USE_NATIVE = typeof $Symbol == 'function'
- , QObject = global.QObject;
- // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
- var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
- // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
- var setSymbolDesc = DESCRIPTORS && $fails(function(){
- return _create(dP({}, 'a', {
- get: function(){ return dP(this, 'a', {value: 7}).a; }
- })).a != 7;
- }) ? function(it, key, D){
- var protoDesc = gOPD(ObjectProto, key);
- if(protoDesc)delete ObjectProto[key];
- dP(it, key, D);
- if(protoDesc && it !== ObjectProto)dP(ObjectProto, key, protoDesc);
- } : dP;
- var wrap = function(tag){
- var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
- sym._k = tag;
- return sym;
- };
- var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function(it){
- return typeof it == 'symbol';
- } : function(it){
- return it instanceof $Symbol;
- };
- var $defineProperty = function defineProperty(it, key, D){
- if(it === ObjectProto)$defineProperty(OPSymbols, key, D);
- anObject(it);
- key = toPrimitive(key, true);
- anObject(D);
- if(has(AllSymbols, key)){
- if(!D.enumerable){
- if(!has(it, HIDDEN))dP(it, HIDDEN, createDesc(1, {}));
- it[HIDDEN][key] = true;
- } else {
- if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;
- D = _create(D, {enumerable: createDesc(0, false)});
- } return setSymbolDesc(it, key, D);
- } return dP(it, key, D);
- };
- var $defineProperties = function defineProperties(it, P){
- anObject(it);
- var keys = enumKeys(P = toIObject(P))
- , i = 0
- , l = keys.length
- , key;
- while(l > i)$defineProperty(it, key = keys[i++], P[key]);
- return it;
- };
- var $create = function create(it, P){
- return P === undefined ? _create(it) : $defineProperties(_create(it), P);
- };
- var $propertyIsEnumerable = function propertyIsEnumerable(key){
- var E = isEnum.call(this, key = toPrimitive(key, true));
- if(this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return false;
- return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
- };
- var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){
- it = toIObject(it);
- key = toPrimitive(key, true);
- if(it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return;
- var D = gOPD(it, key);
- if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true;
- return D;
- };
- var $getOwnPropertyNames = function getOwnPropertyNames(it){
- var names = gOPN(toIObject(it))
- , result = []
- , i = 0
- , key;
- while(names.length > i){
- if(!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META)result.push(key);
- } return result;
- };
- var $getOwnPropertySymbols = function getOwnPropertySymbols(it){
- var IS_OP = it === ObjectProto
- , names = gOPN(IS_OP ? OPSymbols : toIObject(it))
- , result = []
- , i = 0
- , key;
- while(names.length > i){
- if(has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true))result.push(AllSymbols[key]);
- } return result;
- };
- // 19.4.1.1 Symbol([description])
- if(!USE_NATIVE){
- $Symbol = function Symbol(){
- if(this instanceof $Symbol)throw TypeError('Symbol is not a constructor!');
- var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
- var $set = function(value){
- if(this === ObjectProto)$set.call(OPSymbols, value);
- if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;
- setSymbolDesc(this, tag, createDesc(1, value));
- };
- if(DESCRIPTORS && setter)setSymbolDesc(ObjectProto, tag, {configurable: true, set: $set});
- return wrap(tag);
- };
- redefine($Symbol[PROTOTYPE], 'toString', function toString(){
- return this._k;
- });
- $GOPD.f = $getOwnPropertyDescriptor;
- $DP.f = $defineProperty;
- __webpack_require__(45).f = gOPNExt.f = $getOwnPropertyNames;
- __webpack_require__(23).f = $propertyIsEnumerable;
- __webpack_require__(32).f = $getOwnPropertySymbols;
- if(DESCRIPTORS && !__webpack_require__(31)){
- redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
- }
- wksExt.f = function(name){
- return wrap(wks(name));
- }
- }
- $export($export.G + $export.W + $export.F * !USE_NATIVE, {Symbol: $Symbol});
- for(var symbols = (
- // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
- 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
- ).split(','), i = 0; symbols.length > i; )wks(symbols[i++]);
- for(var symbols = $keys(wks.store), i = 0; symbols.length > i; )wksDefine(symbols[i++]);
- $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
- // 19.4.2.1 Symbol.for(key)
- 'for': function(key){
- return has(SymbolRegistry, key += '')
- ? SymbolRegistry[key]
- : SymbolRegistry[key] = $Symbol(key);
- },
- // 19.4.2.5 Symbol.keyFor(sym)
- keyFor: function keyFor(key){
- if(isSymbol(key))return keyOf(SymbolRegistry, key);
- throw TypeError(key + ' is not a symbol!');
- },
- useSetter: function(){ setter = true; },
- useSimple: function(){ setter = false; }
- });
- $export($export.S + $export.F * !USE_NATIVE, 'Object', {
- // 19.1.2.2 Object.create(O [, Properties])
- create: $create,
- // 19.1.2.4 Object.defineProperty(O, P, Attributes)
- defineProperty: $defineProperty,
- // 19.1.2.3 Object.defineProperties(O, Properties)
- defineProperties: $defineProperties,
- // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
- getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
- // 19.1.2.7 Object.getOwnPropertyNames(O)
- getOwnPropertyNames: $getOwnPropertyNames,
- // 19.1.2.8 Object.getOwnPropertySymbols(O)
- getOwnPropertySymbols: $getOwnPropertySymbols
- });
- // 24.3.2 JSON.stringify(value [, replacer [, space]])
- $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function(){
- var S = $Symbol();
- // MS Edge converts symbol values to JSON as {}
- // WebKit converts symbol values to JSON as null
- // V8 throws on boxed symbols
- return _stringify([S]) != '[null]' || _stringify({a: S}) != '{}' || _stringify(Object(S)) != '{}';
- })), 'JSON', {
- stringify: function stringify(it){
- if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined
- var args = [it]
- , i = 1
- , replacer, $replacer;
- while(arguments.length > i)args.push(arguments[i++]);
- replacer = args[1];
- if(typeof replacer == 'function')$replacer = replacer;
- if($replacer || !isArray(replacer))replacer = function(key, value){
- if($replacer)value = $replacer.call(this, key, value);
- if(!isSymbol(value))return value;
- };
- args[1] = replacer;
- return _stringify.apply($JSON, args);
- }
- });
- // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
- $Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(13)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
- // 19.4.3.5 Symbol.prototype[@@toStringTag]
- setToStringTag($Symbol, 'Symbol');
- // 20.2.1.9 Math[@@toStringTag]
- setToStringTag(Math, 'Math', true);
- // 24.3.3 JSON[@@toStringTag]
- setToStringTag(global.JSON, 'JSON', true);
- /***/ }),
- /* 111 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var each = __webpack_require__(27)(0)
- , redefine = __webpack_require__(14)
- , meta = __webpack_require__(22)
- , assign = __webpack_require__(65)
- , weak = __webpack_require__(55)
- , isObject = __webpack_require__(3)
- , getWeak = meta.getWeak
- , isExtensible = Object.isExtensible
- , uncaughtFrozenStore = weak.ufstore
- , tmp = {}
- , InternalMap;
- var wrapper = function(get){
- return function WeakMap(){
- return get(this, arguments.length > 0 ? arguments[0] : undefined);
- };
- };
- var methods = {
- // 23.3.3.3 WeakMap.prototype.get(key)
- get: function get(key){
- if(isObject(key)){
- var data = getWeak(key);
- if(data === true)return uncaughtFrozenStore(this).get(key);
- return data ? data[this._i] : undefined;
- }
- },
- // 23.3.3.5 WeakMap.prototype.set(key, value)
- set: function set(key, value){
- return weak.def(this, key, value);
- }
- };
- // 23.3 WeakMap Objects
- var $WeakMap = module.exports = __webpack_require__(28)('WeakMap', wrapper, methods, weak, true, true);
- // IE11 WeakMap frozen keys fix
- if(new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7){
- InternalMap = weak.getConstructor(wrapper);
- assign(InternalMap.prototype, methods);
- meta.NEED = true;
- each(['delete', 'has', 'get', 'set'], function(key){
- var proto = $WeakMap.prototype
- , method = proto[key];
- redefine(proto, key, function(a, b){
- // store frozen objects on internal weakmap shim
- if(isObject(a) && !isExtensible(a)){
- if(!this._f)this._f = new InternalMap;
- var result = this._f[key](a, b);
- return key == 'set' ? this : result;
- // store all the rest on native weakmap
- } return method.call(this, a, b);
- });
- });
- }
- /***/ }),
- /* 112 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var weak = __webpack_require__(55);
- // 23.4 WeakSet Objects
- __webpack_require__(28)('WeakSet', function(get){
- return function WeakSet(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
- }, {
- // 23.4.3.1 WeakSet.prototype.add(value)
- add: function add(value){
- return weak.def(this, value, true);
- }
- }, weak, false, true);
- /***/ }),
- /* 113 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // https://github.com/tc39/Array.prototype.includes
- var $export = __webpack_require__(0)
- , $includes = __webpack_require__(52)(true);
- $export($export.P, 'Array', {
- includes: function includes(el /*, fromIndex = 0 */){
- return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
- }
- });
- __webpack_require__(15)('includes');
- /***/ }),
- /* 114 */
- /***/ (function(module, exports, __webpack_require__) {
- // https://github.com/tc39/proposal-object-values-entries
- var $export = __webpack_require__(0)
- , $entries = __webpack_require__(67)(true);
- $export($export.S, 'Object', {
- entries: function entries(it){
- return $entries(it);
- }
- });
- /***/ }),
- /* 115 */
- /***/ (function(module, exports, __webpack_require__) {
- // https://github.com/tc39/proposal-object-getownpropertydescriptors
- var $export = __webpack_require__(0)
- , ownKeys = __webpack_require__(261)
- , toIObject = __webpack_require__(8)
- , gOPD = __webpack_require__(44)
- , createProperty = __webpack_require__(37);
- $export($export.S, 'Object', {
- getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object){
- var O = toIObject(object)
- , getDesc = gOPD.f
- , keys = ownKeys(O)
- , result = {}
- , i = 0
- , key;
- while(keys.length > i)createProperty(result, key = keys[i++], getDesc(O, key));
- return result;
- }
- });
- /***/ }),
- /* 116 */
- /***/ (function(module, exports, __webpack_require__) {
- // https://github.com/tc39/proposal-object-values-entries
- var $export = __webpack_require__(0)
- , $values = __webpack_require__(67)(false);
- $export($export.S, 'Object', {
- values: function values(it){
- return $values(it);
- }
- });
- /***/ }),
- /* 117 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // https://github.com/tc39/proposal-string-pad-start-end
- var $export = __webpack_require__(0)
- , $pad = __webpack_require__(70);
- $export($export.P, 'String', {
- padEnd: function padEnd(maxLength /*, fillString = ' ' */){
- return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);
- }
- });
- /***/ }),
- /* 118 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // https://github.com/tc39/proposal-string-pad-start-end
- var $export = __webpack_require__(0)
- , $pad = __webpack_require__(70);
- $export($export.P, 'String', {
- padStart: function padStart(maxLength /*, fillString = ' ' */){
- return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);
- }
- });
- /***/ }),
- /* 119 */
- /***/ (function(module, exports, __webpack_require__) {
- var $iterators = __webpack_require__(51)
- , redefine = __webpack_require__(14)
- , global = __webpack_require__(2)
- , hide = __webpack_require__(13)
- , Iterators = __webpack_require__(21)
- , wks = __webpack_require__(1)
- , ITERATOR = wks('iterator')
- , TO_STRING_TAG = wks('toStringTag')
- , ArrayValues = Iterators.Array;
- for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){
- var NAME = collections[i]
- , Collection = global[NAME]
- , proto = Collection && Collection.prototype
- , key;
- if(proto){
- if(!proto[ITERATOR])hide(proto, ITERATOR, ArrayValues);
- if(!proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME);
- Iterators[NAME] = ArrayValues;
- for(key in $iterators)if(!proto[key])redefine(proto, key, $iterators[key], true);
- }
- }
- /***/ }),
- /* 120 */
- /***/ (function(module, exports, __webpack_require__) {
- var $export = __webpack_require__(0)
- , $task = __webpack_require__(49);
- $export($export.G + $export.B, {
- setImmediate: $task.set,
- clearImmediate: $task.clear
- });
- /***/ }),
- /* 121 */
- /***/ (function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(global) {var co = __webpack_require__(246),
- isGeneratorFn = __webpack_require__(266).fn;
- var DEFAULT_METHODS = [
- 'afterAll',
- 'afterEach',
- 'beforeAll',
- 'beforeEach',
- 'it', 'fit', //'xit',
- ];
- var EXPECTS_NAME = ['it', 'fit', 'xit'];
- var originalMethods = {},
- overrideMethods, installed;
- module.exports = function jasmineCo(userFn) {
- return wrapFn(userFn);
- };
- module.exports.install = function install() {
- (overrideMethods || DEFAULT_METHODS).forEach(function(fname) {
- coifyJasmineFn(fname);
- });
- installed = true;
- };
- module.exports.uninstall = function uninstall() {
- Object.keys(originalMethods).forEach(function(key) {
- global[key] = originalMethods[key];
- });
- originalMethods = {};
- installed = false;
- };
- module.exports.isInstalled = function isInstalled() {
- return installed;
- };
- module.exports.setOverrideMethods = function setOverrideMethods(methods) {
- overrideMethods = Array.isArray(methods) ? methods : DEFAULT_METHODS;
- };
- function coifyJasmineFn(fname) {
- // don't process methods that don't exist globally or have already been overridden
- if (!global[fname] || originalMethods[fname]) { return; }
- var origFn = originalMethods[fname] = global[fname];
- global[fname] = wrapFn(origFn, EXPECTS_NAME.indexOf(fname) !== -1);
- }
- function wrapFn(origFn, expectsName) {
- return function() {
- var userFn = expectsName ? arguments[1] : arguments[0];
- var restParams = [].slice.call(arguments, expectsName ? 2 : 1);
- var args;
- if (isGeneratorFn(userFn)) {
- // if the user method is a generator:
- // 1. call it with the correct `this` context object
- // 2. wrap it in a co function which fails the spec if an exception is
- // encountered and notifies jasmine that the spec is done when the co
- // promise settles
- args = [function(done) {
- return co(userFn.bind(this)).then(done, done.fail);
- }];
- if (expectsName) { args.unshift(arguments[0]); }
- if (restParams.length) { args.push.apply(args, restParams); }
- return origFn.apply(null, args);
- } else if (userFn && !userFn.length) {
- // if the user method is a standard function that doesn't expect to be asynchronous
- // (i.e. it doesn't take `done` as a parameter), wrap it with a function that *is*
- // asynchronous and retrofit it to support returning a promise from the function
- args = [function(done) {
- var result = userFn.call(this);
- if (!(result && typeof result.then === 'function')) {
- done();
- return result;
- } else {
- result.then(done, done.fail);
- }
- }];
- if (expectsName) { args.unshift(arguments[0]); }
- if (restParams.length) { args.push.apply(args, restParams); }
- return origFn.apply(null, args);
- } else {
- // if the user method is already asynchronous, just call the standard jasmine method
- // and let the user method take care of itself
- return origFn.apply(null, arguments);
- }
- };
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(74)))
- /***/ }),
- /* 122 */
- /***/ (function(module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function(global) {/**
- * Copyright (c) 2014, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
- * additional grant of patent rights can be found in the PATENTS file in
- * the same directory.
- */
- !(function(global) {
- "use strict";
- var Op = Object.prototype;
- var hasOwn = Op.hasOwnProperty;
- var undefined; // More compressible than void 0.
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
- var inModule = typeof module === "object";
- var runtime = global.regeneratorRuntime;
- if (runtime) {
- if (inModule) {
- // If regeneratorRuntime is defined globally and we're in a module,
- // make the exports object identical to regeneratorRuntime.
- module.exports = runtime;
- }
- // Don't bother evaluating the rest of this file if the runtime was
- // already defined globally.
- return;
- }
- // Define the runtime globally (as expected by generated code) as either
- // module.exports (if we're in a module) or a new, empty object.
- runtime = global.regeneratorRuntime = inModule ? module.exports : {};
- function wrap(innerFn, outerFn, self, tryLocsList) {
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
- var generator = Object.create(protoGenerator.prototype);
- var context = new Context(tryLocsList || []);
- // The ._invoke method unifies the implementations of the .next,
- // .throw, and .return methods.
- generator._invoke = makeInvokeMethod(innerFn, self, context);
- return generator;
- }
- runtime.wrap = wrap;
- // Try/catch helper to minimize deoptimizations. Returns a completion
- // record like context.tryEntries[i].completion. This interface could
- // have been (and was previously) designed to take a closure to be
- // invoked without arguments, but in all the cases we care about we
- // already have an existing method we want to call, so there's no need
- // to create a new function object. We can even get away with assuming
- // the method takes exactly one argument, since that happens to be true
- // in every case, so we don't have to touch the arguments object. The
- // only additional allocation required is the completion record, which
- // has a stable shape and so hopefully should be cheap to allocate.
- function tryCatch(fn, obj, arg) {
- try {
- return { type: "normal", arg: fn.call(obj, arg) };
- } catch (err) {
- return { type: "throw", arg: err };
- }
- }
- var GenStateSuspendedStart = "suspendedStart";
- var GenStateSuspendedYield = "suspendedYield";
- var GenStateExecuting = "executing";
- var GenStateCompleted = "completed";
- // Returning this object from the innerFn has the same effect as
- // breaking out of the dispatch switch statement.
- var ContinueSentinel = {};
- // Dummy constructor functions that we use as the .constructor and
- // .constructor.prototype properties for functions that return Generator
- // objects. For full spec compliance, you may wish to configure your
- // minifier not to mangle the names of these two functions.
- function Generator() {}
- function GeneratorFunction() {}
- function GeneratorFunctionPrototype() {}
- // This is a polyfill for %IteratorPrototype% for environments that
- // don't natively support it.
- var IteratorPrototype = {};
- IteratorPrototype[iteratorSymbol] = function () {
- return this;
- };
- var getProto = Object.getPrototypeOf;
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
- if (NativeIteratorPrototype &&
- NativeIteratorPrototype !== Op &&
- hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
- // This environment has a native %IteratorPrototype%; use it instead
- // of the polyfill.
- IteratorPrototype = NativeIteratorPrototype;
- }
- var Gp = GeneratorFunctionPrototype.prototype =
- Generator.prototype = Object.create(IteratorPrototype);
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
- GeneratorFunctionPrototype[toStringTagSymbol] =
- GeneratorFunction.displayName = "GeneratorFunction";
- // Helper for defining the .next, .throw, and .return methods of the
- // Iterator interface in terms of a single ._invoke method.
- function defineIteratorMethods(prototype) {
- ["next", "throw", "return"].forEach(function(method) {
- prototype[method] = function(arg) {
- return this._invoke(method, arg);
- };
- });
- }
- runtime.isGeneratorFunction = function(genFun) {
- var ctor = typeof genFun === "function" && genFun.constructor;
- return ctor
- ? ctor === GeneratorFunction ||
- // For the native GeneratorFunction constructor, the best we can
- // do is to check its .name property.
- (ctor.displayName || ctor.name) === "GeneratorFunction"
- : false;
- };
- runtime.mark = function(genFun) {
- if (Object.setPrototypeOf) {
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
- } else {
- genFun.__proto__ = GeneratorFunctionPrototype;
- if (!(toStringTagSymbol in genFun)) {
- genFun[toStringTagSymbol] = "GeneratorFunction";
- }
- }
- genFun.prototype = Object.create(Gp);
- return genFun;
- };
- // Within the body of any async function, `await x` is transformed to
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
- // meant to be awaited.
- runtime.awrap = function(arg) {
- return { __await: arg };
- };
- function AsyncIterator(generator) {
- function invoke(method, arg, resolve, reject) {
- var record = tryCatch(generator[method], generator, arg);
- if (record.type === "throw") {
- reject(record.arg);
- } else {
- var result = record.arg;
- var value = result.value;
- if (value &&
- typeof value === "object" &&
- hasOwn.call(value, "__await")) {
- return Promise.resolve(value.__await).then(function(value) {
- invoke("next", value, resolve, reject);
- }, function(err) {
- invoke("throw", err, resolve, reject);
- });
- }
- return Promise.resolve(value).then(function(unwrapped) {
- // When a yielded Promise is resolved, its final value becomes
- // the .value of the Promise<{value,done}> result for the
- // current iteration. If the Promise is rejected, however, the
- // result for this iteration will be rejected with the same
- // reason. Note that rejections of yielded Promises are not
- // thrown back into the generator function, as is the case
- // when an awaited Promise is rejected. This difference in
- // behavior between yield and await is important, because it
- // allows the consumer to decide what to do with the yielded
- // rejection (swallow it and continue, manually .throw it back
- // into the generator, abandon iteration, whatever). With
- // await, by contrast, there is no opportunity to examine the
- // rejection reason outside the generator function, so the
- // only option is to throw it from the await expression, and
- // let the generator function handle the exception.
- result.value = unwrapped;
- resolve(result);
- }, reject);
- }
- }
- if (typeof global.process === "object" && global.process.domain) {
- invoke = global.process.domain.bind(invoke);
- }
- var previousPromise;
- function enqueue(method, arg) {
- function callInvokeWithMethodAndArg() {
- return new Promise(function(resolve, reject) {
- invoke(method, arg, resolve, reject);
- });
- }
- return previousPromise =
- // If enqueue has been called before, then we want to wait until
- // all previous Promises have been resolved before calling invoke,
- // so that results are always delivered in the correct order. If
- // enqueue has not been called before, then it is important to
- // call invoke immediately, without waiting on a callback to fire,
- // so that the async generator function has the opportunity to do
- // any necessary setup in a predictable way. This predictability
- // is why the Promise constructor synchronously invokes its
- // executor callback, and why async functions synchronously
- // execute code before the first await. Since we implement simple
- // async functions in terms of async generators, it is especially
- // important to get this right, even though it requires care.
- previousPromise ? previousPromise.then(
- callInvokeWithMethodAndArg,
- // Avoid propagating failures to Promises returned by later
- // invocations of the iterator.
- callInvokeWithMethodAndArg
- ) : callInvokeWithMethodAndArg();
- }
- // Define the unified helper method that is used to implement .next,
- // .throw, and .return (see defineIteratorMethods).
- this._invoke = enqueue;
- }
- defineIteratorMethods(AsyncIterator.prototype);
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
- return this;
- };
- runtime.AsyncIterator = AsyncIterator;
- // Note that simple async functions are implemented on top of
- // AsyncIterator objects; they just return a Promise for the value of
- // the final result produced by the iterator.
- runtime.async = function(innerFn, outerFn, self, tryLocsList) {
- var iter = new AsyncIterator(
- wrap(innerFn, outerFn, self, tryLocsList)
- );
- return runtime.isGeneratorFunction(outerFn)
- ? iter // If outerFn is a generator, return the full iterator.
- : iter.next().then(function(result) {
- return result.done ? result.value : iter.next();
- });
- };
- function makeInvokeMethod(innerFn, self, context) {
- var state = GenStateSuspendedStart;
- return function invoke(method, arg) {
- if (state === GenStateExecuting) {
- throw new Error("Generator is already running");
- }
- if (state === GenStateCompleted) {
- if (method === "throw") {
- throw arg;
- }
- // Be forgiving, per 25.3.3.3.3 of the spec:
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
- return doneResult();
- }
- context.method = method;
- context.arg = arg;
- while (true) {
- var delegate = context.delegate;
- if (delegate) {
- var delegateResult = maybeInvokeDelegate(delegate, context);
- if (delegateResult) {
- if (delegateResult === ContinueSentinel) continue;
- return delegateResult;
- }
- }
- if (context.method === "next") {
- // Setting context._sent for legacy support of Babel's
- // function.sent implementation.
- context.sent = context._sent = context.arg;
- } else if (context.method === "throw") {
- if (state === GenStateSuspendedStart) {
- state = GenStateCompleted;
- throw context.arg;
- }
- context.dispatchException(context.arg);
- } else if (context.method === "return") {
- context.abrupt("return", context.arg);
- }
- state = GenStateExecuting;
- var record = tryCatch(innerFn, self, context);
- if (record.type === "normal") {
- // If an exception is thrown from innerFn, we leave state ===
- // GenStateExecuting and loop back for another invocation.
- state = context.done
- ? GenStateCompleted
- : GenStateSuspendedYield;
- if (record.arg === ContinueSentinel) {
- continue;
- }
- return {
- value: record.arg,
- done: context.done
- };
- } else if (record.type === "throw") {
- state = GenStateCompleted;
- // Dispatch the exception by looping back around to the
- // context.dispatchException(context.arg) call above.
- context.method = "throw";
- context.arg = record.arg;
- }
- }
- };
- }
- // Call delegate.iterator[context.method](context.arg) and handle the
- // result, either by returning a { value, done } result from the
- // delegate iterator, or by modifying context.method and context.arg,
- // setting context.delegate to null, and returning the ContinueSentinel.
- function maybeInvokeDelegate(delegate, context) {
- var method = delegate.iterator[context.method];
- if (method === undefined) {
- // A .throw or .return when the delegate iterator has no .throw
- // method always terminates the yield* loop.
- context.delegate = null;
- if (context.method === "throw") {
- if (delegate.iterator.return) {
- // If the delegate iterator has a return method, give it a
- // chance to clean up.
- context.method = "return";
- context.arg = undefined;
- maybeInvokeDelegate(delegate, context);
- if (context.method === "throw") {
- // If maybeInvokeDelegate(context) changed context.method from
- // "return" to "throw", let that override the TypeError below.
- return ContinueSentinel;
- }
- }
- context.method = "throw";
- context.arg = new TypeError(
- "The iterator does not provide a 'throw' method");
- }
- return ContinueSentinel;
- }
- var record = tryCatch(method, delegate.iterator, context.arg);
- if (record.type === "throw") {
- context.method = "throw";
- context.arg = record.arg;
- context.delegate = null;
- return ContinueSentinel;
- }
- var info = record.arg;
- if (! info) {
- context.method = "throw";
- context.arg = new TypeError("iterator result is not an object");
- context.delegate = null;
- return ContinueSentinel;
- }
- if (info.done) {
- // Assign the result of the finished delegate to the temporary
- // variable specified by delegate.resultName (see delegateYield).
- context[delegate.resultName] = info.value;
- // Resume execution at the desired location (see delegateYield).
- context.next = delegate.nextLoc;
- // If context.method was "throw" but the delegate handled the
- // exception, let the outer generator proceed normally. If
- // context.method was "next", forget context.arg since it has been
- // "consumed" by the delegate iterator. If context.method was
- // "return", allow the original .return call to continue in the
- // outer generator.
- if (context.method !== "return") {
- context.method = "next";
- context.arg = undefined;
- }
- } else {
- // Re-yield the result returned by the delegate method.
- return info;
- }
- // The delegate iterator is finished, so forget it and continue with
- // the outer generator.
- context.delegate = null;
- return ContinueSentinel;
- }
- // Define Generator.prototype.{next,throw,return} in terms of the
- // unified ._invoke helper method.
- defineIteratorMethods(Gp);
- Gp[toStringTagSymbol] = "Generator";
- // A Generator should always return itself as the iterator object when the
- // @@iterator function is called on it. Some browsers' implementations of the
- // iterator prototype chain incorrectly implement this, causing the Generator
- // object to not be returned from this call. This ensures that doesn't happen.
- // See https://github.com/facebook/regenerator/issues/274 for more details.
- Gp[iteratorSymbol] = function() {
- return this;
- };
- Gp.toString = function() {
- return "[object Generator]";
- };
- function pushTryEntry(locs) {
- var entry = { tryLoc: locs[0] };
- if (1 in locs) {
- entry.catchLoc = locs[1];
- }
- if (2 in locs) {
- entry.finallyLoc = locs[2];
- entry.afterLoc = locs[3];
- }
- this.tryEntries.push(entry);
- }
- function resetTryEntry(entry) {
- var record = entry.completion || {};
- record.type = "normal";
- delete record.arg;
- entry.completion = record;
- }
- function Context(tryLocsList) {
- // The root entry object (effectively a try statement without a catch
- // or a finally block) gives us a place to store values thrown from
- // locations where there is no enclosing try statement.
- this.tryEntries = [{ tryLoc: "root" }];
- tryLocsList.forEach(pushTryEntry, this);
- this.reset(true);
- }
- runtime.keys = function(object) {
- var keys = [];
- for (var key in object) {
- keys.push(key);
- }
- keys.reverse();
- // Rather than returning an object with a next method, we keep
- // things simple and return the next function itself.
- return function next() {
- while (keys.length) {
- var key = keys.pop();
- if (key in object) {
- next.value = key;
- next.done = false;
- return next;
- }
- }
- // To avoid creating an additional object, we just hang the .value
- // and .done properties off the next function object itself. This
- // also ensures that the minifier will not anonymize the function.
- next.done = true;
- return next;
- };
- };
- function values(iterable) {
- if (iterable) {
- var iteratorMethod = iterable[iteratorSymbol];
- if (iteratorMethod) {
- return iteratorMethod.call(iterable);
- }
- if (typeof iterable.next === "function") {
- return iterable;
- }
- if (!isNaN(iterable.length)) {
- var i = -1, next = function next() {
- while (++i < iterable.length) {
- if (hasOwn.call(iterable, i)) {
- next.value = iterable[i];
- next.done = false;
- return next;
- }
- }
- next.value = undefined;
- next.done = true;
- return next;
- };
- return next.next = next;
- }
- }
- // Return an iterator with no values.
- return { next: doneResult };
- }
- runtime.values = values;
- function doneResult() {
- return { value: undefined, done: true };
- }
- Context.prototype = {
- constructor: Context,
- reset: function(skipTempReset) {
- this.prev = 0;
- this.next = 0;
- // Resetting context._sent for legacy support of Babel's
- // function.sent implementation.
- this.sent = this._sent = undefined;
- this.done = false;
- this.delegate = null;
- this.method = "next";
- this.arg = undefined;
- this.tryEntries.forEach(resetTryEntry);
- if (!skipTempReset) {
- for (var name in this) {
- // Not sure about the optimal order of these conditions:
- if (name.charAt(0) === "t" &&
- hasOwn.call(this, name) &&
- !isNaN(+name.slice(1))) {
- this[name] = undefined;
- }
- }
- }
- },
- stop: function() {
- this.done = true;
- var rootEntry = this.tryEntries[0];
- var rootRecord = rootEntry.completion;
- if (rootRecord.type === "throw") {
- throw rootRecord.arg;
- }
- return this.rval;
- },
- dispatchException: function(exception) {
- if (this.done) {
- throw exception;
- }
- var context = this;
- function handle(loc, caught) {
- record.type = "throw";
- record.arg = exception;
- context.next = loc;
- if (caught) {
- // If the dispatched exception was caught by a catch block,
- // then let that catch block handle the exception normally.
- context.method = "next";
- context.arg = undefined;
- }
- return !! caught;
- }
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- var record = entry.completion;
- if (entry.tryLoc === "root") {
- // Exception thrown outside of any try block that could handle
- // it, so set the completion value of the entire function to
- // throw the exception.
- return handle("end");
- }
- if (entry.tryLoc <= this.prev) {
- var hasCatch = hasOwn.call(entry, "catchLoc");
- var hasFinally = hasOwn.call(entry, "finallyLoc");
- if (hasCatch && hasFinally) {
- if (this.prev < entry.catchLoc) {
- return handle(entry.catchLoc, true);
- } else if (this.prev < entry.finallyLoc) {
- return handle(entry.finallyLoc);
- }
- } else if (hasCatch) {
- if (this.prev < entry.catchLoc) {
- return handle(entry.catchLoc, true);
- }
- } else if (hasFinally) {
- if (this.prev < entry.finallyLoc) {
- return handle(entry.finallyLoc);
- }
- } else {
- throw new Error("try statement without catch or finally");
- }
- }
- }
- },
- abrupt: function(type, arg) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.tryLoc <= this.prev &&
- hasOwn.call(entry, "finallyLoc") &&
- this.prev < entry.finallyLoc) {
- var finallyEntry = entry;
- break;
- }
- }
- if (finallyEntry &&
- (type === "break" ||
- type === "continue") &&
- finallyEntry.tryLoc <= arg &&
- arg <= finallyEntry.finallyLoc) {
- // Ignore the finally entry if control is not jumping to a
- // location outside the try/catch block.
- finallyEntry = null;
- }
- var record = finallyEntry ? finallyEntry.completion : {};
- record.type = type;
- record.arg = arg;
- if (finallyEntry) {
- this.method = "next";
- this.next = finallyEntry.finallyLoc;
- return ContinueSentinel;
- }
- return this.complete(record);
- },
- complete: function(record, afterLoc) {
- if (record.type === "throw") {
- throw record.arg;
- }
- if (record.type === "break" ||
- record.type === "continue") {
- this.next = record.arg;
- } else if (record.type === "return") {
- this.rval = this.arg = record.arg;
- this.method = "return";
- this.next = "end";
- } else if (record.type === "normal" && afterLoc) {
- this.next = afterLoc;
- }
- return ContinueSentinel;
- },
- finish: function(finallyLoc) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.finallyLoc === finallyLoc) {
- this.complete(entry.completion, entry.afterLoc);
- resetTryEntry(entry);
- return ContinueSentinel;
- }
- }
- },
- "catch": function(tryLoc) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.tryLoc === tryLoc) {
- var record = entry.completion;
- if (record.type === "throw") {
- var thrown = record.arg;
- resetTryEntry(entry);
- }
- return thrown;
- }
- }
- // The context.catch method must only be called with a location
- // argument that corresponds to a known catch block.
- throw new Error("illegal catch attempt");
- },
- delegateYield: function(iterable, resultName, nextLoc) {
- this.delegate = {
- iterator: values(iterable),
- resultName: resultName,
- nextLoc: nextLoc
- };
- if (this.method === "next") {
- // Deliberately forget the last sent value so that we don't
- // accidentally pass it on to the delegate.
- this.arg = undefined;
- }
- return ContinueSentinel;
- }
- };
- })(
- // Among the various tricks for obtaining a reference to the global
- // object, this seems to be the most reliable technique that does not
- // use indirect eval (which violates Content Security Policy).
- typeof global === "object" ? global :
- typeof window === "object" ? window :
- typeof self === "object" ? self : this
- );
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(74)))
- /***/ }),
- /* 123 */
- /***/ (function(module, exports, __webpack_require__) {
- var map = {
- "./autoColumnSize/test/autoColumnSize.e2e.js": 126,
- "./autoRowSize/test/autoRowSize.e2e.js": 127,
- "./columnSorting/test/columnSorting.e2e.js": 128,
- "./comments/test/comments.e2e.js": 129,
- "./contextMenu/test/alignment.e2e.js": 130,
- "./contextMenu/test/contextMenu.e2e.js": 131,
- "./contextMenu/test/predefinedItems/readOnly.e2e.js": 132,
- "./contextMenuCopyPaste/test/contextMenuCopyPaste.e2e.js": 133,
- "./copyPaste/test/copyPaste.e2e.js": 134,
- "./customBorders/test/customBorders.e2e.js": 135,
- "./dragToScroll/test/dragToScroll.e2e.js": 136,
- "./manualColumnFreeze/test/manualColumnFreeze.e2e.js": 137,
- "./manualColumnMove/test/manualColumnMove.e2e.js": 138,
- "./manualColumnMove/test/manualColumnMoveUI.e2e.js": 139,
- "./manualColumnResize/test/manualColumnResize.e2e.js": 140,
- "./manualRowMove/test/manualRowMove.e2e.js": 141,
- "./manualRowMove/test/manualRowMoveUI.e2e.js": 142,
- "./manualRowResize/test/manualRowResize.e2e.js": 143,
- "./mergeCells/test/canMergeRange.e2e.js": 144,
- "./observeChanges/test/observeChanges.e2e.js": 145,
- "./persistentState/test/persistentState.e2e.js": 146,
- "./search/test/search.e2e.js": 147,
- "./undoRedo/test/UndoRedo.e2e.js": 148
- };
- function webpackContext(req) {
- return __webpack_require__(webpackContextResolve(req));
- };
- function webpackContextResolve(req) {
- var id = map[req];
- if(!(id + 1)) // check for number or string
- throw new Error("Cannot find module '" + req + "'.");
- return id;
- };
- webpackContext.keys = function webpackContextKeys() {
- return Object.keys(map);
- };
- webpackContext.resolve = webpackContextResolve;
- module.exports = webpackContext;
- webpackContext.id = 123;
- /***/ }),
- /* 124 */
- /***/ (function(module, exports, __webpack_require__) {
- var map = {
- "./ColHeader.spec.js": 149,
- "./Core_alter.spec.js": 150,
- "./Core_beforeKeyDown.spec.js": 151,
- "./Core_beforechange.spec.js": 152,
- "./Core_copy.spec.js": 153,
- "./Core_count.spec.js": 154,
- "./Core_dataSchema.spec.js": 155,
- "./Core_datachange.spec.js": 156,
- "./Core_destroy.spec.js": 157,
- "./Core_destroyEditor.spec.js": 158,
- "./Core_getCellMeta.spec.js": 159,
- "./Core_getColHeader.spec.js": 160,
- "./Core_getDataAt.spec.js": 161,
- "./Core_getDataType.spec.js": 162,
- "./Core_getRowHeader.spec.js": 163,
- "./Core_init.spec.js": 164,
- "./Core_isEmpty.spec.js": 165,
- "./Core_keepEmptyRows.spec.js": 166,
- "./Core_listen.spec.js": 167,
- "./Core_loadData.spec.js": 168,
- "./Core_navigation.spec.js": 169,
- "./Core_onKeyDown.spec.js": 170,
- "./Core_paste.spec.js": 171,
- "./Core_populateFromArray.spec.js": 172,
- "./Core_reCreate.spec.js": 173,
- "./Core_removeCellMeta.spec.js": 174,
- "./Core_render.spec.js": 175,
- "./Core_selection.spec.js": 176,
- "./Core_setDataAtCell.spec.js": 177,
- "./Core_splice.spec.js": 178,
- "./Core_update.spec.js": 179,
- "./Core_validate.spec.js": 180,
- "./Core_view.spec.js": 181,
- "./Dom.spec.js": 182,
- "./FillHandle.spec.js": 183,
- "./Performance.spec.js": 184,
- "./PluginHooks.spec.js": 185,
- "./RowHeader.spec.js": 186,
- "./cellTypes/index.spec.js": 187,
- "./core/colToProp.spec.js": 188,
- "./core/countSourceCols.spec.js": 189,
- "./core/getCellMetaAtRow.spec.js": 190,
- "./core/getCellsMeta.spec.js": 191,
- "./core/getCopyableData.spec.js": 192,
- "./core/getCopyableText.spec.js": 193,
- "./core/getSourceDataArray.spec.js": 194,
- "./core/getSourceDataAtCell.spec.js": 195,
- "./core/propToCol.spec.js": 196,
- "./core/setCellMeta.spec.js": 197,
- "./core/spliceCellsMeta.spec.js": 198,
- "./core/spliceCol.spec.js": 199,
- "./core/spliceRow.spec.js": 200,
- "./core/toPhysicalColumn.spec.js": 201,
- "./core/toPhysicalRow.spec.js": 202,
- "./core/toVisualColumn.spec.js": 203,
- "./core/toVisualRow.spec.js": 204,
- "./editors/autocompleteEditor.spec.js": 205,
- "./editors/baseEditor.spec.js": 206,
- "./editors/dateEditor.spec.js": 207,
- "./editors/dropdownEditor.spec.js": 208,
- "./editors/handsontableEditor.spec.js": 209,
- "./editors/index.spec.js": 210,
- "./editors/noEditor.spec.js": 211,
- "./editors/numericEditor.spec.js": 212,
- "./editors/passwordEditor.spec.js": 213,
- "./editors/selectEditor.spec.js": 214,
- "./editors/textEditor.spec.js": 215,
- "./publicAPI.spec.js": 217,
- "./renderers/autocompleteRenderer.spec.js": 218,
- "./renderers/cellDecorator.spec.js": 219,
- "./renderers/checkboxRenderer.spec.js": 220,
- "./renderers/htmlRenderer.spec.js": 221,
- "./renderers/index.spec.js": 222,
- "./renderers/numericRenderer.spec.js": 223,
- "./renderers/passwordRenderer.spec.js": 224,
- "./renderers/textRenderer.spec.js": 225,
- "./settings/colWidths.spec.js": 226,
- "./settings/columns.spec.js": 227,
- "./settings/copyable.spec.js": 228,
- "./settings/currentHeaderClassName.spec.js": 229,
- "./settings/currentRowClassName.spec.js": 230,
- "./settings/editor.spec.js": 231,
- "./settings/fixedColumnsLeft.spec.js": 232,
- "./settings/fixedRowsTop.spec.js": 233,
- "./settings/fragmentSelection.spec.js": 234,
- "./settings/maxCols.spec.js": 235,
- "./settings/maxRows.spec.js": 236,
- "./settings/renderer.spec.js": 237,
- "./settings/tableClassName.spec.js": 238,
- "./utils/ghostTable.spec.js": 239,
- "./validators/autocompleteValidator.spec.js": 240,
- "./validators/dateValidator.spec.js": 241,
- "./validators/index.spec.js": 242,
- "./validators/numericValidator.spec.js": 243,
- "./validators/timeValidator.spec.js": 244
- };
- function webpackContext(req) {
- return __webpack_require__(webpackContextResolve(req));
- };
- function webpackContextResolve(req) {
- var id = map[req];
- if(!(id + 1)) // check for number or string
- throw new Error("Cannot find module '" + req + "'.");
- return id;
- };
- webpackContext.keys = function webpackContextKeys() {
- return Object.keys(map);
- };
- webpackContext.resolve = webpackContextResolve;
- module.exports = webpackContext;
- webpackContext.id = 124;
- /***/ }),
- /* 125 */,
- /* 126 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
- describe('AutoColumnSize', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfObjects = function arrayOfObjects() {
- return [{ id: 'Short', name: 'Somewhat long', lastName: 'The very very very longest one', nestedData: [{ id: 1000 }] }];
- };
- it('should apply auto size by default', function () {
- handsontable({
- data: arrayOfObjects()
- });
- var width0 = colWidth(this.$container, 0);
- var width1 = colWidth(this.$container, 1);
- var width2 = colWidth(this.$container, 2);
- expect(width0).toBeLessThan(width1);
- expect(width1).toBeLessThan(width2);
- });
- it('should update column width after update value in cell (array of objects)', function () {
- handsontable({
- data: arrayOfObjects(),
- autoColumnSize: true,
- columns: [{ data: 'id' }, { data: 'name' }, { data: 'lastName' }]
- });
- expect(colWidth(this.$container, 0)).toBeAroundValue(50, 3);
- expect([117, 120, 121, 129, 135]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 1)]));
- expect([216, 229, 247, 260]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 2)]));
- setDataAtRowProp(0, 'id', 'foo bar foo bar foo bar');
- setDataAtRowProp(0, 'name', 'foo');
- expect([165, 168, 169, 189, 191]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 0)]));
- expect(colWidth(this.$container, 1)).toBeAroundValue(50, 3);
- expect([216, 229, 247, 260]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 2)]));
- });
- it('should correctly detect column widths with colHeaders', function () {
- handsontable({
- data: arrayOfObjects(),
- autoColumnSize: true,
- colHeaders: ['Identifier Longer text'],
- columns: [{ data: 'id' }, { data: 'name' }]
- });
- expect([149, 155, 174, 178]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 0)]));
- });
- it('should correctly detect column widths after update colHeaders when headers were passed as an array', function () {
- handsontable({
- data: arrayOfObjects(),
- autoColumnSize: true,
- colHeaders: true,
- columns: [{ data: 'id' }, { data: 'name' }]
- });
- expect([50, 51, 53]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 0)]));
- updateSettings({ colHeaders: ['Identifier Longer text', 'Identifier Longer and longer text'] });
- expect([149, 155, 174, 178]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 0)]));
- expect([226, 235, 263, 270]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 1)]));
- });
- it('should correctly detect column widths after update colHeaders when headers were passed as a string', function () {
- handsontable({
- data: arrayOfObjects(),
- autoColumnSize: true,
- colHeaders: true,
- columns: [{ data: 'id' }, { data: 'name' }]
- });
- expect([50, 51, 53]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 0)]));
- updateSettings({ colHeaders: 'Identifier Longer text' });
- expect([149, 155, 174, 178]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 0)]));
- expect([149, 155, 174, 178]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 1)]));
- });
- it('should correctly detect column widths after update colHeaders when headers were passed as a function', function () {
- handsontable({
- data: arrayOfObjects(),
- autoColumnSize: true,
- colHeaders: true,
- columns: [{ data: 'id' }, { data: 'name' }]
- });
- expect([50, 51, 53]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 0)]));
- updateSettings({
- colHeaders: function colHeaders(index) {
- return index === 0 ? 'Identifier Longer text' : 'Identifier Longer and longer text';
- }
- });
- expect([149, 155, 174, 178]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 0)]));
- expect([226, 235, 263, 270]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 1)]));
- });
- it('should correctly detect column width with colHeaders and the useHeaders option set to false (not taking the header widths into calculation)', function () {
- handsontable({
- data: [{ id: 'ab' }],
- autoColumnSize: {
- useHeaders: false
- },
- colHeaders: ['Identifier'],
- columns: [{ data: 'id' }]
- });
- expect(colWidth(this.$container, 0)).toBe(50);
- });
- it('should correctly detect column width with columns.title', function () {
- handsontable({
- data: arrayOfObjects(),
- autoColumnSize: true,
- columns: [{ data: 'id', title: 'Identifier' }]
- });
- expect([68, 70, 71, 80, 82]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 0)]));
- });
- it('should correctly detect column widths after update columns.title', function () {
- handsontable({
- data: arrayOfObjects(),
- autoColumnSize: true,
- columns: [{ data: 'id', title: 'Identifier' }]
- });
- updateSettings({
- columns: [{ data: 'id', title: 'Identifier with longer text' }]
- });
- expect([174, 182, 183, 208, 213]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 0)]));
- });
- // https://github.com/handsontable/handsontable/issues/2684
- it('should correctly detect column width when table is hidden on init (display: none)', _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
- var hot;
- return regeneratorRuntime.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- spec().$container.css('display', 'none');
- hot = handsontable({
- data: arrayOfObjects(),
- autoColumnSize: true,
- colHeaders: ['Identifier', 'First Name']
- });
- _context.next = 4;
- return sleep(200);
- case 4:
- spec().$container.css('display', 'block');
- hot.render();
- expect([68, 70, 71, 80, 82]).toEqual(jasmine.arrayContaining([colWidth(spec().$container, 0)]));
- case 7:
- case 'end':
- return _context.stop();
- }
- }
- }, _callee, undefined);
- })));
- it('should keep last columns width unchanged if all rows was removed', function () {
- var hot = handsontable({
- data: arrayOfObjects(),
- autoColumnSize: true,
- columns: [{ data: 'id', title: 'Identifier' }, { data: 'name', title: 'Name' }, { data: 'lastName', title: 'Last Name' }]
- });
- expect([68, 70, 71, 80, 82]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 0)]));
- expect([117, 120, 121, 129, 135]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 1)]));
- expect([216, 229, 247, 260]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 2)]));
- hot.alter('remove_row', 0);
- expect([68, 70, 71, 80, 82]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 0)]));
- expect([117, 120, 121, 129, 135]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 1)]));
- expect([216, 229, 247, 260]).toEqual(jasmine.arrayContaining([colWidth(this.$container, 2)]));
- });
- it('should be possible to disable plugin using updateSettings', function () {
- handsontable({
- data: arrayOfObjects()
- });
- var width0 = colWidth(this.$container, 0);
- var width1 = colWidth(this.$container, 1);
- var width2 = colWidth(this.$container, 2);
- expect(width0).toBeLessThan(width1);
- expect(width1).toBeLessThan(width2);
- updateSettings({
- autoColumnSize: false
- });
- width0 = colWidth(this.$container, 0);
- width1 = colWidth(this.$container, 1);
- width2 = colWidth(this.$container, 2);
- expect(width0).toEqual(width1);
- expect(width0).toEqual(width2);
- expect(width1).toEqual(width2);
- });
- it('should apply disabling/enabling plugin using updateSettings, only to a particular HOT instance', function () {
- this.$container2 = $('<div id="' + id + '-2"></div>').appendTo('body');
- handsontable({
- data: arrayOfObjects()
- });
- this.$container2.handsontable({
- data: arrayOfObjects()
- });
- var widths = {
- 1: [],
- 2: []
- };
- widths[1][0] = colWidth(this.$container, 0);
- widths[1][1] = colWidth(this.$container, 1);
- widths[1][2] = colWidth(this.$container, 2);
- widths[2][0] = colWidth(this.$container2, 0);
- widths[2][1] = colWidth(this.$container2, 1);
- widths[2][2] = colWidth(this.$container2, 2);
- expect(widths[1][0]).toBeLessThan(widths[1][1]);
- expect(widths[1][1]).toBeLessThan(widths[1][2]);
- expect(widths[2][0]).toBeLessThan(widths[2][1]);
- expect(widths[2][1]).toBeLessThan(widths[2][2]);
- updateSettings({
- autoColumnSize: false
- });
- widths[1][0] = colWidth(this.$container, 0);
- widths[1][1] = colWidth(this.$container, 1);
- widths[1][2] = colWidth(this.$container, 2);
- widths[2][0] = colWidth(this.$container2, 0);
- widths[2][1] = colWidth(this.$container2, 1);
- widths[2][2] = colWidth(this.$container2, 2);
- expect(widths[1][0]).toEqual(widths[1][1]);
- expect(widths[1][0]).toEqual(widths[1][2]);
- expect(widths[1][1]).toEqual(widths[1][2]);
- expect(widths[2][0]).toBeLessThan(widths[2][1]);
- expect(widths[2][1]).toBeLessThan(widths[2][2]);
- this.$container2.handsontable('destroy');
- this.$container2.remove();
- });
- it('should be possible to enable plugin using updateSettings', function () {
- handsontable({
- data: arrayOfObjects(),
- autoColumnSize: false
- });
- var width0 = colWidth(this.$container, 0);
- var width1 = colWidth(this.$container, 1);
- var width2 = colWidth(this.$container, 2);
- expect(width0).toEqual(width1);
- expect(width0).toEqual(width2);
- expect(width1).toEqual(width2);
- updateSettings({
- autoColumnSize: true
- });
- width0 = colWidth(this.$container, 0);
- width1 = colWidth(this.$container, 1);
- width2 = colWidth(this.$container, 2);
- expect(width0).toBeLessThan(width1);
- expect(width1).toBeLessThan(width2);
- });
- it('should consider CSS style of each instance separately', function () {
- var $style = $('<style>.big .htCore td {font-size: 40px; line-height: 1.1;}</style>').appendTo('head');
- var $container1 = $('<div id="hot1"></div>').appendTo('body').handsontable({
- data: arrayOfObjects()
- });
- var $container2 = $('<div id="hot2"></div>').appendTo('body').handsontable({
- data: arrayOfObjects()
- });
- var hot1 = $container1.handsontable('getInstance');
- var hot2 = $container2.handsontable('getInstance');
- expect(colWidth($container1, 0)).toEqual(colWidth($container2, 0));
- $container1.addClass('big');
- hot1.render();
- hot2.render();
- expect(colWidth($container1, 0)).toBeGreaterThan(colWidth($container2, 0));
- $container1.removeClass('big').handsontable('render');
- $container2.addClass('big').handsontable('render');
- expect(colWidth($container1, 0)).toBeLessThan(colWidth($container2, 0));
- $style.remove();
- $container1.handsontable('destroy');
- $container1.remove();
- $container2.handsontable('destroy');
- $container2.remove();
- });
- it('should consider CSS class of the <table> element (e.g. when used with Bootstrap)', function () {
- var $style = $('<style>.htCore.big-table td {font-size: 32px}</style>').appendTo('head');
- handsontable({
- data: arrayOfObjects(),
- autoColumnSize: true
- });
- var width = colWidth(this.$container, 0);
- this.$container.find('table').addClass('big-table');
- render();
- expect(colWidth(this.$container, 0)).toBeGreaterThan(width);
- $style.remove();
- });
- it('should destroy temporary element', function () {
- handsontable({
- autoColumnSize: true
- });
- expect(document.querySelector('.htAutoSize')).toBe(null);
- });
- it('should not trigger autoColumnSize when column width is defined (through colWidths)', function () {
- handsontable({
- data: arrayOfObjects(),
- autoColumnSize: true,
- colWidths: [70, 70, 70],
- width: 500,
- height: 100,
- rowHeaders: true
- });
- setDataAtCell(0, 0, 'LongLongLongLong');
- expect(colWidth(this.$container, 0)).toBe(70);
- });
- it('should not trigger autoColumnSize when column width is defined (through columns.width)', function () {
- handsontable({
- data: arrayOfObjects(),
- autoColumnSize: true,
- colWidth: 77,
- columns: [{ width: 70 }, { width: 70 }, { width: 70 }],
- width: 500,
- height: 100,
- rowHeaders: true
- });
- setDataAtCell(0, 0, 'LongLongLongLong');
- expect(colWidth(this.$container, 0)).toBe(70);
- });
- it('should consider renderer that uses conditional formatting for specific row & column index', function () {
- var data = arrayOfObjects();
- data.push({ id: '2', name: 'Rocket Man', lastName: 'In a tin can' });
- handsontable({
- data: data,
- columns: [{ data: 'id' }, { data: 'name' }],
- autoColumnSize: true,
- renderer: function renderer(instance, td, row, col, prop, value, cellProperties) {
- // taken from demo/renderers.html
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- if (row === 1 && col === 0) {
- td.style.padding = '100px';
- }
- }
- });
- expect(colWidth(this.$container, 0)).toBeGreaterThan(colWidth(this.$container, 1));
- });
- it('should\'t serialize value if it is array (nested data sources)', function () {
- var spy = jasmine.createSpy('renderer');
- handsontable({
- data: arrayOfObjects(),
- autoColumnSize: true,
- columns: [{ data: 'nestedData' }],
- renderer: spy
- });
- expect(spy.calls.mostRecent().args[5]).toEqual([{ id: 1000 }]);
- });
- });
- /***/ }),
- /* 127 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('AutoRowSize', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- function arrayOfObjects() {
- return [{ id: 'Short' }, { id: 'Somewhat\nlong' }, { id: 'The\nvery\nvery\nvery\nlongest one' }];
- }
- function arrayOfObjects2() {
- return [{ id: 'Short', name: 'Somewhat long' }, { id: 'Somewhat long', name: 'The very very longest one' }, { id: 'The very very very longest one', name: 'Short' }];
- }
- it('should apply auto size by default', function () {
- handsontable({
- data: arrayOfObjects()
- });
- var height0 = rowHeight(this.$container, 0);
- var height1 = rowHeight(this.$container, 1);
- var height2 = rowHeight(this.$container, 2);
- expect(height0).toBeLessThan(height1);
- expect(height1).toBeLessThan(height2);
- });
- it('should draw scrollbar correctly (proper height) after calculation when autoRowSize option is set (long text in row) #4000', function (done) {
- var row = ['This is very long text which will break this cell text into two lines'];
- var data = [];
- var nrOfRows = 200;
- var columnWidth = 100;
- for (var i = 0; i < nrOfRows; i += 1) {
- data.push(row);
- }
- handsontable({
- data: data,
- colWidths: function colWidths() {
- return columnWidth;
- },
- autoRowSize: true
- });
- var oldHeight = spec().$container[0].scrollHeight;
- setTimeout(function () {
- var newHeight = spec().$container[0].scrollHeight;
- expect(oldHeight).toBeLessThan(newHeight);
- done();
- }, 200);
- });
- describe('should draw scrollbar correctly (proper height) after calculation when autoRowSize option is set (`table td` element height set by CSS) #4000', function () {
- var cellHeightInPx = 100;
- var nrOfRows = null;
- var nrOfColumns = 200,
- style;
- var SYNC_CALCULATION_LIMIT = Handsontable.plugins.AutoRowSize.SYNC_CALCULATION_LIMIT;
- var CALCULATION_STEP = Handsontable.plugins.AutoRowSize.CALCULATION_STEP;
- beforeEach(function () {
- if (!this.$container) {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- }
- var css = '.handsontable table td { height: ' + cellHeightInPx + 'px !important }',
- head = document.head;
- style = document.createElement('style');
- style.type = 'text/css';
- if (style.styleSheet) {
- style.styleSheet.cssText = css;
- } else {
- style.appendChild(document.createTextNode(css));
- }
- $(head).append(style);
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- if (style) {
- $(style).remove();
- }
- });
- it('(SYNC_CALCULATION_LIMIT - 1 rows)', function (done) {
- nrOfRows = SYNC_CALCULATION_LIMIT - 1;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(nrOfRows, nrOfColumns),
- autoRowSize: true
- });
- setTimeout(function () {
- var newHeight = spec().$container[0].scrollHeight;
- expect(newHeight).toEqual((cellHeightInPx + 1) * nrOfRows + 1);
- done();
- }, 200);
- });
- it('(SYNC_CALCULATION_LIMIT + 1 rows)', function (done) {
- nrOfRows = SYNC_CALCULATION_LIMIT + 1;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(nrOfRows, nrOfColumns),
- autoRowSize: true
- });
- setTimeout(function () {
- var newHeight = spec().$container[0].scrollHeight;
- expect(newHeight).toEqual((cellHeightInPx + 1) * nrOfRows + 1);
- done();
- }, 200);
- });
- it('(SYNC_CALCULATION_LIMIT + CALCULATION_STEP - 1 rows)', function (done) {
- nrOfRows = SYNC_CALCULATION_LIMIT + CALCULATION_STEP - 1;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(nrOfRows, nrOfColumns),
- autoRowSize: true
- });
- setTimeout(function () {
- var newHeight = spec().$container[0].scrollHeight;
- expect(newHeight).toEqual((cellHeightInPx + 1) * nrOfRows + 1);
- done();
- }, 200);
- });
- it('(SYNC_CALCULATION_LIMIT + CALCULATION_STEP + 1 rows)', function (done) {
- nrOfRows = SYNC_CALCULATION_LIMIT + CALCULATION_STEP + 1;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(nrOfRows, nrOfColumns),
- autoRowSize: true
- });
- setTimeout(function () {
- var newHeight = spec().$container[0].scrollHeight;
- expect(newHeight).toEqual((cellHeightInPx + 1) * nrOfRows + 1);
- done();
- }, 200);
- });
- });
- it('should correctly detect row height when table is hidden on init (display: none)', function (done) {
- this.$container.css('display', 'none');
- var hot = handsontable({
- data: arrayOfObjects(),
- rowHeaders: true,
- autoRowSize: true
- });
- setTimeout(function () {
- spec().$container.css('display', 'block');
- hot.render();
- expect(rowHeight(spec().$container, 0)).toBe(24);
- expect(rowHeight(spec().$container, 1)).toBe(43);
- expect([106, 127]).toEqual(jasmine.arrayContaining([rowHeight(spec().$container, 2)]));
- done();
- }, 200);
- });
- it('should be possible to disable plugin using updateSettings', function () {
- var hot = handsontable({
- data: arrayOfObjects()
- });
- var height0 = rowHeight(this.$container, 0);
- var height1 = rowHeight(this.$container, 1);
- var height2 = rowHeight(this.$container, 2);
- expect(height0).toBeLessThan(height1);
- expect(height1).toBeLessThan(height2);
- updateSettings({
- autoRowSize: false
- });
- hot.setDataAtCell(0, 0, 'A\nB\nC');
- var height4 = rowHeight(this.$container, 0);
- expect(height4).toBeGreaterThan(height0);
- });
- it('should be possible to enable plugin using updateSettings', function () {
- handsontable({
- data: arrayOfObjects(),
- autoRowSize: false
- });
- var height0 = parseInt(getCell(0, 0).style.height, 10);
- var height1 = parseInt(getCell(1, 0).style.height, 10);
- var height2 = parseInt(getCell(2, 0).style.height, 10);
- expect(height0).toEqual(height1);
- expect(height0).toEqual(height2);
- expect(height1).toEqual(height2);
- updateSettings({
- autoRowSize: true
- });
- height0 = parseInt(getCell(0, 0).style.height, 10);
- height1 = parseInt(getCell(1, 0).style.height, 10);
- height2 = parseInt(getCell(2, 0).style.height, 10);
- expect(height0).toBeLessThan(height1);
- expect(height1).toBeLessThan(height2);
- });
- it('should consider CSS style of each instance separately', function () {
- var $style = $('<style>.big .htCore td {font-size: 40px;line-height: 1.1}</style>').appendTo('head');
- var $container1 = $('<div id="hot1"></div>').appendTo('body').handsontable({
- data: arrayOfObjects(),
- autoRowSize: true
- });
- var $container2 = $('<div id="hot2"></div>').appendTo('body').handsontable({
- data: arrayOfObjects(),
- autoRowSize: true
- });
- var hot1 = $container1.handsontable('getInstance');
- var hot2 = $container2.handsontable('getInstance');
- expect(parseInt(hot1.getCell(0, 0).style.height, 10)).toEqual(parseInt(hot2.getCell(0, 0).style.height, 10));
- $container1.addClass('big');
- hot1.render();
- hot2.render();
- expect(parseInt(hot1.getCell(2, 0).style.height, 10)).toBeGreaterThan(parseInt(hot2.getCell(2, 0).style.height, 10));
- $container1.removeClass('big');
- hot1.render();
- $container2.addClass('big');
- hot2.render();
- expect(parseInt(hot1.getCell(2, 0).style.height, 10)).toBeLessThan(parseInt(hot2.getCell(2, 0).style.height, 10));
- $style.remove();
- $container1.handsontable('destroy');
- $container1.remove();
- $container2.handsontable('destroy');
- $container2.remove();
- });
- it('should consider CSS class of the <table> element (e.g. when used with Bootstrap)', function () {
- var $style = $('<style>.htCore.big-table td {font-size: 32px;line-height: 1.1}</style>').appendTo('head');
- var hot = handsontable({
- data: arrayOfObjects(),
- autoRowSize: true
- });
- var height = parseInt(hot.getCell(2, 0).style.height, 10);
- this.$container.find('table').addClass('big-table');
- hot.getPlugin('autoRowSize').clearCache();
- render();
- expect(parseInt(hot.getCell(2, 0).style.height, 10)).toBeGreaterThan(height);
- $style.remove();
- });
- it('should not trigger autoColumnSize when column width is defined (through colWidths)', function () {
- var hot = handsontable({
- data: arrayOfObjects(),
- autoRowSize: true,
- rowHeights: [70, 70, 70],
- width: 500,
- height: 100,
- rowHeaders: true
- });
- setDataAtCell(0, 0, 'LongLongLongLong');
- expect(parseInt(hot.getCell(0, -1).style.height, 10)).toBe(69); // -1px of cell border
- });
- // Currently columns.height is not supported
- xit('should not trigger autoRowSize when column height is defined (through columns.height)', function () {
- var hot = handsontable({
- data: arrayOfObjects(),
- autoRowSize: true,
- rowHeights: 77,
- columns: [{ height: 70 }, { height: 70 }, { height: 70 }],
- width: 500,
- height: 100,
- rowHeaders: true
- });
- setDataAtCell(0, 0, 'LongLongLongLong');
- expect(parseInt(hot.getCell(0, -1).style.height, 10)).toBe(69); // -1px of cell border
- });
- it('should consider renderer that uses conditional formatting for specific row & column index', function () {
- var data = arrayOfObjects();
- data.push({ id: '2', name: 'Rocket Man', lastName: 'In a tin can' });
- var hot = handsontable({
- data: data,
- columns: [{ data: 'id' }, { data: 'name' }],
- autoRowSize: true,
- renderer: function renderer(instance, td, row, col, prop, value, cellProperties) {
- // taken from demo/renderers.html
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- if (row === 1 && col === 0) {
- td.style.padding = '100px';
- }
- }
- });
- expect(parseInt(hot.getCell(1, 0).style.height || 0, 10)).toBe(242);
- });
- it('should destroy temporary element', function () {
- handsontable({
- autoRowSize: true
- });
- expect(document.querySelector('.htAutoSize')).toBe(null);
- });
- it('should recalculate heights after column resize', function () {
- var hot = handsontable({
- data: arrayOfObjects2(),
- colWidths: 250,
- manualColumnResize: true,
- autoRowSize: true,
- rowHeaders: true,
- colHeaders: true
- });
- expect(parseInt(hot.getCell(0, -1).style.height, 10)).toBe(22); // -1px of cell border
- expect(parseInt(hot.getCell(1, -1).style.height, 10)).toBe(22); // -1px of cell border
- expect(parseInt(hot.getCell(2, -1).style.height, 10)).toBeInArray([22, 42]); // -1px of cell border
- resizeColumn.call(this, 1, 100);
- expect(parseInt(hot.getCell(0, -1).style.height, 10)).toBe(22);
- expect(parseInt(hot.getCell(1, -1).style.height, 10)).toBe(42);
- expect([63, 84]).toEqual(jasmine.arrayContaining([parseInt(hot.getCell(2, -1).style.height, 10)]));
- resizeColumn.call(this, 1, 50);
- expect(parseInt(hot.getCell(0, -1).style.height, 10)).toBe(22);
- expect(parseInt(hot.getCell(1, -1).style.height, 10)).toBe(42);
- expect(parseInt(hot.getCell(2, -1).style.height, 10)).toBe(126);
- resizeColumn.call(this, 1, 200);
- expect(parseInt(hot.getCell(0, -1).style.height, 10)).toBe(22);
- expect(parseInt(hot.getCell(1, -1).style.height, 10)).toBe(22);
- expect(parseInt(hot.getCell(2, -1).style.height, 10)).toBe(42);
- });
- it('should recalculate heights after column moved', function () {
- var hot = handsontable({
- data: arrayOfObjects2(),
- colWidths: [250, 50],
- manualColumnMove: true,
- autoRowSize: true,
- rowHeaders: true,
- colHeaders: true
- });
- var plugin = hot.getPlugin('manualColumnMove');
- expect(parseInt(hot.getCell(0, -1).style.height, 10)).toBe(42); // -1px of cell border
- expect(parseInt(hot.getCell(1, -1).style.height, 10)).toBe(105); // -1px of cell border
- expect(parseInt(hot.getCell(2, -1).style.height, 10)).toBeInArray([22, 42]); // -1px of cell border
- plugin.moveColumn(0, 2);
- hot.render();
- expect(parseInt(hot.getCell(0, -1).style.height, 10)).toBe(22);
- expect(parseInt(hot.getCell(1, -1).style.height, 10)).toBe(42);
- expect(parseInt(hot.getCell(2, -1).style.height, 10)).toBe(126);
- });
- it('should recalculate heights with manualRowResize when changing text to multiline', function () {
- var hot = handsontable({
- data: arrayOfObjects2(),
- colWidths: 250,
- manualRowResize: [23, 50],
- autoRowSize: true,
- rowHeaders: true,
- colHeaders: true
- });
- expect(parseInt(hot.getCell(0, -1).style.height, 10)).toBe(22); // -1px of cell border
- expect(parseInt(hot.getCell(1, -1).style.height, 10)).toBe(49); // -1px of cell border
- expect(parseInt(hot.getCell(2, -1).style.height, 10)).toBeInArray([22, 42]); // -1px of cell border
- hot.setDataAtCell(1, 0, 'A\nB\nC\nD\nE');
- expect(parseInt(hot.getCell(0, -1).style.height, 10)).toBe(22);
- expect(parseInt(hot.getCell(1, -1).style.height, 10)).toBe(105);
- expect(parseInt(hot.getCell(2, -1).style.height, 10)).toBeInArray([22, 42]);
- });
- it('should recalculate heights after moved row', function () {
- var hot = handsontable({
- data: arrayOfObjects2(),
- colWidths: 250,
- manualRowResize: [23, 50],
- manualRowMove: true,
- autoRowSize: true,
- rowHeaders: true,
- colHeaders: true
- });
- expect(parseInt(hot.getCell(0, -1).style.height, 10)).toBe(22); // -1px of cell border
- expect(parseInt(hot.getCell(1, -1).style.height, 10)).toBe(49); // -1px of cell border
- expect(parseInt(hot.getCell(2, -1).style.height, 10)).toBeInArray([22, 42]); // -1px of cell border
- var plugin = hot.getPlugin('manualRowMove');
- plugin.moveRow(1, 0);
- hot.render();
- expect(parseInt(hot.getCell(0, -1).style.height, 10)).toBe(49);
- expect(parseInt(hot.getCell(1, -1).style.height, 10)).toBe(22);
- expect(parseInt(hot.getCell(2, -1).style.height, 10)).toBeInArray([22, 42]); // -1px of cell border
- });
- it('should resize the column headers properly, according the their content sizes', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(30, 30),
- colHeaders: function colHeaders(index) {
- if (index === 22) {
- return 'a<br>much<br>longer<br>label';
- }
- return 'test';
- },
- autoRowSize: true,
- rowHeaders: true,
- width: 300,
- height: 300
- });
- expect(rowHeight(spec().$container, -1)).toBe(89);
- });
- });
- /***/ }),
- /* 128 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- describe('ColumnSorting', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '" style="overflow: auto; width: 300px; height: 200px;"></div>').appendTo('body');
- this.sortByColumn = function (columnIndex) {
- var element = this.$container.find('th span.columnSorting:eq(' + columnIndex + ')');
- element.simulate('mousedown');
- element.simulate('mouseup');
- };
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfObjects = function arrayOfObjects() {
- return [{ id: 1, name: 'Ted', lastName: 'Right' }, { id: 2, name: 'Frank', lastName: 'Honest' }, { id: 3, name: 'Joan', lastName: 'Well' }, { id: 4, name: 'Sid', lastName: 'Strong' }, { id: 5, name: 'Jane', lastName: 'Neat' }, { id: 6, name: 'Chuck', lastName: 'Jackson' }, { id: 7, name: 'Meg', lastName: 'Jansen' }, { id: 8, name: 'Rob', lastName: 'Norris' }, { id: 9, name: 'Sean', lastName: 'O\'Hara' }, { id: 10, name: 'Eve', lastName: 'Branson' }];
- };
- it('should sort table by first visible column', function () {
- var hot = handsontable({
- data: [[1, 9, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 3, 1, 9], [0, 3, 0, 5, 6, 7, 8, 9, 1]],
- colHeaders: true,
- columnSorting: true
- });
- var htCore = getHtCore();
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(htCore.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('9');
- expect(htCore.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('3');
- expect(htCore.find('tbody tr:eq(0) td:eq(3)').text()).toEqual('4');
- this.sortByColumn(0);
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(htCore.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('3');
- expect(htCore.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('0');
- expect(htCore.find('tbody tr:eq(0) td:eq(3)').text()).toEqual('5');
- });
- it('should apply stable sort function #3606', function () {
- var hot = handsontable({
- data: [['mercedes1', 'Mercedes', 'A 160', '01/14/2007'], ['citroen1', 'Citroen', 'C4 Coupe', '12/01/2007'], ['opel1', 'Opel', 'Astra', '02/02/2006'], ['bmw1', 'BMW', '320i Coupe', '07/24/2009'], ['citroen2', 'Citroen', 'C4 Coupe', '12/01/2012'], ['opel2', 'Opel', 'Astra', '02/02/2004'], ['mercedes2', 'Mercedes', 'A 160', '01/14/2008'], ['citroen3', 'Citroen', 'C4 Coupe', '12/01/2007'], ['mercedes3', 'Mercedes', 'A 160', '01/14/2009'], ['opel3', 'Opel', 'Astra', '02/02/2006'], ['bmw2', 'BMW', '320i Coupe', '07/24/2013'], ['bmw3', 'BMW', '320i Coupe', '07/24/2012']],
- columns: [{}, {}, {
- type: 'date',
- dateFormat: 'mm/dd/yy'
- }, {
- type: 'numeric'
- }],
- columnSorting: true
- });
- hot.sort(1, true); // ASC
- expect(hot.getDataAtCol(0)).toEqual(['bmw1', 'bmw2', 'bmw3', 'citroen1', 'citroen2', 'citroen3', 'mercedes1', 'mercedes2', 'mercedes3', 'opel1', 'opel2', 'opel3']);
- hot.sort(1, false); // DESC
- expect(hot.getDataAtCol(0)).toEqual(['opel1', 'opel2', 'opel3', 'mercedes1', 'mercedes2', 'mercedes3', 'citroen1', 'citroen2', 'citroen3', 'bmw1', 'bmw2', 'bmw3']);
- });
- it('should not throw error when trying run handsontable with columnSorting and autoRowSize in the same time.', function () {
- var errors = 0;
- try {
- handsontable({
- data: arrayOfObjects(),
- autoRowSize: true,
- columnSorting: true
- });
- } catch (e) {
- errors++;
- }
- expect(errors).toBe(0);
- });
- it('should sort numbers descending after 2 clicks on table header', function () {
- handsontable({
- data: arrayOfObjects(),
- colHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(0);
- this.sortByColumn(0);
- expect(this.$container.find('tr td').first().html()).toEqual('10');
- });
- it('should remove specified row from sorted table and NOT sort the table again', function () {
- var hot = handsontable({
- data: [[1, 'B'], [3, 'D'], [2, 'A'], [0, 'C']],
- colHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(0);
- var htCore = getHtCore();
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('1');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('2');
- expect(htCore.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('3');
- expect(htCore.find('tbody tr').length).toEqual(4);
- // Now if sort is launched, sorting ordered will be reversed
- hot.sortOrder = false;
- hot.alter('remove_row', 0);
- expect(htCore.find('tbody tr').length).toEqual(3);
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('2');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- });
- it('should add an empty row to sorted table', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'A'], [3, 'D'], [2, 'C']],
- colHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(0);
- var htCore = getHtCore();
- expect(htCore.find('tbody tr').length).toEqual(4);
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('1');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('2');
- expect(htCore.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('3');
- hot.alter('insert_row', 1, 2);
- expect(htCore.find('tbody tr').length).toEqual(6);
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('');
- expect(htCore.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('1');
- expect(htCore.find('tbody tr:eq(4) td:eq(0)').text()).toEqual('2');
- expect(htCore.find('tbody tr:eq(5) td:eq(0)').text()).toEqual('3');
- });
- it('should add an empty row to sorted table at a given index', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'A'], [3, 'D'], [2, 'C']],
- colHeaders: true,
- columnSorting: true
- });
- var htCore = getHtCore();
- this.sortByColumn(0);
- expect(htCore.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('3');
- expect(htCore.find('tbody tr:eq(4) td:eq(0)').text()).toEqual('');
- hot.alter('insert_row', 2);
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('1');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('');
- expect(htCore.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('2');
- });
- it('should NOT sort the table after value update in sorted column', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'A'], [3, 'D'], [2, 'C']],
- colHeaders: true,
- columnSorting: true
- });
- var htCore = getHtCore();
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- this.sortByColumn(0);
- this.sortByColumn(0);
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('3');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('2');
- hot.setDataAtCell(1, 0, 20);
- render();
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('3');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('20');
- });
- it('defaultSort comparing function shouldn\'t change order when comparing empty string, null and undefined', function () {
- var hot = handsontable({});
- var defaultSort = hot.getPlugin('columnSorting').defaultSort;
- expect(defaultSort(false, {})(['key1', null], ['key2', null])).toEqual(0);
- expect(defaultSort(false, {})(['key1', ''], ['key2', ''])).toEqual(0);
- expect(defaultSort(false, {})(['key1', undefined], ['key2', undefined])).toEqual(0);
- expect(defaultSort(false, {})(['key1', ''], ['key2', null])).toEqual(0);
- expect(defaultSort(false, {})(['key1', null], ['key2', ''])).toEqual(0);
- expect(defaultSort(false, {})(['key1', ''], ['key2', undefined])).toEqual(0);
- expect(defaultSort(false, {})(['key1', undefined], ['key2', ''])).toEqual(0);
- expect(defaultSort(false, {})(['key1', null], ['key2', undefined])).toEqual(0);
- expect(defaultSort(false, {})(['key1', undefined], ['key2', null])).toEqual(0);
- });
- it('should place empty strings, null and undefined values at proper position (stability of default comparing function)', function () {
- var hot = handsontable({
- data: [[null, 'Ted Right'], [undefined, 'Jane Neat'], [null, 'Meg Jansen'], ['', 'Sean Hara'], ['', 'Eve Branson'], [6, 'Frank Honest'], [7, 'Joan Well'], [8, 'Sid Strong'], [9, 'Chuck Jackson'], [10, 'Rob Norris'], [11, 'Eve Well']],
- columnSorting: true
- });
- hot.sort(0, true); // ASC
- expect(hot.getDataAtCol(1)).toEqual(['Frank Honest', 'Joan Well', 'Sid Strong', 'Chuck Jackson', 'Rob Norris', 'Eve Well',
- // empty cells below
- 'Ted Right', 'Jane Neat', 'Meg Jansen', 'Sean Hara', 'Eve Branson']);
- hot.sort(0, false); // DESC
- expect(hot.getDataAtCol(1)).toEqual(['Eve Well', 'Rob Norris', 'Chuck Jackson', 'Sid Strong', 'Joan Well', 'Frank Honest',
- // empty cells below
- 'Ted Right', 'Jane Neat', 'Meg Jansen', 'Sean Hara', 'Eve Branson']);
- });
- it('should place empty strings, null and undefined values at proper position when `sortEmptyCells` option is enabled ' + '(API call, data type: default)', function () {
- var hot = handsontable({
- data: [[6, 'Frank Honest'], [null, 'Ted Right'], [7, 'Joan Well'], [8, 'Sid Strong'], [undefined, 'Jane Neat'], [9, 'Chuck Jackson'], [null, 'Meg Jansen'], [10, 'Rob Norris'], ['', 'Sean Hara'], ['', 'Eve Branson']],
- columnSorting: {
- sortEmptyCells: true
- }
- });
- hot.sort(0, true); // ASC
- expect(hot.getDataAtCol(1)).toEqual(['Ted Right', 'Jane Neat', 'Meg Jansen', 'Sean Hara', 'Eve Branson',
- // empty cells above
- 'Frank Honest', 'Joan Well', 'Sid Strong', 'Chuck Jackson', 'Rob Norris']);
- hot.sort(0, false); // DESC
- expect(hot.getDataAtCol(1)).toEqual(['Rob Norris', 'Chuck Jackson', 'Sid Strong', 'Joan Well', 'Frank Honest',
- // empty cells below
- 'Ted Right', 'Jane Neat', 'Meg Jansen', 'Sean Hara', 'Eve Branson']);
- });
- it('should place empty strings, null and undefined values at proper position when `sortEmptyCells` ' + 'option is enabled and `column` property of `columnSorting` option is set (data type: default)', function () {
- var hot = handsontable({
- data: [[6, 'Frank Honest'], [null, 'Ted Right'], [7, 'Joan Well'], [8, 'Sid Strong'], [undefined, 'Jane Neat'], [9, 'Chuck Jackson'], [null, 'Meg Jansen'], [10, 'Rob Norris'], ['', 'Sean Hara'], ['', 'Eve Branson']],
- columnSorting: {
- sortEmptyCells: true,
- sortOrder: true,
- column: 0
- }
- });
- // ASC
- expect(hot.getDataAtCol(1)).toEqual(['Ted Right', 'Jane Neat', 'Meg Jansen', 'Sean Hara', 'Eve Branson',
- // empty cells above
- 'Frank Honest', 'Joan Well', 'Sid Strong', 'Chuck Jackson', 'Rob Norris']);
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- hot = handsontable({
- data: [[6, 'Frank Honest'], [null, 'Ted Right'], [7, 'Joan Well'], [8, 'Sid Strong'], [undefined, 'Jane Neat'], [9, 'Chuck Jackson'], [null, 'Meg Jansen'], [10, 'Rob Norris'], ['', 'Sean Hara'], ['', 'Eve Branson']],
- columnSorting: {
- sortEmptyCells: true,
- sortOrder: false,
- column: 0
- }
- });
- // DESC
- expect(hot.getDataAtCol(1)).toEqual(['Rob Norris', 'Chuck Jackson', 'Sid Strong', 'Joan Well', 'Frank Honest',
- // empty cells below
- 'Ted Right', 'Jane Neat', 'Meg Jansen', 'Sean Hara', 'Eve Branson']);
- });
- it('should place empty strings, null and undefined values at proper position when `sortEmptyCells` ' + 'option is enabled and `column` property of `columnSorting` option is set (data type: numeric)', function () {
- var hot = handsontable({
- data: [[6, 'Frank Honest'], [null, 'Ted Right'], [7, 'Joan Well'], [8, 'Sid Strong'], [undefined, 'Jane Neat'], [9, 'Chuck Jackson'], [null, 'Meg Jansen'], [10, 'Rob Norris'], ['', 'Sean Hara'], ['', 'Eve Branson']],
- columns: [{
- type: 'numeric'
- }, {}],
- columnSorting: {
- sortEmptyCells: true,
- sortOrder: true,
- column: 0
- }
- });
- // ASC
- expect(hot.getDataAtCol(1)).toEqual(['Ted Right', 'Jane Neat', 'Meg Jansen', 'Sean Hara', 'Eve Branson',
- // empty cells above
- 'Frank Honest', 'Joan Well', 'Sid Strong', 'Chuck Jackson', 'Rob Norris']);
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- hot = handsontable({
- data: [[6, 'Frank Honest'], [null, 'Ted Right'], [7, 'Joan Well'], [8, 'Sid Strong'], [undefined, 'Jane Neat'], [9, 'Chuck Jackson'], [null, 'Meg Jansen'], [10, 'Rob Norris'], ['', 'Sean Hara'], ['', 'Eve Branson']],
- columnSorting: {
- sortEmptyCells: true,
- sortOrder: false,
- column: 0
- }
- });
- // DESC
- expect(hot.getDataAtCol(1)).toEqual(['Rob Norris', 'Chuck Jackson', 'Sid Strong', 'Joan Well', 'Frank Honest',
- // empty cells below
- 'Ted Right', 'Jane Neat', 'Meg Jansen', 'Sean Hara', 'Eve Branson']);
- });
- describe('data type: date', function () {
- it('dateSort comparing function shouldn\'t change order when comparing empty string, null and undefined', function () {
- var hot = handsontable({});
- var dateSort = hot.getPlugin('columnSorting').dateSort;
- expect(dateSort(false, {})(['key1', null], ['key2', null])).toEqual(0);
- expect(dateSort(false, {})(['key1', ''], ['key2', ''])).toEqual(0);
- expect(dateSort(false, {})(['key1', undefined], ['key2', undefined])).toEqual(0);
- expect(dateSort(false, {})(['key1', ''], ['key2', null])).toEqual(0);
- expect(dateSort(false, {})(['key1', null], ['key2', ''])).toEqual(0);
- expect(dateSort(false, {})(['key1', ''], ['key2', undefined])).toEqual(0);
- expect(dateSort(false, {})(['key1', undefined], ['key2', ''])).toEqual(0);
- expect(dateSort(false, {})(['key1', null], ['key2', undefined])).toEqual(0);
- expect(dateSort(false, {})(['key1', undefined], ['key2', null])).toEqual(0);
- });
- it('should place empty strings, null and undefined values at proper position when `sortEmptyCells` ' + 'option is enabled and `column` property of `columnSorting` option is set', function () {
- var hot = handsontable({
- data: [['Citroen1', 'C4 Coupe', null], ['Mercedes1', 'A 160', '12/01/2008'], ['Mercedes2', 'A 160', '01/14/2006'], ['Citroen2', 'C4 Coupe', undefined], ['Audi1', 'A4 Avant', '11/19/2011'], ['Opel1', 'Astra', '02/02/2004'], ['Citroen3', 'C4 Coupe', null], ['BMW1', '320i Coupe', '07/24/2011'], ['Citroen4', 'C4 Coupe', ''], ['Citroen5', 'C4 Coupe', '']],
- columns: [{}, {}, {
- type: 'date',
- dateFormat: 'MM/DD/YYYY'
- }],
- columnSorting: {
- sortEmptyCells: true,
- sortOrder: true,
- column: 2
- }
- });
- // ASC
- expect(hot.getDataAtCol(0)).toEqual(['Citroen1', 'Citroen2', 'Citroen3', 'Citroen4', 'Citroen5',
- // empty cells above
- 'Opel1', 'Mercedes2', 'Mercedes1', 'BMW1', 'Audi1']);
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- hot = handsontable({
- data: [['Citroen1', 'C4 Coupe', null], ['Mercedes1', 'A 160', '12/01/2008'], ['Mercedes2', 'A 160', '01/14/2006'], ['Citroen2', 'C4 Coupe', undefined], ['Audi1', 'A4 Avant', '11/19/2011'], ['Opel1', 'Astra', '02/02/2004'], ['Citroen3', 'C4 Coupe', null], ['BMW1', '320i Coupe', '07/24/2011'], ['Citroen4', 'C4 Coupe', ''], ['Citroen5', 'C4 Coupe', '']],
- columns: [{}, {}, {
- type: 'date',
- dateFormat: 'MM/DD/YYYY'
- }],
- columnSorting: {
- sortEmptyCells: true,
- sortOrder: false,
- column: 2
- }
- });
- // DESC
- expect(hot.getDataAtCol(0)).toEqual(['Audi1', 'BMW1', 'Mercedes1', 'Mercedes2', 'Opel1',
- // empty cells below
- 'Citroen1', 'Citroen2', 'Citroen3', 'Citroen4', 'Citroen5']);
- });
- it('should sort date columns (MM/DD/YYYY)', function () {
- var hot = handsontable({
- data: [['Mercedes', 'A 160', '01/14/2006', 6999.9999], ['Citroen', 'C4 Coupe', '12/01/2008', 8330], ['Audi', 'A4 Avant', '11/19/2011', 33900], ['Opel', 'Astra', '02/02/2004', 7000], ['BMW', '320i Coupe', '07/24/2011', 30500]],
- columns: [{}, {}, {
- type: 'date',
- dateFormat: 'MM/DD/YYYY'
- }, {
- type: 'numeric'
- }],
- colHeaders: true,
- columnSorting: true
- });
- hot.sort(2, true); // ASC
- expect(hot.getDataAtRow(0)).toEqual(['Opel', 'Astra', '02/02/2004', 7000]);
- expect(hot.getDataAtRow(1)).toEqual(['Mercedes', 'A 160', '01/14/2006', 6999.9999]);
- expect(hot.getDataAtRow(2)).toEqual(['Citroen', 'C4 Coupe', '12/01/2008', 8330]);
- expect(hot.getDataAtRow(3)).toEqual(['BMW', '320i Coupe', '07/24/2011', 30500]);
- expect(hot.getDataAtRow(4)).toEqual(['Audi', 'A4 Avant', '11/19/2011', 33900]);
- hot.sort(2, false); // DESC
- expect(hot.getDataAtRow(0)).toEqual(['Audi', 'A4 Avant', '11/19/2011', 33900]);
- expect(hot.getDataAtRow(1)).toEqual(['BMW', '320i Coupe', '07/24/2011', 30500]);
- expect(hot.getDataAtRow(2)).toEqual(['Citroen', 'C4 Coupe', '12/01/2008', 8330]);
- expect(hot.getDataAtRow(3)).toEqual(['Mercedes', 'A 160', '01/14/2006', 6999.9999]);
- expect(hot.getDataAtRow(4)).toEqual(['Opel', 'Astra', '02/02/2004', 7000]);
- });
- it('should sort date columns (DD/MM/YYYY)', function () {
- var hot = handsontable({
- data: [['Mercedes', 'A 160', '01/12/2012', 6999.9999], ['Citroen', 'C4 Coupe', '12/01/2013', 8330], ['Audi', 'A4 Avant', '11/10/2014', 33900], ['Opel', 'Astra', '02/02/2015', 7000], ['BMW', '320i Coupe', '07/02/2013', 30500]],
- columns: [{}, {}, {
- type: 'date',
- dateFormat: 'DD/MM/YYYY'
- }, {
- type: 'numeric'
- }],
- colHeaders: true,
- columnSorting: true
- });
- hot.sort(2, true); // ASC
- expect(hot.getDataAtRow(0)).toEqual(['Mercedes', 'A 160', '01/12/2012', 6999.9999]);
- expect(hot.getDataAtRow(1)).toEqual(['Citroen', 'C4 Coupe', '12/01/2013', 8330]);
- expect(hot.getDataAtRow(2)).toEqual(['BMW', '320i Coupe', '07/02/2013', 30500]);
- expect(hot.getDataAtRow(3)).toEqual(['Audi', 'A4 Avant', '11/10/2014', 33900]);
- expect(hot.getDataAtRow(4)).toEqual(['Opel', 'Astra', '02/02/2015', 7000]);
- hot.sort(2, false); // DESC
- expect(hot.getDataAtRow(0)).toEqual(['Opel', 'Astra', '02/02/2015', 7000]);
- expect(hot.getDataAtRow(1)).toEqual(['Audi', 'A4 Avant', '11/10/2014', 33900]);
- expect(hot.getDataAtRow(2)).toEqual(['BMW', '320i Coupe', '07/02/2013', 30500]);
- expect(hot.getDataAtRow(3)).toEqual(['Citroen', 'C4 Coupe', '12/01/2013', 8330]);
- expect(hot.getDataAtRow(4)).toEqual(['Mercedes', 'A 160', '01/12/2012', 6999.9999]);
- });
- it('should sort date columns (MMMM Do YYYY)', function () {
- var hot = handsontable({
- data: [['Mercedes', 'A 160', 'October 28th 2016', 6999.9999], ['Citroen', 'C4 Coupe', 'October 27th 2001', 8330], ['Audi', 'A4 Avant', 'July 8th 1999', 33900], ['Opel', 'Astra', 'June 1st 2001', 7000], ['BMW', '320i Coupe', 'August 3rd 2001', 30500]],
- columns: [{}, {}, {
- type: 'date',
- dateFormat: 'MMMM Do YYYY'
- }, {
- type: 'numeric'
- }],
- colHeaders: true,
- columnSorting: true
- });
- hot.sort(2, true); // ASC
- expect(hot.getDataAtRow(0)).toEqual(['Audi', 'A4 Avant', 'July 8th 1999', 33900]);
- expect(hot.getDataAtRow(1)).toEqual(['Opel', 'Astra', 'June 1st 2001', 7000]);
- expect(hot.getDataAtRow(2)).toEqual(['BMW', '320i Coupe', 'August 3rd 2001', 30500]);
- expect(hot.getDataAtRow(3)).toEqual(['Citroen', 'C4 Coupe', 'October 27th 2001', 8330]);
- expect(hot.getDataAtRow(4)).toEqual(['Mercedes', 'A 160', 'October 28th 2016', 6999.9999]);
- hot.sort(2, false); // DESC
- expect(hot.getDataAtRow(0)).toEqual(['Mercedes', 'A 160', 'October 28th 2016', 6999.9999]);
- expect(hot.getDataAtRow(1)).toEqual(['Citroen', 'C4 Coupe', 'October 27th 2001', 8330]);
- expect(hot.getDataAtRow(2)).toEqual(['BMW', '320i Coupe', 'August 3rd 2001', 30500]);
- expect(hot.getDataAtRow(3)).toEqual(['Opel', 'Astra', 'June 1st 2001', 7000]);
- expect(hot.getDataAtRow(4)).toEqual(['Audi', 'A4 Avant', 'July 8th 1999', 33900]);
- });
- it('should sort date columns along with empty and null values', function () {
- var hot = handsontable({
- data: [['Mercedes', 'A 160', '01/14/2006', 6999.9999], ['Citroen', 'C4 Coupe', '12/01/2008', 8330], ['Citroen', 'C4 Coupe null', null, 8330], ['Citroen', 'C4 Coupe empty', '', 8330], ['Audi', 'A4 Avant', '11/19/2011', 33900], ['Opel', 'Astra', '02/02/2004', 7000], ['BMW', '320i Coupe', '07/24/2011', 30500]],
- columns: [{}, {}, {
- type: 'date',
- dateFormat: 'mm/dd/yy'
- }, {
- type: 'numeric'
- }],
- colHeaders: true,
- columnSorting: true
- });
- hot.sort(2, true); // ASC
- expect(hot.getDataAtRow(0)).toEqual(['Mercedes', 'A 160', '01/14/2006', 6999.9999]);
- expect(hot.getDataAtRow(1)).toEqual(['Opel', 'Astra', '02/02/2004', 7000]);
- expect(hot.getDataAtRow(2)).toEqual(['BMW', '320i Coupe', '07/24/2011', 30500]);
- expect(hot.getDataAtRow(3)).toEqual(['Audi', 'A4 Avant', '11/19/2011', 33900]);
- expect(hot.getDataAtRow(4)).toEqual(['Citroen', 'C4 Coupe', '12/01/2008', 8330]);
- hot.sort(2, false); // DESC
- expect(hot.getDataAtRow(0)).toEqual(['Citroen', 'C4 Coupe', '12/01/2008', 8330]);
- expect(hot.getDataAtRow(1)).toEqual(['Audi', 'A4 Avant', '11/19/2011', 33900]);
- expect(hot.getDataAtRow(2)).toEqual(['BMW', '320i Coupe', '07/24/2011', 30500]);
- expect(hot.getDataAtRow(3)).toEqual(['Opel', 'Astra', '02/02/2004', 7000]);
- expect(hot.getDataAtRow(4)).toEqual(['Mercedes', 'A 160', '01/14/2006', 6999.9999]);
- });
- });
- describe('data type: time', function () {
- it('should properly rewrite time into correct format after sort', function (done) {
- var hot = handsontable({
- data: [['0:00:01 am'], ['5:30:14 pm'], ['8:00:00 pm'], ['11:15:05 am'], ['4:07:48 am']],
- columns: [{
- type: 'time',
- dateFormat: 'h:mm:ss a',
- correctFormat: true
- }],
- colHeaders: true,
- columnSorting: {
- column: 0,
- sortOrder: false
- }
- });
- hot.setDataAtCell(0, 0, '19:55', 'edit');
- setTimeout(function () {
- expect(hot.getDataAtCell(0, 0)).toEqual('7:55:00 pm');
- done();
- }, 250);
- });
- });
- it('should properly sort numeric data', function () {
- var hot = handsontable({
- data: [['Mercedes', 'A 160', '01/14/2006', '6999.9999'], ['Citroen', 'C4 Coupe', '12/01/2008', 8330], ['Citroen', 'C4 Coupe null', null, '8330'], ['Citroen', 'C4 Coupe empty', '', 8333], ['Audi', 'A4 Avant', '11/19/2011', '33900'], ['Opel', 'Astra', '02/02/2004', '7000'], ['BMW', '320i Coupe', '07/24/2011', 30500]],
- columns: [{}, {}, {}, {
- type: 'numeric'
- }],
- colHeaders: true,
- columnSorting: true
- });
- var htCore = getHtCore();
- this.sortByColumn(3);
- expect(hot.getDataAtCol(3)).toEqual(['6999.9999', '7000', 8330, '8330', 8333, 30500, '33900']);
- this.sortByColumn(3);
- expect(hot.getDataAtCol(3)).toEqual(['33900', 30500, 8333, 8330, '8330', '7000', '6999.9999']);
- this.sortByColumn(3);
- expect(hot.getDataAtCol(3)).toEqual(['6999.9999', 8330, '8330', 8333, '33900', '7000', 30500]);
- });
- it('numericSort comparing function shouldn\'t change order when comparing empty string, null and undefined', function () {
- var hot = handsontable({});
- var numericSort = hot.getPlugin('columnSorting').numericSort;
- expect(numericSort(false, {})(['key1', null], ['key2', null])).toEqual(0);
- expect(numericSort(false, {})(['key1', ''], ['key2', ''])).toEqual(0);
- expect(numericSort(false, {})(['key1', undefined], ['key2', undefined])).toEqual(0);
- expect(numericSort(false, {})(['key1', ''], ['key2', null])).toEqual(0);
- expect(numericSort(false, {})(['key1', null], ['key2', ''])).toEqual(0);
- expect(numericSort(false, {})(['key1', ''], ['key2', undefined])).toEqual(0);
- expect(numericSort(false, {})(['key1', undefined], ['key2', ''])).toEqual(0);
- expect(numericSort(false, {})(['key1', null], ['key2', undefined])).toEqual(0);
- expect(numericSort(false, {})(['key1', undefined], ['key2', null])).toEqual(0);
- });
- it('should sort table with multiple row headers', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'D'], [3, 'A'], [2, 'C']],
- columns: [{}, {}, {
- type: 'date',
- dateFormat: 'mm/dd/yy'
- }, {
- type: 'numeric'
- }],
- colHeaders: true,
- columnSorting: true,
- removeRowPlugin: true // this plugin ads an extra row header, so now we have 2 instead of 1
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- this.sortByColumn(0); // sort by first column
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('D');
- this.sortByColumn(1); // sort by second column
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('A');
- });
- it('should allow to define sorting column and order during initialization', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'D'], [3, 'A'], [2, 'C']],
- colHeaders: true,
- columnSorting: {
- column: 0,
- sortOrder: true
- }
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('D');
- });
- it('should allow to change sorting column with updateSettings', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'D'], [3, 'A'], [2, 'C']],
- colHeaders: true,
- columnSorting: {
- column: 0,
- sortOrder: true
- }
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('D');
- updateSettings({
- columnSorting: {
- column: 1,
- sortOrder: true
- }
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('3');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('A');
- });
- it('should allow to change sorting order with updateSettings', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'D'], [3, 'A'], [2, 'C']],
- colHeaders: true,
- columnSorting: {
- column: 0,
- sortOrder: true
- }
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- updateSettings({
- columnSorting: {
- column: 0,
- sortOrder: false
- }
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('3');
- });
- it('should allow to change if sorting empty cells with updateSettings', function () {
- var hot = handsontable({
- data: [[1, 'B'], [2, ''], [3, 'A'], [4, ''], [6, 'E'], [7, ''], [8, 'F']],
- colHeaders: true,
- columnSorting: {
- column: 1,
- sortOrder: false,
- sortEmptyCells: false
- }
- });
- updateSettings({
- columnSorting: {
- column: 1,
- sortOrder: true,
- sortEmptyCells: true
- }
- });
- // ASC with empty cells sorting
- expect(hot.getDataAtCol(0)).toEqual([2, 4, 7, 3, 1, 6, 8]);
- updateSettings({
- columnSorting: {
- column: 1,
- sortOrder: true,
- sortEmptyCells: false
- }
- });
- // ASC without empty cells sorting
- expect(hot.getDataAtCol(0)).toEqual([3, 1, 6, 8, 2, 4, 7]);
- });
- it('should NOT sort spare rows', function () {
- var myData = [{ a: 'aaa', b: 2, c: 3 }, { a: 'z', b: 11, c: -4 }, { a: 'dddd', b: 13, c: 13 }, { a: 'bbbb', b: 10, c: 11 }];
- function customIsEmptyRow(row) {
- var data = this.getSourceData();
- return data[row].isNew;
- }
- handsontable({
- data: myData,
- rowHeaders: true,
- colHeaders: ['A', 'B', 'C'],
- columns: [{ data: 'a', type: 'text' }, { data: 'b', type: 'text' }, { data: 'c', type: 'text' }],
- dataSchema: { isNew: true, a: false }, // default for a to avoid #bad value#
- columnSorting: true,
- minSpareRows: 3,
- isEmptyRow: customIsEmptyRow
- });
- // ASC
- updateSettings({
- columnSorting: {
- column: 0,
- sortOrder: true
- }
- });
- expect(getData()).toEqual([['aaa', 2, 3], ['bbbb', 10, 11], ['dddd', 13, 13], ['z', 11, -4], [false, null, null], [false, null, null], [false, null, null]]);
- updateSettings({
- columnSorting: {
- column: 0,
- sortOrder: false
- }
- });
- expect(getData()).toEqual([['z', 11, -4], ['dddd', 13, 13], ['bbbb', 10, 11], ['aaa', 2, 3], [false, null, null], [false, null, null], [false, null, null]]);
- });
- it('should reset column sorting with updateSettings', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'D'], [3, 'A'], [2, 'C']],
- colHeaders: true,
- columnSorting: {
- column: 0,
- sortOrder: true
- }
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- updateSettings({
- columnSorting: void 0
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- });
- it('should expose sort method when columnSorting is enabled', function () {
- var hot = handsontable();
- expect(hot.getSettings().columnSorting).toBeFalsy();
- expect(hot.sort).toBeUndefined();
- updateSettings({
- columnSorting: true
- });
- expect(hot.getSettings().columnSorting).toBe(true);
- expect(hot.sort).toBeDefined();
- expect(_typeof(hot.sort)).toBe('function');
- updateSettings({
- columnSorting: false
- });
- expect(hot.getSettings().columnSorting).toBeFalsy();
- expect(hot.sort).toBeUndefined();
- });
- it('should sort table using HOT.sort method', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'D'], [3, 'A'], [2, 'C']],
- columnSorting: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('0');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- expect(this.$container.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('2');
- hot.sort(0, true);
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('3');
- });
- it('should reset column sorting with updateSettings', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'D'], [3, 'A'], [2, 'C']],
- colHeaders: true,
- columnSorting: {
- column: 0,
- sortOrder: true
- }
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- updateSettings({
- columnSorting: void 0
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- });
- it('should fire beforeColumnSort event before sorting data', function () {
- var hot = handsontable({
- data: [[2], [4], [1], [3]],
- columnSorting: true
- });
- this.beforeColumnSortHandler = function () {
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('4');
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('3');
- };
- spyOn(this, 'beforeColumnSortHandler');
- hot.addHook('beforeColumnSort', this.beforeColumnSortHandler);
- var sortColumn = 0;
- var sortOrder = true;
- hot.sort(sortColumn, sortOrder);
- expect(this.beforeColumnSortHandler.calls.count()).toEqual(1);
- expect(this.beforeColumnSortHandler).toHaveBeenCalledWith(sortColumn, sortOrder, void 0, void 0, void 0, void 0);
- });
- it('should not sorting column when beforeColumnSort returns false', function (done) {
- var hot = handsontable({
- data: [[2], [4], [1], [3]],
- columnSorting: true,
- beforeColumnSort: function beforeColumnSort() {
- return false;
- }
- });
- hot.sort(0, true);
- setTimeout(function () {
- expect(spec().$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('2');
- expect(spec().$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('4');
- expect(spec().$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('1');
- expect(spec().$container.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('3');
- done();
- }, 200);
- });
- it('should add beforeColumnSort event listener in constructor', function () {
- var beforeColumnSortCallback = jasmine.createSpy('beforeColumnSortHandler');
- var hot = handsontable({
- data: [[2], [4], [1], [3]],
- columnSorting: true,
- beforeColumnSort: beforeColumnSortCallback
- });
- var sortColumn = 0;
- var sortOrder = true;
- hot.sort(sortColumn, sortOrder);
- expect(beforeColumnSortCallback.calls.count()).toEqual(1);
- expect(beforeColumnSortCallback).toHaveBeenCalledWith(sortColumn, sortOrder, void 0, void 0, void 0, void 0);
- });
- it('should fire afterColumnSort event before data has been sorted but before table render', function () {
- var hot = handsontable({
- data: [[2], [4], [1], [3]],
- columnSorting: true
- });
- var rendered = false;
- var afterColumnSortHandler = jasmine.createSpy('afterColumnSortHandler');
- var afterRenderSpy = jasmine.createSpy('afterRender');
- hot.addHook('afterColumnSort', function () {
- expect(rendered).toBe(false);
- afterColumnSortHandler.apply(afterColumnSortHandler, arguments);
- });
- hot.addHook('afterRender', function () {
- rendered = true;
- afterRenderSpy.apply(afterRenderSpy, arguments);
- });
- var sortColumn = 0;
- var sortOrder = true;
- afterRenderSpy.calls.reset();
- hot.sort(sortColumn, sortOrder);
- expect(afterColumnSortHandler.calls.count()).toBe(1);
- expect(afterColumnSortHandler).toHaveBeenCalledWith(sortColumn, sortOrder, void 0, void 0, void 0, void 0);
- expect(afterRenderSpy.calls.count()).toBe(1);
- });
- it('should add afterColumnSort event listener in constructor', function () {
- var afterColumnSortCallback = jasmine.createSpy('afterColumnSortHandler');
- var hot = handsontable({
- data: [[2], [4], [1], [3]],
- columnSorting: true,
- afterColumnSort: afterColumnSortCallback
- });
- var sortColumn = 0;
- var sortOrder = true;
- hot.sort(sortColumn, sortOrder);
- expect(afterColumnSortCallback.calls.count()).toEqual(1);
- expect(afterColumnSortCallback).toHaveBeenCalledWith(sortColumn, sortOrder, void 0, void 0, void 0, void 0);
- });
- it('should insert row when plugin is enabled, but table hasn\'t been sorted', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'D'], [3, 'A'], [2, 'C']],
- columnSorting: true
- });
- expect(countRows()).toEqual(4);
- expect(hot.sortColumn).toBeUndefined();
- alter('insert_row');
- expect(countRows()).toEqual(5);
- });
- it('should remove row when plugin is enabled, but table hasn\'t been sorted', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'D'], [3, 'A'], [2, 'C']],
- columnSorting: true
- });
- expect(countRows()).toEqual(4);
- expect(hot.sortColumn).toBeUndefined();
- alter('remove_row');
- expect(countRows()).toEqual(3);
- });
- it('should display new row added directly to dataSource, when observeChanges plugin is enabled', function (done) {
- var data = [[1, 'B'], [0, 'A'], [3, 'D'], [2, 'C']];
- var hot = handsontable({
- data: data,
- colHeaders: true,
- columnSorting: true,
- observeChanges: true
- });
- var htCore = getHtCore();
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('0');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- expect(htCore.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('2');
- this.sortByColumn(0);
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('1');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('2');
- expect(htCore.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('3');
- expect(htCore.find('tbody tr').length).toEqual(4);
- var afterChangesObservedCallback = jasmine.createSpy('afterChangesObservedCallback');
- hot.addHook('afterChangesObserved', afterChangesObservedCallback);
- data.push([5, 'E']);
- setTimeout(function () {
- expect(countRows()).toEqual(5);
- expect(spec().$container.find('tbody tr:eq(4) td:eq(0)').text()).toEqual('5');
- expect(spec().$container.find('tbody tr:eq(4) td:eq(1)').text()).toEqual('E');
- done();
- }, 200);
- });
- it('should not display new row added directly to dataSource, when observeChanges plugin is explicitly disabled', function (done) {
- var data = [[1, 'B'], [0, 'A'], [3, 'D'], [2, 'C']];
- var hot = handsontable({
- data: data,
- colHeaders: true,
- columnSorting: true,
- observeChanges: false
- });
- var afterChangesObservedCallback = jasmine.createSpy('afterChangesObservedCallback');
- hot.addHook('afterChangesObserved', afterChangesObservedCallback);
- var htCore = getHtCore();
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('0');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- expect(htCore.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('2');
- this.sortByColumn(0);
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('1');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('2');
- expect(htCore.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('3');
- expect(htCore.find('tbody tr').length).toEqual(4);
- data.push([5, 'E']);
- setTimeout(function () {
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('1');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('2');
- expect(htCore.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('3');
- expect(htCore.find('tbody tr').length).toEqual(4);
- expect(afterChangesObservedCallback).not.toHaveBeenCalled();
- done();
- }, 100);
- });
- it('should display new row added directly to dataSource, when observeChanges plugin status is undefined', function (done) {
- var data = [[1, 'B'], [0, 'A'], [3, 'D'], [2, 'C']];
- var onUpdateSettings = jasmine.createSpy('onUpdateSettings');
- var hot = handsontable({
- data: data,
- colHeaders: true,
- columnSorting: true,
- afterUpdateSettings: onUpdateSettings
- });
- var afterChangesObservedCallback = jasmine.createSpy('afterChangesObservedCallback');
- hot.addHook('afterChangesObserved', afterChangesObservedCallback);
- var htCore = getHtCore();
- // columnSorting enables observeChanges plugin by asynchronously invoking updateSettings
- setTimeout(function () {
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('0');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- expect(htCore.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('2');
- spec().sortByColumn(0);
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('1');
- expect(htCore.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('2');
- expect(htCore.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('3');
- expect(htCore.find('tbody tr').length).toEqual(4);
- data.push([5, 'E']);
- }, 100);
- setTimeout(function () {
- expect(countRows()).toEqual(5);
- expect(htCore.find('tbody tr:eq(4) td:eq(0)').text()).toEqual('5');
- expect(htCore.find('tbody tr:eq(4) td:eq(1)').text()).toEqual('E');
- done();
- }, 2000); // 2s delayed needs for safari env
- });
- it('should apply sorting when there are two tables and only one has sorting enabled and has been already sorted (#1020)', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'D'], [3, 'A'], [2, 'C']],
- columnSorting: {
- column: 1
- }
- });
- this.$container2 = $('<div id="' + id + '-2"></div>').appendTo('body');
- this.$container2.handsontable();
- var hot2 = this.$container2.handsontable('getInstance');
- selectCell(0, 1);
- keyDown('enter');
- expect($('.handsontableInput').val()).toEqual('A');
- this.$container2.handsontable('destroy');
- this.$container2.remove();
- });
- it('should reset sorting after loading new data', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'D'], [3, 'A'], [2, 'C']],
- columnSorting: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('0');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- expect(this.$container.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('2');
- hot.sort(0, true);
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('3');
- loadData([[50, 'E'], [10, 'G'], [30, 'F'], [60, 'I'], [40, 'J'], [20, 'H']]);
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('50');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('10');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('30');
- expect(this.$container.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('60');
- expect(this.$container.find('tbody tr:eq(4) td:eq(0)').text()).toEqual('40');
- expect(this.$container.find('tbody tr:eq(5) td:eq(0)').text()).toEqual('20');
- });
- it('should reset sorting after loading new data (default sorting column and order set)', function () {
- var hot = handsontable({
- data: [[1, 'B'], [0, 'D'], [3, 'A'], [2, 'C']],
- columnSorting: {
- column: 1,
- sortOrder: true
- }
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('3');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('0');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('A');
- expect(this.$container.find('tbody tr:eq(1) td:eq(1)').text()).toEqual('B');
- expect(this.$container.find('tbody tr:eq(2) td:eq(1)').text()).toEqual('C');
- expect(this.$container.find('tbody tr:eq(3) td:eq(1)').text()).toEqual('D');
- hot.sort(0, true);
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('0');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('3');
- loadData([[50, 'E'], [10, 'G'], [30, 'F'], [60, 'I'], [40, 'J'], [20, 'H']]);
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('50');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('30');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('10');
- expect(this.$container.find('tbody tr:eq(3) td:eq(0)').text()).toEqual('20');
- expect(this.$container.find('tbody tr:eq(4) td:eq(0)').text()).toEqual('60');
- expect(this.$container.find('tbody tr:eq(5) td:eq(0)').text()).toEqual('40');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('E');
- expect(this.$container.find('tbody tr:eq(1) td:eq(1)').text()).toEqual('F');
- expect(this.$container.find('tbody tr:eq(2) td:eq(1)').text()).toEqual('G');
- expect(this.$container.find('tbody tr:eq(3) td:eq(1)').text()).toEqual('H');
- expect(this.$container.find('tbody tr:eq(4) td:eq(1)').text()).toEqual('I');
- expect(this.$container.find('tbody tr:eq(5) td:eq(1)').text()).toEqual('J');
- });
- it('should return updated data at specyfied row after sorted', function () {
- var hot = handsontable({
- data: [[1, 'Ted', 'Right'], [2, 'Frank', 'Honest'], [3, 'Joan', 'Well'], [4, 'Sid', 'Strong'], [5, 'Jane', 'Neat']],
- colHeaders: true,
- rowHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(0);
- expect(getDataAtRow(0)).toEqual([1, 'Ted', 'Right']);
- expect(getDataAtRow(4)).toEqual([5, 'Jane', 'Neat']);
- this.sortByColumn(0);
- expect(getDataAtRow(0)).toEqual([5, 'Jane', 'Neat']);
- expect(getDataAtRow(4)).toEqual([1, 'Ted', 'Right']);
- this.sortByColumn(0);
- expect(getDataAtRow(0)).toEqual([1, 'Ted', 'Right']);
- expect(getDataAtRow(4)).toEqual([5, 'Jane', 'Neat']);
- });
- it('should return updated data at specyfied col after sorted', function () {
- var hot = handsontable({
- data: [[1, 'Ted', 'Right'], [2, 'Frank', 'Honest'], [3, 'Joan', 'Well'], [4, 'Sid', 'Strong'], [5, 'Jane', 'Neat']],
- colHeaders: true,
- rowHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual([1, 2, 3, 4, 5]);
- expect(getDataAtCol(1)).toEqual(['Ted', 'Frank', 'Joan', 'Sid', 'Jane']);
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual([5, 4, 3, 2, 1]);
- expect(getDataAtCol(1)).toEqual(['Jane', 'Sid', 'Joan', 'Frank', 'Ted']);
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual([1, 2, 3, 4, 5]);
- expect(getDataAtCol(1)).toEqual(['Ted', 'Frank', 'Joan', 'Sid', 'Jane']);
- });
- it('should return original data source at specified row after sorted', function () {
- var hot = handsontable({
- data: [[1, 'Ted', 'Right'], [2, 'Frank', 'Honest'], [3, 'Joan', 'Well'], [4, 'Sid', 'Strong'], [5, 'Jane', 'Neat']],
- colHeaders: true,
- rowHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(0);
- expect(getDataAtRow(0)).toEqual([1, 'Ted', 'Right']);
- expect(getDataAtRow(4)).toEqual([5, 'Jane', 'Neat']);
- expect(getSourceDataAtRow(0)).toEqual([1, 'Ted', 'Right']);
- expect(getSourceDataAtRow(4)).toEqual([5, 'Jane', 'Neat']);
- this.sortByColumn(0);
- expect(getDataAtRow(0)).toEqual([5, 'Jane', 'Neat']);
- expect(getDataAtRow(4)).toEqual([1, 'Ted', 'Right']);
- expect(getSourceDataAtRow(0)).toEqual([1, 'Ted', 'Right']);
- expect(getSourceDataAtRow(4)).toEqual([5, 'Jane', 'Neat']);
- });
- it('should return original data source at specified col after sorted', function () {
- var hot = handsontable({
- data: [[1, 'Ted', 'Right'], [2, 'Frank', 'Honest'], [3, 'Joan', 'Well'], [4, 'Sid', 'Strong'], [5, 'Jane', 'Neat']],
- colHeaders: true,
- rowHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual([1, 2, 3, 4, 5]);
- expect(getDataAtCol(1)).toEqual(['Ted', 'Frank', 'Joan', 'Sid', 'Jane']);
- expect(getSourceDataAtCol(0)).toEqual([1, 2, 3, 4, 5]);
- expect(getSourceDataAtCol(1)).toEqual(['Ted', 'Frank', 'Joan', 'Sid', 'Jane']);
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual([5, 4, 3, 2, 1]);
- expect(getDataAtCol(1)).toEqual(['Jane', 'Sid', 'Joan', 'Frank', 'Ted']);
- expect(getSourceDataAtCol(0)).toEqual([1, 2, 3, 4, 5]);
- expect(getSourceDataAtCol(1)).toEqual(['Ted', 'Frank', 'Joan', 'Sid', 'Jane']);
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual([1, 2, 3, 4, 5]);
- expect(getDataAtCol(1)).toEqual(['Ted', 'Frank', 'Joan', 'Sid', 'Jane']);
- expect(getSourceDataAtCol(0)).toEqual([1, 2, 3, 4, 5]);
- expect(getSourceDataAtCol(1)).toEqual(['Ted', 'Frank', 'Joan', 'Sid', 'Jane']);
- });
- it('should ignore case when sorting', function () {
- var hot = handsontable({
- data: [[1, 'albuquerque'], [2, 'Alabama'], [3, 'Missouri']],
- colHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(1);
- expect(getDataAtCol(0)).toEqual([2, 1, 3]);
- expect(getDataAtCol(1)).toEqual(['Alabama', 'albuquerque', 'Missouri']);
- this.sortByColumn(1);
- expect(getDataAtCol(0)).toEqual([3, 1, 2]);
- expect(getDataAtCol(1)).toEqual(['Missouri', 'albuquerque', 'Alabama']);
- });
- it('should push empty cells to the end of sorted column', function () {
- var hot = handsontable({
- data: [[1, 'Ted', 'Right'], [2, '', 'Honest'], [3, '', 'Well'], [4, 'Sid', 'Strong'], [5, 'Jane', 'Neat']],
- colHeaders: true,
- rowHeaders: true,
- columnSorting: true,
- minSpareRows: 1
- });
- this.sortByColumn(1);
- expect(getDataAtCol(0)).toEqual([5, 4, 1, 2, 3, null]);
- expect(getDataAtCol(1)).toEqual(['Jane', 'Sid', 'Ted', '', '', null]);
- this.sortByColumn(1);
- expect(getDataAtCol(0)).toEqual([1, 4, 5, 2, 3, null]);
- expect(getDataAtCol(1)).toEqual(['Ted', 'Sid', 'Jane', '', '', null]);
- });
- it('should push numeric values before non-numeric values, when sorting ascending using the default sorting function', function () {
- var hot = handsontable({
- data: [[1, 'Ted', 123], [2, '', 'Some'], [3, '', 321], [4, 'Sid', 'String'], [5, 'Jane', 46]],
- colHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(2);
- expect(getDataAtCol(2)).toEqual([46, 123, 321, 'Some', 'String']);
- this.sortByColumn(2);
- expect(getDataAtCol(2)).toEqual(['String', 'Some', 321, 123, 46]);
- });
- it('should add a sorting indicator to the column header after it\'s been sorted, only if sortIndicator property is set to true', function () {
- var hot = handsontable({
- data: [[1, 'Ted', 'Right'], [2, '', 'Honest'], [3, '', 'Well'], [4, 'Sid', 'Strong'], [5, 'Jane', 'Neat']],
- colHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(1);
- var sortedColumn = this.$container.find('th span.columnSorting')[1],
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue === '' || afterValue === 'none').toBe(true);
- // ---------------------------------
- // INDICATOR SET FOR THE WHOLE TABLE
- // ---------------------------------
- hot.updateSettings({
- sortIndicator: true
- });
- this.sortByColumn(1);
- // descending (updateSettings doesn't reset sorting stack)
- sortedColumn = this.$container.find('th span.columnSorting')[1];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9660))).toBeGreaterThan(-1);
- this.sortByColumn(1);
- sortedColumn = this.$container.find('th span.columnSorting')[1];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue === '' || afterValue === 'none').toBe(true);
- this.sortByColumn(1);
- // ascending
- sortedColumn = this.$container.find('th span.columnSorting')[1];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9650))).toBeGreaterThan(-1);
- // ---------------------------------
- // INDICATOR SET FOR A SINGLE COLUMN
- // ---------------------------------
- hot.updateSettings({
- sortIndicator: void 0,
- columns: [{}, {}, { sortIndicator: true }]
- });
- this.sortByColumn(0);
- sortedColumn = this.$container.find('th span.columnSorting')[0];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue === '' || afterValue === 'none').toBe(true);
- this.sortByColumn(1);
- // descending
- sortedColumn = this.$container.find('th span.columnSorting')[1];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue === '' || afterValue === 'none').toBe(true);
- this.sortByColumn(2);
- sortedColumn = this.$container.find('th span.columnSorting')[2];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9650))).toBeGreaterThan(-1);
- });
- it('should change sorting indicator state on every `hot.sort()` method call (continuously for the same column)', function () {
- var hot = handsontable({
- data: [[1, 'Ted', 'Right'], [2, '', 'Honest'], [3, '', 'Well'], [4, 'Sid', 'Strong'], [5, 'Jane', 'Neat']],
- colHeaders: true,
- columnSorting: true,
- sortIndicator: true
- });
- hot.sort(1);
- // ascending
- var sortedColumn = this.$container.find('th span.columnSorting')[1];
- var afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9650))).toBeGreaterThan(-1);
- hot.sort(1);
- // descending
- sortedColumn = this.$container.find('th span.columnSorting')[1];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9660))).toBeGreaterThan(-1);
- hot.sort(1);
- sortedColumn = this.$container.find('th span.columnSorting')[1];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue === '' || afterValue === 'none').toBe(true);
- hot.sort(1);
- // ascending
- sortedColumn = this.$container.find('th span.columnSorting')[1];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9650))).toBeGreaterThan(-1);
- hot.sort(1);
- // descending
- sortedColumn = this.$container.find('th span.columnSorting')[1];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9660))).toBeGreaterThan(-1);
- });
- it('should change sorting indicator state on every `hot.sort()` method (calling for different columns)', function () {
- var hot = handsontable({
- data: [[1, 'Ted', 'Right'], [2, '', 'Honest'], [3, '', 'Well'], [4, 'Sid', 'Strong'], [5, 'Jane', 'Neat']],
- colHeaders: true,
- columnSorting: true,
- sortIndicator: true
- });
- hot.sort(1);
- // ascending
- var sortedColumn = this.$container.find('th span.columnSorting')[1];
- var afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9650))).toBeGreaterThan(-1);
- hot.sort(2);
- // ascending
- sortedColumn = this.$container.find('th span.columnSorting')[2];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9650))).toBeGreaterThan(-1);
- hot.sort(1);
- // ascending
- sortedColumn = this.$container.find('th span.columnSorting')[1];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9650))).toBeGreaterThan(-1);
- hot.sort(2, false);
- // descending
- sortedColumn = this.$container.find('th span.columnSorting')[2];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9660))).toBeGreaterThan(-1);
- hot.sort(2, false);
- // descending
- sortedColumn = this.$container.find('th span.columnSorting')[2];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9660))).toBeGreaterThan(-1);
- hot.sort(2, true);
- // ascending
- sortedColumn = this.$container.find('th span.columnSorting')[2];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9650))).toBeGreaterThan(-1);
- });
- it('should change sorting indicator state when initial column sorting was provided', function () {
- var hot = handsontable({
- data: [[1, 'Ted', 'Right'], [2, '', 'Honest'], [3, '', 'Well'], [4, 'Sid', 'Strong'], [5, 'Jane', 'Neat']],
- colHeaders: true,
- columnSorting: {
- column: 1,
- sortOrder: false
- },
- sortIndicator: true
- });
- // descending
- var sortedColumn = this.$container.find('th span.columnSorting')[1];
- var afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9660))).toBeGreaterThan(-1);
- hot.sort(1);
- // default
- sortedColumn = this.$container.find('th span.columnSorting')[1];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue === '' || afterValue === 'none').toBe(true);
- hot.sort(1);
- // ascending
- sortedColumn = this.$container.find('th span.columnSorting')[1];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9650))).toBeGreaterThan(-1);
- hot.sort(1);
- // descending
- sortedColumn = this.$container.find('th span.columnSorting')[1];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue.indexOf(String.fromCharCode(9660))).toBeGreaterThan(-1);
- hot.sort(1);
- // default
- sortedColumn = this.$container.find('th span.columnSorting')[1];
- afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');
- expect(afterValue === '' || afterValue === 'none').toBe(true);
- });
- it('should properly sort the table, when it\'s scrolled to the far right', function () {
- var data = [['Jasmine Ferguson', 'Britney Carey', 'Kelly Decker', 'Lacey Mcleod', 'Leona Shaffer', 'Kelli Ochoa', 'Adele Roberson', 'Viola Snow', 'Barron Cherry', 'Calhoun Lane', 'Elvia Andrews', 'Katheryn Dale', 'Dorthy Hale', 'Munoz Randall', 'Fields Morse', 'Hubbard Nichols', 'Chang Yang', 'Osborn Anthony', 'Owens Warner', 'Gloria Hampton'], ['Lane Hill', 'Belinda Mathews', 'York Gray', 'Celina Stone', 'Victoria Mays', 'Angelina Lott', 'Joyce Mason', 'Shawn Rodriguez', 'Susanna Mayo', 'Wolf Fuller', 'Long Hester', 'Dudley Doyle', 'Wilder Sutton', 'Oneal Avery', 'James Mclaughlin', 'Lenora Guzman', 'Mcmahon Sullivan', 'Abby Weeks', 'Beverly Joseph', 'Rosalind Church'], ['Myrtle Landry', 'Hays Huff', 'Hernandez Benjamin', 'Mclaughlin Garza', 'Franklin Barton', 'Lara Buchanan', 'Ratliff Beck', 'Rosario Munoz', 'Isabelle Dalton', 'Smith Woodard', 'Marjorie Marshall', 'Spears Stein', 'Brianna Bowman', 'Marci Clay', 'Palmer Harrell', 'Ball Levy', 'Shelley Mendoza', 'Morrow Glass', 'Baker Knox', 'Adrian Holman'], ['Trisha Howell', 'Brooke Harrison', 'Anthony Watkins', 'Ellis Cobb', 'Sheppard Dillon', 'Mathis Bray', 'Foreman Burns', 'Lina Glenn', 'Giles Pollard', 'Weiss Ballard', 'Lynnette Smith', 'Flores Kline', 'Graciela Singleton', 'Santiago Mcclure', 'Claudette Battle', 'Nita Holloway', 'Eula Wolfe', 'Pruitt Stokes', 'Felicia Briggs', 'Melba Bradshaw']];
- var hot = handsontable({
- data: data,
- colHeaders: true,
- columnSorting: true
- });
- hot.view.wt.wtOverlays.leftOverlay.scrollTo(15);
- hot.render();
- hot.sort(15);
- expect(getDataAtCell(0, 15)).toEqual('Ball Levy');
- expect(getDataAtCell(1, 15)).toEqual('Hubbard Nichols');
- expect(getDataAtCell(2, 15)).toEqual('Lenora Guzman');
- expect(getDataAtCell(3, 15)).toEqual('Nita Holloway');
- hot.sort(15);
- expect(getDataAtCell(3, 15)).toEqual('Ball Levy');
- expect(getDataAtCell(2, 15)).toEqual('Hubbard Nichols');
- expect(getDataAtCell(1, 15)).toEqual('Lenora Guzman');
- expect(getDataAtCell(0, 15)).toEqual('Nita Holloway');
- hot.sort(15);
- expect(getDataAtCell(0, 15)).toEqual('Hubbard Nichols');
- expect(getDataAtCell(1, 15)).toEqual('Lenora Guzman');
- expect(getDataAtCell(2, 15)).toEqual('Ball Levy');
- expect(getDataAtCell(3, 15)).toEqual('Nita Holloway');
- });
- it('should allow specifiyng a custom sorting function', function () {
- var data = [['1 inch'], ['1 yard'], ['2 feet'], ['0.2 miles']];
- var hot = handsontable({
- data: data,
- colHeaders: true,
- columnSorting: true,
- columns: [{
- sortFunction: function sortFunction(sortOrder) {
- return function (a, b) {
- var unitsRatios = {
- inch: 1,
- yard: 36,
- feet: 12,
- miles: 63360
- };
- var newA = a[1],
- newB = b[1];
- Handsontable.helper.objectEach(unitsRatios, function (val, prop) {
- if (a[1].indexOf(prop) > -1) {
- newA = parseFloat(a[1].replace(prop, '')) * val;
- return false;
- }
- });
- Handsontable.helper.objectEach(unitsRatios, function (val, prop) {
- if (b[1].indexOf(prop) > -1) {
- newB = parseFloat(b[1].replace(prop, '')) * val;
- return false;
- }
- });
- if (newA < newB) {
- return sortOrder ? -1 : 1;
- }
- if (newA > newB) {
- return sortOrder ? 1 : -1;
- }
- return 0;
- };
- }
- }]
- });
- expect(getDataAtCell(0, 0)).toEqual('1 inch');
- expect(getDataAtCell(1, 0)).toEqual('1 yard');
- expect(getDataAtCell(2, 0)).toEqual('2 feet');
- expect(getDataAtCell(3, 0)).toEqual('0.2 miles');
- hot.sort(0);
- expect(getDataAtCell(0, 0)).toEqual('1 inch');
- expect(getDataAtCell(1, 0)).toEqual('2 feet');
- expect(getDataAtCell(2, 0)).toEqual('1 yard');
- expect(getDataAtCell(3, 0)).toEqual('0.2 miles');
- hot.sort(0);
- expect(getDataAtCell(0, 0)).toEqual('0.2 miles');
- expect(getDataAtCell(1, 0)).toEqual('1 yard');
- expect(getDataAtCell(2, 0)).toEqual('2 feet');
- expect(getDataAtCell(3, 0)).toEqual('1 inch');
- hot.sort(0);
- expect(getDataAtCell(0, 0)).toEqual('1 inch');
- expect(getDataAtCell(1, 0)).toEqual('1 yard');
- expect(getDataAtCell(2, 0)).toEqual('2 feet');
- expect(getDataAtCell(3, 0)).toEqual('0.2 miles');
- });
- it('should properly sort integers with nulls', function () {
- var hot = handsontable({
- data: [['12'], [null], ['10'], ['-5'], [null], ['1000']],
- colHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual(['-5', '10', '12', '1000', null, null]);
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual(['1000', '12', '10', '-5', null, null]);
- });
- it('should properly sort floating points', function () {
- var hot = handsontable({
- data: [['0.0561'], ['-10.67'], ['-4.1'], ['-0.01'], ['-127'], ['1000']],
- colHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual(['-127', '-10.67', '-4.1', '-0.01', '0.0561', '1000']);
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual(['1000', '0.0561', '-0.01', '-4.1', '-10.67', '-127']);
- });
- it('should properly sort floating points with nulls', function () {
- var hot = handsontable({
- data: [['0.0561'], ['-10.67'], [null], ['-4.1'], ['-0.01'], [null], ['-127'], ['1000'], [null]],
- colHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual(['-127', '-10.67', '-4.1', '-0.01', '0.0561', '1000', null, null, null]);
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual(['1000', '0.0561', '-0.01', '-4.1', '-10.67', '-127', null, null, null]);
- });
- it('should properly sort floating points with non-numerical values', function () {
- var hot = handsontable({
- data: [['0.0561'], ['-10.67'], ['a'], ['-4.1'], ['-0.01'], ['b'], ['-127'], ['1000'], ['hello']],
- colHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual(['-127', '-10.67', '-4.1', '-0.01', '0.0561', '1000', 'a', 'b', 'hello']);
- this.sortByColumn(0);
- expect(getDataAtCol(0)).toEqual(['hello', 'b', 'a', '1000', '0.0561', '-0.01', '-4.1', '-10.67', '-127']);
- });
- it('should modify row translating process when soring is applied (visual to physical and vice versa)', function () {
- var hot = handsontable({
- data: [[2], [4], [1], [3]],
- colHeaders: true,
- columnSorting: true
- });
- this.sortByColumn(0);
- expect(hot.toPhysicalRow(0)).toBe(2);
- expect(hot.toPhysicalRow(1)).toBe(0);
- expect(hot.toPhysicalRow(2)).toBe(3);
- expect(hot.toPhysicalRow(3)).toBe(1);
- expect(hot.toVisualRow(0)).toBe(1);
- expect(hot.toVisualRow(1)).toBe(3);
- expect(hot.toVisualRow(2)).toBe(0);
- expect(hot.toVisualRow(3)).toBe(2);
- });
- describe('should return sorted properly data when maxRows or / and minSpareRow options are set', function () {
- var testSorting = function testSorting(desc, config, result) {
- it(desc, function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(config.rows, config.columns),
- maxRows: config.maxRow,
- minSpareRows: config.minSpareRows,
- columnSorting: {
- column: config.sortByColumnIndex,
- sortOrder: config.sortOrder
- }
- });
- expect(getData().length).toEqual(result.dataLength);
- for (var i = 0; i < result.expectations.length; i += 1) {
- expect(getDataAtCell(result.expectations[i].rowIndex, result.expectations[i].columnIndex)).toEqual(result.expectations[i].value);
- }
- });
- };
- testSorting('maxRows < data.length', { rows: 9, columns: 9, maxRow: 6, sortByColumnIndex: 1, sortOrder: false }, { dataLength: 6, expectations: [{ rowIndex: 0, columnIndex: 2, value: 'C6' }] });
- testSorting('maxRows > data.length', { rows: 8, columns: 8, maxRow: 20, sortByColumnIndex: 1, sortOrder: false }, { dataLength: 8, expectations: [{ rowIndex: 0, columnIndex: 2, value: 'C8' }] });
- testSorting('minSpareRows is set; maxRows < data.length', { rows: 9, columns: 9, maxRow: 5, minSpareRows: 3, sortByColumnIndex: 1, sortOrder: false }, { dataLength: 5, expectations: [{ rowIndex: 0, columnIndex: 2, value: 'C5' }] });
- testSorting('minSpareRows is set; maxRows === data.length', { rows: 6, columns: 6, maxRow: 9, minSpareRows: 3, sortByColumnIndex: 1, sortOrder: false }, { dataLength: 6 + 3, expectations: [{ rowIndex: 0, columnIndex: 2, value: 'C6' }] });
- testSorting('minSpareRows is set; maxRows > data.length', { rows: 9, columns: 9, maxRow: 15, minSpareRows: 2, sortByColumnIndex: 1, sortOrder: false }, { dataLength: 9 + 2, expectations: [{ rowIndex: 0, columnIndex: 2, value: 'C9' }] });
- });
- });
- /***/ }),
- /* 129 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Comments', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('Enabling the plugin', function () {
- it('should enable the plugin in the initial config', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- comments: true
- });
- expect(hot.getPlugin('comments').isEnabled()).toBe(true);
- });
- it('should enable the plugin using updateSettings', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4)
- });
- expect(hot.getPlugin('comments').isEnabled()).toBe(false);
- updateSettings({
- comments: true
- });
- expect(hot.getPlugin('comments').isEnabled()).toBe(true);
- });
- });
- describe('Styling', function () {
- it('should display comment indicators in the appropriate cells', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- comments: true,
- cell: [{ row: 1, col: 1, comment: { value: 'test' } }, { row: 2, col: 2, comment: { value: 'test' } }]
- });
- expect(getCell(1, 1).className.indexOf('htCommentCell')).toBeGreaterThan(-1);
- expect(getCell(2, 2).className.indexOf('htCommentCell')).toBeGreaterThan(-1);
- });
- });
- describe('API', function () {
- it('should return the comment from a proper cell, when using the getCommentAtCell method', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- comments: true,
- cell: [{ row: 1, col: 1, comment: { value: 'test' } }, { row: 2, col: 2, comment: { value: 'another test' } }]
- });
- var plugin = hot.getPlugin('comments');
- expect(plugin.getCommentAtCell(1, 1)).toEqual('test');
- expect(plugin.getCommentAtCell(2, 2)).toEqual('another test');
- });
- it('should return the comment from a proper cell, when using the setRange and getComment methods', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- comments: true,
- cell: [{ row: 1, col: 1, comment: { value: 'test' } }, { row: 2, col: 2, comment: { value: 'another test' } }]
- });
- var plugin = hot.getPlugin('comments');
- plugin.setRange({ from: { row: 1, col: 1 } });
- expect(plugin.getComment()).toEqual('test');
- plugin.setRange({ from: { row: 2, col: 2 } });
- expect(plugin.getComment()).toEqual('another test');
- });
- it('should allow inserting comments using the `setCommentAtCell` method', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- comments: true
- });
- var plugin = hot.getPlugin('comments');
- expect(getCellMeta(1, 1).comment).toEqual(void 0);
- plugin.setCommentAtCell(1, 1, 'test comment');
- expect(getCellMeta(1, 1).comment.value).toEqual('test comment');
- });
- it('should trigger `afterSetCellMeta` callback when `setCommentAtCell` function is invoked', function () {
- var afterSetCellMetaCallback = jasmine.createSpy('afterSetCellMetaCallback');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- comments: true,
- afterSetCellMeta: afterSetCellMetaCallback
- });
- var plugin = hot.getPlugin('comments');
- plugin.setCommentAtCell(1, 1, 'Added comment');
- expect(afterSetCellMetaCallback).toHaveBeenCalledWith(1, 1, 'comment', { value: 'Added comment' }, undefined, undefined);
- });
- it('should allow removing comments using the `removeCommentAtCell` method', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- comments: true,
- cell: [{ row: 1, col: 1, comment: { value: 'test' } }]
- });
- var plugin = hot.getPlugin('comments');
- expect(getCellMeta(1, 1).comment.value).toEqual('test');
- plugin.removeCommentAtCell(1, 1);
- expect(getCellMeta(1, 1).comment).toEqual(void 0);
- });
- it('should trigger `afterSetCellMeta` callback when `removeCommentAtCell` function is invoked', function () {
- var afterSetCellMetaCallback = jasmine.createSpy('afterSetCellMetaCallback');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- comments: true,
- cell: [{ row: 1, col: 1, comment: { value: 'test' } }],
- afterSetCellMeta: afterSetCellMetaCallback
- });
- var plugin = hot.getPlugin('comments');
- plugin.removeCommentAtCell(1, 1);
- expect(afterSetCellMetaCallback).toHaveBeenCalledWith(1, 1, 'comment', undefined, undefined, undefined);
- });
- it('should allow opening the comment editor using the `showAtCell` method', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- comments: true
- });
- var plugin = hot.getPlugin('comments');
- var editor = plugin.editor.getInputElement();
- expect(editor.parentNode.style.display).toEqual('none');
- plugin.showAtCell(1, 1);
- expect(editor.parentNode.style.display).toEqual('block');
- });
- it('should allow closing the comment editor using the `hide` method', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- comments: true
- });
- var plugin = hot.getPlugin('comments');
- var editor = plugin.editor.getInputElement();
- plugin.showAtCell(1, 1);
- expect(editor.parentNode.style.display).toEqual('block');
- plugin.hide();
- expect(editor.parentNode.style.display).toEqual('none');
- });
- });
- it('`updateCommentMeta` & `setComment` functions should extend cellMetaObject properly', function () {
- var comment, readOnly;
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- comments: true
- });
- var plugin = hot.getPlugin('comments');
- setCellMeta(0, 0, 'comment', { readOnly: true });
- plugin.updateCommentMeta(0, 0, { value: 'Test' });
- comment = getCellMeta(0, 0).comment;
- readOnly = comment && comment.readOnly;
- expect(readOnly).toEqual(true);
- plugin.setRange({ from: { row: 0, col: 0 }, to: { row: 0, col: 0 } });
- plugin.setComment('Test2');
- comment = getCellMeta(0, 0).comment;
- readOnly = comment && comment.readOnly;
- expect(readOnly).toEqual(true);
- });
- describe('Using the Context Menu', function () {
- it('should open the comment editor when clicking the "Add comment" entry', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- comments: true
- });
- selectCell(1, 1);
- contextMenu();
- var addCommentButton = $('.htItemWrapper').filter(function () {
- return $(this).text() === 'Add comment';
- })[0];
- $(addCommentButton).simulate('mousedown');
- var editor = hot.getPlugin('comments').editor.getInputElement();
- expect($(editor).parents('.htComments')[0].style.display).toEqual('block');
- });
- it('should remove the comment from a cell after clicking the "Delete comment" entry', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- comments: true,
- cell: [{ row: 1, col: 1, comment: { value: 'Test comment' } }]
- });
- expect(getCellMeta(1, 1).comment.value).toEqual('Test comment');
- selectCell(1, 1);
- contextMenu();
- var deleteCommentButton = $('.htItemWrapper').filter(function () {
- return $(this).text() === 'Delete comment';
- })[0];
- $(deleteCommentButton).simulate('mousedown');
- expect(getCellMeta(1, 1).comment).toEqual(void 0);
- });
- it('should remove comments from a selected group of cells after clicking the "Delete comment" entry', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- comments: true,
- cell: [{ row: 1, col: 1, comment: { value: 'Test comment' } }, { row: 2, col: 2, comment: { value: 'Test comment 2' } }]
- });
- expect(getCellMeta(1, 1).comment.value).toEqual('Test comment');
- expect(getCellMeta(2, 2).comment.value).toEqual('Test comment 2');
- selectCell(1, 1, 2, 2);
- contextMenu();
- var deleteCommentButton = $('.htItemWrapper').filter(function () {
- return $(this).text() === 'Delete comment';
- })[0];
- $(deleteCommentButton).simulate('mousedown');
- expect(getCellMeta(1, 1).comment).toEqual(void 0);
- expect(getCellMeta(2, 2).comment).toEqual(void 0);
- });
- it('should make the comment editor\'s textarea read-only after clicking the "Read only comment" entry', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- comments: true,
- cell: [{ row: 1, col: 1, comment: { value: 'Test comment' } }]
- });
- selectCell(1, 1);
- contextMenu();
- var editor = hot.getPlugin('comments').editor.getInputElement();
- expect($(editor)[0].readOnly).toBe(false);
- var readOnlyComment = $('.htItemWrapper').filter(function () {
- return $(this).text() === 'Read only comment';
- })[0];
- $(readOnlyComment).simulate('mousedown');
- $(document).simulate('mouseup');
- $(getCell(1, 1)).simulate('mouseover', {
- clientX: Handsontable.dom.offset(getCell(1, 1)).left + 5,
- clientY: Handsontable.dom.offset(getCell(1, 1)).top + 5
- });
- setTimeout(function () {
- expect($(editor)[0].readOnly).toBe(true);
- done();
- }, 550);
- });
- });
- describe('Hooks invoked after changing cell meta', function () {
- it('should trigger `afterSetCellMeta` callback after deleting comment by context menu', function () {
- var afterSetCellMetaCallback = jasmine.createSpy('afterSetCellMetaCallback');
- var rows = 10,
- columns = 10;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(rows, columns),
- rowHeaders: true,
- colHeaders: true,
- contextMenu: true,
- comments: true,
- columns: function columns() {
- return {
- comment: {
- value: 'test'
- }
- };
- },
- afterSetCellMeta: afterSetCellMetaCallback
- });
- expect(afterSetCellMetaCallback).not.toHaveBeenCalled();
- selectCell(1, 1);
- contextMenu();
- var deleteCommentButton = $('.htItemWrapper').filter(function () {
- return $(this).text() === 'Delete comment';
- })[0];
- $(deleteCommentButton).simulate('mousedown');
- expect(afterSetCellMetaCallback).toHaveBeenCalledWith(1, 1, 'comment', undefined, undefined, undefined);
- });
- // Don't work in PhantomJS
- // It will work probably when #3961 will be fixed
- xit('should trigger `afterSetCellMeta` callback after editing comment by context menu', function (done) {
- var afterSetCellMetaCallback = jasmine.createSpy('afterSetCellMetaCallback');
- var rows = 10,
- columns = 10;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(rows, columns),
- rowHeaders: true,
- colHeaders: true,
- contextMenu: true,
- comments: true,
- columns: function columns() {
- return {
- comment: {
- value: 'test'
- }
- };
- },
- afterSetCellMeta: afterSetCellMetaCallback
- });
- selectCell(0, 0);
- contextMenu();
- var editCommentButton = $('.htItemWrapper').filter(function () {
- return $(this).text() === 'Edit comment';
- })[0];
- $(editCommentButton).simulate('mousedown');
- setTimeout(function () {
- $('.htCommentTextArea').val('Edited comment');
- // changing focus
- $('body').simulate('mousedown');
- setTimeout(function () {
- expect(afterSetCellMetaCallback).toHaveBeenCalledWith(0, 0, 'comment', { value: 'Edited comment' }, undefined, undefined);
- done();
- }, 100);
- }, 100);
- });
- });
- });
- /***/ }),
- /* 130 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('ContextMenu', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('alignment', function () {
- it('should align text left', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- var button = contextSubMenu.find('.ht_master .htCore tbody td').not('.htSeparator').eq(0);
- button.simulate('mousedown'); // Text left
- expect(getCellMeta(0, 0).className).toEqual('htLeft');
- expect(getCell(0, 0).className).toContain('htLeft');
- done();
- }, 350);
- });
- it('should align text center', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- var button = contextSubMenu.find('.ht_master .htCore tbody td').not('.htSeparator').eq(1);
- button.simulate('mousedown'); // Text center
- expect(getCellMeta(0, 0).className).toEqual('htCenter');
- expect(getCell(0, 0).className).toContain('htCenter');
- done();
- }, 350);
- });
- it('should align text right', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- var button = contextSubMenu.find('.ht_master .htCore tbody td').not('.htSeparator').eq(2);
- button.simulate('mousedown'); // Text right
- expect(getCellMeta(0, 0).className).toEqual('htRight');
- expect(getCell(0, 0).className).toContain('htRight');
- done();
- }, 350);
- });
- it('should justify text', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- var button = contextSubMenu.find('.ht_master .htCore tbody td').not('.htSeparator').eq(3);
- button.simulate('mousedown'); // Text justify
- deselectCell();
- expect(getCellMeta(0, 0).className).toEqual('htJustify');
- expect(getCell(0, 0).className).toContain('htJustify');
- done();
- }, 350); // menu opens after 300ms
- });
- it('should vertical align text top', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- var button = contextSubMenu.find('.ht_master .htCore tbody td').not('.htSeparator').eq(4);
- button.simulate('mousedown'); // Text top
- deselectCell();
- expect(getCellMeta(0, 0).className).toEqual('htTop');
- expect(getCell(0, 0).className).toContain('htTop');
- done();
- }, 350); // menu opens after 300ms
- });
- it('should vertical align text middle', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- var button = contextSubMenu.find('.ht_master .htCore tbody td').not('.htSeparator').eq(5);
- button.simulate('mousedown'); // Text middle
- deselectCell();
- expect(getCellMeta(0, 0).className).toEqual('htMiddle');
- expect(getCell(0, 0).className).toContain('htMiddle');
- done();
- }, 350); // menu opens after 300ms
- });
- it('should vertical align text bottom', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- var button = contextSubMenu.find('.ht_master .htCore tbody td').not('.htSeparator').eq(6);
- button.simulate('mousedown'); // Text bottom
- deselectCell();
- expect(getCellMeta(0, 0).className).toEqual('htBottom');
- expect(getCell(0, 0).className).toContain('htBottom');
- done();
- }, 350); // menu opens after 300ms
- });
- it('should trigger `afterSetCellMeta` callback after changing alignment by context menu', function (done) {
- var afterSetCellMetaCallback = jasmine.createSpy('afterSetCellMetaCallback');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- rowHeaders: true,
- colHeaders: true,
- contextMenu: true,
- afterSetCellMeta: afterSetCellMetaCallback
- });
- selectCell(2, 3);
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- var button = contextSubMenu.find('.ht_master .htCore tbody td').not('.htSeparator').eq(2);
- button.simulate('mousedown'); // Text bottom
- deselectCell();
- expect(afterSetCellMetaCallback).toHaveBeenCalledWith(2, 3, 'className', 'htRight', undefined, undefined);
- done();
- }, 350); // menu opens after 300ms
- });
- });
- });
- /***/ }),
- /* 131 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('ContextMenu', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should update context menu items by calling `updateSettings` method', function () {
- var hot = handsontable({
- contextMenu: ['row_above', 'row_below', '---------', 'remove_row'],
- height: 100
- });
- contextMenu();
- var items = $('.htContextMenu tbody td');
- var actions = items.not('.htSeparator');
- var separators = items.filter('.htSeparator');
- expect(actions.length).toEqual(3);
- expect(separators.length).toEqual(1);
- expect(actions.text()).toEqual(['Insert row above', 'Insert row below', 'Remove row'].join(''));
- hot.updateSettings({
- contextMenu: ['remove_row']
- });
- contextMenu();
- items = $('.htContextMenu tbody td');
- actions = items.not('.htSeparator');
- separators = items.filter('.htSeparator');
- expect(actions.length).toEqual(1);
- expect(separators.length).toEqual(0);
- expect(actions.text()).toEqual(['Remove row'].join(''));
- hot.updateSettings({
- contextMenu: {
- items: {
- remove_col: true,
- hsep1: '---------',
- custom: { name: 'My custom item' }
- }
- }
- });
- contextMenu();
- items = $('.htContextMenu tbody td');
- actions = items.not('.htSeparator');
- separators = items.filter('.htSeparator');
- expect(actions.length).toEqual(2);
- expect(separators.length).toEqual(1);
- expect(actions.text()).toEqual(['Remove column', 'My custom item'].join(''));
- });
- describe('menu opening', function () {
- it('should open menu after right click on table cell', function () {
- var hot = handsontable({
- contextMenu: true,
- height: 100
- });
- expect(hot.getPlugin('contextMenu')).toBeDefined();
- expect($('.htContextMenu').is(':visible')).toBe(false);
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- });
- it('should not open the menu after clicking an open editor', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- selectCell(2, 2);
- keyDownUp('enter');
- expect(hot.getPlugin('contextMenu')).toBeDefined();
- expect($('.htContextMenu').is(':visible')).toBe(false);
- contextMenu(hot.getActiveEditor().TEXTAREA);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should open menu after right click on header cell when only header cells are visible', function () {
- var hot = handsontable({
- data: [],
- colHeaders: ['Year', 'Kia'],
- columns: [{ data: 0 }, { data: 1 }],
- contextMenu: true,
- height: 100
- });
- expect(hot.getPlugin('contextMenu')).toBeDefined();
- expect($('.htContextMenu').is(':visible')).toBe(false);
- contextMenu(hot.rootElement.querySelector('.ht_clone_top thead th'));
- expect($('.htContextMenu').is(':visible')).toBe(true);
- });
- it('should open menu after right click on header corner', function () {
- var hot = handsontable({
- data: [],
- colHeaders: true,
- rowHeaders: true,
- contextMenu: true,
- height: 100
- });
- expect(hot.getPlugin('contextMenu')).toBeDefined();
- expect($('.htContextMenu').is(':visible')).toBe(false);
- contextMenu(hot.rootElement.querySelector('.ht_clone_top_left_corner thead th'));
- expect($('.htContextMenu').is(':visible')).toBe(true);
- });
- it('should open menu after right click active cell border', function () {
- var hot = handsontable({
- contextMenu: true,
- height: 100
- });
- expect(hot.getPlugin('contextMenu')).toBeDefined();
- expect($('.htContextMenu').is(':visible')).toBe(false);
- selectCell(0, 0);
- this.$container.find('.wtBorder.current:eq(0)').simulate('contextmenu');
- expect($('.htContextMenu').is(':visible')).toBe(true);
- });
- });
- describe('menu closing', function () {
- it('should close menu after click', function () {
- var hot = handsontable({
- contextMenu: true,
- height: 100
- });
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- mouseDown(this.$container);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should close menu after click under the menu', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(500, 10),
- contextMenu: true,
- height: 500
- });
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- var rect = $('.htContextMenu')[0].getBoundingClientRect();
- var x = parseInt(rect.left + rect.width / 2, 10);
- var y = parseInt(rect.top + rect.height, 10);
- mouseDown(document.elementFromPoint(x, y));
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- });
- describe('menu disabled', function () {
- it('should not open menu after right click', function () {
- var hot = handsontable({
- contextMenu: true,
- height: 100
- });
- hot.getPlugin('contextMenu').disablePlugin();
- expect($('.htContextMenu').is(':visible')).toBe(false);
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should not create context menu if it\'s disabled in constructor options', function () {
- var hot = handsontable({
- contextMenu: false,
- height: 100
- });
- expect(hot.getPlugin('contextMenu').isEnabled()).toBe(false);
- });
- it('should reenable menu', function () {
- var hot = handsontable({
- contextMenu: true,
- height: 100
- });
- hot.getPlugin('contextMenu').disablePlugin();
- expect($('.htContextMenu').is(':visible')).toBe(false);
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(false);
- hot.getPlugin('contextMenu').enablePlugin();
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- });
- it('should reenable menu with updateSettings when it was disabled in constructor', function () {
- var hot = handsontable({
- contextMenu: false,
- height: 100
- });
- expect(hot.getPlugin('contextMenu').isEnabled()).toBe(false);
- updateSettings({
- contextMenu: true
- });
- expect(hot.getPlugin('contextMenu').isEnabled()).toBe(true);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- });
- it('should disable menu with updateSettings when it was enabled in constructor', function () {
- var hot = handsontable({
- contextMenu: true,
- height: 100
- });
- expect(hot.getPlugin('contextMenu').isEnabled()).toBe(true);
- updateSettings({
- contextMenu: false
- });
- expect(hot.getPlugin('contextMenu').isEnabled()).toBe(false);
- });
- it('should work properly (remove row) after destroy and new init', function () {
- var test = function test() {
- handsontable({
- startRows: 5,
- contextMenu: ['remove_row'],
- height: 100
- });
- selectCell(0, 0);
- contextMenu();
- $('.htContextMenu .ht_master .htCore tbody').find('td').not('.htSeparator').eq(0).simulate('mousedown');
- expect(getData().length).toEqual(4);
- };
- test();
- destroy();
- test();
- });
- });
- describe('menu hidden items', function () {
- it('should remove separators from top, bottom and duplicated', function () {
- var hot = handsontable({
- contextMenu: ['---------', '---------', 'row_above', '---------', '---------', 'row_below', '---------', 'remove_row'],
- height: 100
- });
- contextMenu();
- var items = $('.htContextMenu tbody td');
- var actions = items.not('.htSeparator');
- var separators = items.filter('.htSeparator');
- expect(actions.length).toEqual(3);
- expect(separators.length).toEqual(2);
- });
- it('should hide option if hidden function return true', function () {
- var hot = handsontable({
- startCols: 5,
- colHeaders: true,
- contextMenu: [{
- key: '',
- name: 'Custom option',
- hidden: function hidden() {
- return !this.selection.selectedHeader.cols;
- }
- }]
- });
- contextMenu();
- var items = $('.htContextMenu tbody td');
- var actions = items.not('.htSeparator');
- expect(actions.length).toEqual(0);
- var header = $('.ht_clone_top thead th').eq(1);
- header.simulate('mousedown');
- contextMenu();
- items = $('.htContextMenu tbody td');
- actions = items.not('.htSeparator');
- expect(actions.length).toEqual(1);
- });
- });
- describe('menu destroy', function () {
- it('should close context menu when HOT is being destroyed', function () {
- var hot = handsontable({
- contextMenu: true,
- height: 100
- });
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- destroy();
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- });
- describe('subMenu', function () {
- it('should not open subMenu immediately', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- item.simulate('mouseover');
- var contextSubMenu = $('.htContextMenuSub_' + item.text()).find('tbody td');
- expect(contextSubMenu.length).toEqual(0);
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text()).find('tbody td');
- expect(contextSubMenu.length).toEqual(0);
- done();
- }, 100);
- });
- it('should open subMenu with delay', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- expect(contextSubMenu.length).toEqual(1);
- done();
- }, 350); // menu opens after 300ms
- });
- it('should NOT open subMenu if there is no subMenu for item', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(8);
- item.simulate('mouseover');
- expect(item.hasClass('htSubmenu')).toBe(false);
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- expect(contextSubMenu.length).toEqual(0);
- });
- it('should open subMenu on the left of main menu if on the right there\'s no space left', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, Math.floor(window.innerWidth / 50)),
- contextMenu: true,
- width: window.innerWidth
- });
- selectCell(0, countCols() - 1);
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- var contextMenuRoot = $('.htContextMenu');
- item.simulate('mouseover');
- expect(item.text()).toBe('Alignment');
- expect(item.hasClass('htSubmenu')).toBe(true);
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- expect(contextSubMenu.offset().left).toBeLessThan(contextMenuRoot.offset().left - contextSubMenu.width() + 30); // 30 - scroll
- });
- it('should open subMenu on the right of main menu if there\'s free space', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, Math.floor(window.innerWidth / 50)),
- contextMenu: true,
- width: window.innerWidth
- });
- selectCell(0, countCols() - 9);
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- var contextMenuRoot = $('.htContextMenu');
- item.simulate('mouseover');
- setTimeout(function () {
- expect(item.text()).toBe('Alignment');
- expect(item.hasClass('htSubmenu')).toBe(true);
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- expect(contextSubMenu.offset().left).toBeGreaterThan(contextMenuRoot.offset().left + contextMenuRoot.width() - 30); // 30 - scroll
- done();
- }, 350); // menu opens after 300ms
- });
- it('should open subMenu on the left-bottom of main menu if there\'s free space', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(Math.floor(window.innerHeight / 23), Math.floor(window.innerWidth / 50)),
- contextMenu: true,
- height: window.innerHeight
- });
- window.scrollTo(0, document.body.clientHeight);
- selectCell(0, countCols() - 1);
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- var contextMenuRoot = $('.htContextMenu');
- item.simulate('mouseover');
- setTimeout(function () {
- expect(item.text()).toBe('Alignment');
- expect(item.hasClass('htSubmenu')).toBe(true);
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- expect(parseInt(contextSubMenu.offset().top, 10)).toBeAroundValue(parseInt(item.offset().top, 10) - 1);
- expect(parseInt(contextSubMenu.offset().left, 10)).toBeLessThan(contextMenuRoot.offset().left - contextSubMenu.width() + 30); // 30 - scroll
- done();
- }, 350); // menu opens after 300ms
- });
- it('should open subMenu on the right-bottom of main menu if there\'s free space', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(Math.floor(window.innerHeight / 23), Math.floor(window.innerWidth / 50)),
- contextMenu: true,
- height: window.innerHeight
- });
- window.scrollTo(0, document.body.clientHeight);
- selectCell(0, countCols() - 9);
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- var contextMenuRoot = $('.htContextMenu');
- item.simulate('mouseover');
- setTimeout(function () {
- expect(item.text()).toBe('Alignment');
- expect(item.hasClass('htSubmenu')).toBe(true);
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- expect(parseInt(contextSubMenu.offset().top, 10)).toBeAroundValue(parseInt(item.offset().top, 10) - 1);
- expect(parseInt(contextSubMenu.offset().left, 10)).toBeGreaterThan(contextMenuRoot.offset().left + contextMenuRoot.width() - 30); // 30 - scroll
- done();
- }, 350); // menu opens after 300ms
- });
- it('should open subMenu on the left-top of main menu if there\'s no free space on bottom', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(Math.floor(window.innerHeight / 23), Math.floor(window.innerWidth / 50)),
- contextMenu: true,
- height: window.innerHeight
- });
- selectCell(countRows() - 1, countCols() - 1);
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- var contextMenuRoot = $('.htContextMenu');
- item.simulate('mouseover');
- setTimeout(function () {
- expect(item.text()).toBe('Alignment');
- expect(item.hasClass('htSubmenu')).toBe(true);
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- expect(contextSubMenu.offset().top + contextSubMenu.height() - 28).toBeAroundValue(item.offset().top);
- expect(contextSubMenu.offset().left).toBeLessThan(contextMenuRoot.offset().left - contextSubMenu.width() + 30); // 30 - scroll
- done();
- }, 350); // menu opens after 300ms
- });
- it('should open subMenu on the right-top of main menu if there\'s no free space on bottom', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(Math.floor(window.innerHeight / 23), Math.floor(window.innerWidth / 50)),
- contextMenu: true,
- height: window.innerHeight
- });
- selectCell(countRows() - 1, countCols() - 9);
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- var contextMenuRoot = $('.htContextMenu');
- item.simulate('mouseover');
- setTimeout(function () {
- expect(item.text()).toBe('Alignment');
- expect(item.hasClass('htSubmenu')).toBe(true);
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- expect(contextSubMenu.offset().top + contextSubMenu.height() - 28).toBeAroundValue(item.offset().top);
- expect(contextSubMenu.offset().left).toBeGreaterThan(contextMenuRoot.offset().left + contextMenuRoot.width() - 30); // 30 - scroll
- done();
- }, 350); // menu opens after 300ms
- });
- });
- describe('default context menu actions', function () {
- it('should display the default set of actions', function () {
- var hot = handsontable({
- contextMenu: true,
- comments: true,
- height: 100
- });
- contextMenu();
- var items = $('.htContextMenu tbody td');
- var actions = items.not('.htSeparator');
- var separators = items.filter('.htSeparator');
- expect(actions.length).toEqual(13);
- expect(separators.length).toEqual(6);
- expect(actions.text()).toEqual(['Insert row above', 'Insert row below', 'Insert column on the left', 'Insert column on the right', 'Remove row', 'Remove column', 'Undo', 'Redo', 'Read only', 'Alignment', 'Add comment', 'Delete comment', 'Read only comment'].join(''));
- });
- it('should disable column manipulation when row header selected', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- colHeaders: true,
- rowHeaders: true,
- height: 100
- });
- $('.ht_clone_left .htCore').eq(0).find('tbody').find('th').eq(0).simulate('mousedown', { which: 3 });
- contextMenu();
- expect($('.htContextMenu tbody td.htDisabled').text()).toBe(['Insert column on the left', 'Insert column on the right', 'Remove column', 'Undo', 'Redo'].join(''));
- });
- it('should disable row manipulation when column header selected', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- colHeaders: true,
- rowHeaders: true,
- height: 100
- });
- $('.ht_clone_top .htCore').find('thead').find('th').eq(2).simulate('mousedown', { which: 3 });
- contextMenu();
- expect($('.htContextMenu tbody td.htDisabled').text()).toBe(['Insert row above', 'Insert row below', 'Remove row', 'Undo', 'Redo'].join(''));
- });
- it('should disable cells manipulation when corner header selected', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- colHeaders: true,
- rowHeaders: true,
- height: 100
- });
- $('.ht_clone_top_left_corner .htCore').find('thead').find('th').eq(0).simulate('mousedown', { which: 3 });
- contextMenu();
- expect($('.htContextMenu tbody td.htDisabled').text()).toBe(['Remove row', 'Remove column', 'Undo', 'Redo', 'Read only', 'Alignment'].join(''));
- });
- it('should insert row above selection', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 400
- });
- var afterCreateRowCallback = jasmine.createSpy('afterCreateRowCallback');
- hot.addHook('afterCreateRow', afterCreateRowCallback);
- expect(countRows()).toEqual(4);
- selectCell(1, 0, 3, 0);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(0).simulate('mousedown'); // Insert row above
- expect(afterCreateRowCallback).toHaveBeenCalledWith(1, 1, 'ContextMenu.rowAbove', undefined, undefined, undefined);
- expect(countRows()).toEqual(5);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should insert row above selection when initial data is empty', function () {
- var hot = handsontable({
- rowHeaders: true,
- colHeaders: true,
- data: [],
- dataSchema: [],
- contextMenu: true,
- height: 400
- });
- var afterCreateRowCallback = jasmine.createSpy('afterCreateRowCallback');
- hot.addHook('afterCreateRow', afterCreateRowCallback);
- expect(countRows()).toEqual(0);
- var cell = $('.ht_clone_top_left_corner .htCore').find('thead').find('th').eq(0);
- cell.simulate('mousedown', { which: 3 });
- contextMenu(cell[0]);
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(0).simulate('mousedown'); // Insert row above
- expect(afterCreateRowCallback).toHaveBeenCalledWith(0, 1, 'ContextMenu.rowAbove', undefined, undefined, undefined);
- expect(countRows()).toEqual(1);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should NOT display insert row selection', function () {
- var hot = handsontable({
- contextMenu: true,
- allowInsertRow: false
- });
- contextMenu();
- var items = $('.htContextMenu tbody td');
- var actions = items.not('.htSeparator');
- var separators = items.filter('.htSeparator');
- expect(actions.length).toEqual(8);
- expect(separators.length).toEqual(4);
- expect(actions.text()).toEqual(['Insert column on the left', 'Insert column on the right', 'Remove row', 'Remove column', 'Undo', 'Redo', 'Read only', 'Alignment'].join(''));
- });
- it('should NOT display insert column selection', function () {
- var hot = handsontable({
- contextMenu: true,
- allowInsertColumn: false
- });
- contextMenu();
- var items = $('.htContextMenu tbody td');
- var actions = items.not('.htSeparator');
- expect(actions.length).toEqual(8);
- expect(actions.text()).toEqual(['Insert row above', 'Insert row below', 'Remove row', 'Remove column', 'Undo', 'Redo', 'Read only', 'Alignment'].join(''));
- });
- it('should insert row above selection (reverse selection)', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- var afterCreateRowCallback = jasmine.createSpy('afterCreateRowCallback');
- hot.addHook('afterCreateRow', afterCreateRowCallback);
- expect(countRows()).toEqual(4);
- selectCell(3, 0, 1, 0);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(0).simulate('mousedown'); // Insert row above
- expect(afterCreateRowCallback).toHaveBeenCalledWith(1, 1, 'ContextMenu.rowAbove', undefined, undefined, undefined);
- expect(countRows()).toEqual(5);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should insert row below selection', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- var afterCreateRowCallback = jasmine.createSpy('afterCreateRowCallback');
- hot.addHook('afterCreateRow', afterCreateRowCallback);
- expect(countRows()).toEqual(4);
- selectCell(1, 0, 3, 0);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(1).simulate('mousedown'); // Insert row above
- expect(afterCreateRowCallback).toHaveBeenCalledWith(4, 1, 'ContextMenu.rowBelow', undefined, undefined, undefined);
- expect(countRows()).toEqual(5);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should insert row below selection when initial data is empty', function () {
- var hot = handsontable({
- rowHeaders: true,
- colHeaders: true,
- data: [],
- dataSchema: [],
- contextMenu: true,
- height: 400
- });
- var afterCreateRowCallback = jasmine.createSpy('afterCreateRowCallback');
- hot.addHook('afterCreateRow', afterCreateRowCallback);
- expect(countRows()).toEqual(0);
- var cell = $('.ht_clone_top_left_corner .htCore').find('thead').find('th').eq(0);
- cell.simulate('mousedown', { which: 3 });
- contextMenu(cell[0]);
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(1).simulate('mousedown'); // Insert row below
- expect(afterCreateRowCallback).toHaveBeenCalledWith(0, 1, 'ContextMenu.rowBelow', undefined, undefined, undefined);
- expect(countRows()).toEqual(1);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should insert row below selection (reverse selection)', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- var afterCreateRowCallback = jasmine.createSpy('afterCreateRowCallback');
- hot.addHook('afterCreateRow', afterCreateRowCallback);
- expect(countRows()).toEqual(4);
- selectCell(3, 0, 1, 0);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(1).simulate('mousedown'); // Insert row below
- expect(afterCreateRowCallback).toHaveBeenCalledWith(4, 1, 'ContextMenu.rowBelow', undefined, undefined, undefined);
- expect(countRows()).toEqual(5);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should insert column on the left of selection', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- width: 400,
- height: 400
- });
- var afterCreateColCallback = jasmine.createSpy('afterCreateColCallback');
- hot.addHook('afterCreateCol', afterCreateColCallback);
- expect(countCols()).toEqual(4);
- selectCell(0, 1, 0, 3);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(2).simulate('mousedown'); // Insert col left
- expect(afterCreateColCallback).toHaveBeenCalledWith(1, 1, 'ContextMenu.columnLeft', undefined, undefined, undefined);
- expect(countCols()).toEqual(5);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should insert column on the left of selection when initial data is empty', function () {
- var hot = handsontable({
- rowHeaders: true,
- colHeaders: true,
- data: [],
- dataSchema: [],
- contextMenu: true,
- height: 400
- });
- var afterCreateColCallback = jasmine.createSpy('afterCreateColCallback');
- hot.addHook('afterCreateCol', afterCreateColCallback);
- expect(countCols()).toEqual(0);
- var cell = $('.ht_clone_top_left_corner .htCore').find('thead').find('th').eq(0);
- cell.simulate('mousedown', { which: 3 });
- contextMenu(cell[0]);
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(3).simulate('mousedown'); // Insert column on the left
- expect(afterCreateColCallback).toHaveBeenCalledWith(0, 1, 'ContextMenu.columnRight', undefined, undefined, undefined);
- expect(countCols()).toEqual(1);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should insert column on the left of selection (reverse selection)', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- var afterCreateColCallback = jasmine.createSpy('afterCreateColCallback');
- hot.addHook('afterCreateCol', afterCreateColCallback);
- expect(countCols()).toEqual(4);
- selectCell(0, 3, 0, 1);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(2).simulate('mousedown'); // Insert col left
- expect(afterCreateColCallback).toHaveBeenCalledWith(1, 1, 'ContextMenu.columnLeft', undefined, undefined, undefined);
- expect(countCols()).toEqual(5);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should insert column on the right of selection', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- var afterCreateColCallback = jasmine.createSpy('afterCreateColCallback');
- hot.addHook('afterCreateCol', afterCreateColCallback);
- expect(countCols()).toEqual(4);
- selectCell(0, 1, 0, 3);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(2).simulate('mousedown'); // Insert col right
- expect(afterCreateColCallback).toHaveBeenCalledWith(1, 1, 'ContextMenu.columnLeft', undefined, undefined, undefined);
- expect(countCols()).toEqual(5);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should insert column on the right of selection when initial data is empty', function () {
- var hot = handsontable({
- rowHeaders: true,
- colHeaders: true,
- data: [],
- dataSchema: [],
- contextMenu: true,
- height: 400
- });
- var afterCreateColCallback = jasmine.createSpy('afterCreateColCallback');
- hot.addHook('afterCreateCol', afterCreateColCallback);
- expect(countCols()).toEqual(0);
- var cell = $('.ht_clone_top_left_corner .htCore').find('thead').find('th').eq(0);
- cell.simulate('mousedown', { which: 3 });
- contextMenu(cell[0]);
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(3).simulate('mousedown'); // Insert column on the right
- expect(afterCreateColCallback).toHaveBeenCalledWith(0, 1, 'ContextMenu.columnRight', undefined, undefined, undefined);
- expect(countCols()).toEqual(1);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should insert column on the right of selection (reverse selection)', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- var afterCreateColCallback = jasmine.createSpy('afterCreateColCallback');
- hot.addHook('afterCreateCol', afterCreateColCallback);
- expect(countCols()).toEqual(4);
- selectCell(0, 3, 0, 1);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(3).simulate('mousedown'); // Insert col right
- expect(afterCreateColCallback).toHaveBeenCalledWith(4, 1, 'ContextMenu.columnRight', undefined, undefined, undefined);
- expect(countCols()).toEqual(5);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should remove selected rows', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- var afterRemoveRowCallback = jasmine.createSpy('afterRemoveRowCallback');
- hot.addHook('afterRemoveRow', afterRemoveRowCallback);
- expect(countRows()).toEqual(4);
- selectCell(1, 0, 3, 0);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(4).simulate('mousedown'); // Remove row
- expect(afterRemoveRowCallback).toHaveBeenCalledWith(1, 3, [1, 2, 3], 'ContextMenu.removeRow', undefined, undefined);
- expect(countRows()).toEqual(1);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should allow to remove the latest row', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 4),
- contextMenu: true,
- height: 100
- });
- var afterRemoveRowCallback = jasmine.createSpy('afterRemoveRowCallback');
- hot.addHook('afterRemoveRow', afterRemoveRowCallback);
- expect(countRows()).toBe(1);
- selectCell(0, 0, 0, 0);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(4).simulate('mousedown'); // Remove row
- expect(afterRemoveRowCallback).toHaveBeenCalledWith(0, 1, [0], 'ContextMenu.removeRow', undefined, undefined);
- expect(countRows()).toBe(0);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should remove selected rows (reverse selection)', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- var afterRemoveRowCallback = jasmine.createSpy('afterRemoveRowCallback');
- hot.addHook('afterRemoveRow', afterRemoveRowCallback);
- expect(countRows()).toBe(4);
- selectCell(3, 0, 1, 0);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(4).simulate('mousedown'); // Remove row
- expect(afterRemoveRowCallback).toHaveBeenCalledWith(1, 3, [1, 2, 3], 'ContextMenu.removeRow', undefined, undefined);
- expect(countRows()).toBe(1);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should remove selected columns', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- var afterRemoveColCallback = jasmine.createSpy('afterRemoveColCallback');
- hot.addHook('afterRemoveCol', afterRemoveColCallback);
- expect(countCols()).toBe(4);
- selectCell(0, 1, 0, 3);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(5).simulate('mousedown'); // Remove col
- expect(afterRemoveColCallback).toHaveBeenCalledWith(1, 3, [1, 2, 3], 'ContextMenu.removeColumn', undefined, undefined);
- expect(countCols()).toBe(1);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should allow to remove the latest column', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 1),
- contextMenu: true,
- height: 100
- });
- var afterRemoveColCallback = jasmine.createSpy('afterRemoveColCallback');
- hot.addHook('afterRemoveCol', afterRemoveColCallback);
- expect(countCols()).toBe(1);
- selectCell(0, 0, 0, 0);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(5).simulate('mousedown'); // Remove column
- expect(afterRemoveColCallback).toHaveBeenCalledWith(0, 1, [0], 'ContextMenu.removeColumn', undefined, undefined);
- expect(countCols()).toBe(0);
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should remove selected columns (reverse selection)', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- var afterRemoveColCallback = jasmine.createSpy('afterRemoveColCallback');
- hot.addHook('afterRemoveCol', afterRemoveColCallback);
- expect(countCols()).toEqual(4);
- selectCell(0, 3, 0, 1);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(5).simulate('mousedown'); // Remove col
- expect(afterRemoveColCallback).toHaveBeenCalledWith(1, 3, [1, 2, 3], 'ContextMenu.removeColumn', undefined, undefined);
- expect(countCols()).toEqual(1);
- });
- it('should undo changes', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- selectCell(0, 0);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- setDataAtCell(0, 0, 'XX');
- expect(getDataAtCell(0, 0)).toEqual('XX');
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(6).simulate('mousedown'); // Undo
- expect(getDataAtCell(0, 0)).toEqual('A1');
- });
- it('should redo changes', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- selectCell(0, 0);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- setDataAtCell(0, 0, 'XX');
- expect(getDataAtCell(0, 0)).toEqual('XX');
- hot.undo();
- expect(getDataAtCell(0, 0)).toEqual('A1');
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(7).simulate('mousedown'); // Redo
- expect(getDataAtCell(0, 0)).toEqual('XX');
- });
- it('should display only the specified actions', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: ['remove_row', 'undo'],
- height: 100
- });
- contextMenu();
- expect($('.htContextMenu .ht_master .htCore').find('tbody td').length).toEqual(2);
- });
- it('should make a single selected cell read-only', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- selectCell(0, 0);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(hot.getCellMeta(0, 0).readOnly).toBe(false);
- selectCell(0, 0);
- contextMenu();
- var menu = $('.htContextMenu .ht_master .htCore tbody');
- menu.find('td').not('.htSeparator').eq(8).simulate('mousedown'); // Make read-only
- expect(hot.getCellMeta(0, 0).readOnly).toBe(true);
- });
- it('should make a single selected cell writable, when it\'s set to read-only', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- selectCell(0, 0);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- hot.getCellMeta(0, 0).readOnly = true;
- selectCell(0, 0);
- contextMenu();
- var menu = $('.htContextMenu .ht_master .htCore tbody');
- menu.find('td').not('.htSeparator').eq(8).simulate('mousedown');
- // $(hot.contextMenu.menu).find('tbody td').not('.htSeparator').eq(8).trigger('mousedown'); //Make writable
- expect(hot.getCellMeta(0, 0).readOnly).toBe(false);
- });
- it('should make a group of selected cells read-only, if all of them are writable', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- for (var i = 0; i < 2; i++) {
- for (var j = 0; j < 2; j++) {
- expect(hot.getCellMeta(i, j).readOnly).toEqual(false);
- }
- }
- selectCell(0, 0, 2, 2);
- contextMenu();
- var menu = $('.htContextMenu .ht_master .htCore tbody');
- menu.find('td').not('.htSeparator').eq(8).simulate('mousedown');
- // $(hot.contextMenu.menu).find('tbody td').not('.htSeparator').eq(8).trigger('mousedown'); //Make read-only
- for (var _i = 0; _i < 2; _i++) {
- for (var _j = 0; _j < 2; _j++) {
- expect(hot.getCellMeta(_i, _j).readOnly).toEqual(true);
- }
- }
- });
- it('should not close menu after clicking on submenu root item', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: ['row_above', 'remove_row', '---------', 'alignment'],
- height: 400
- });
- selectCell(1, 0, 3, 0);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(2).simulate('mousedown'); // Alignment
- expect($('.htContextMenu').is(':visible')).toBe(true);
- });
- it('should make a group of selected cells read-only, if all of them are writable (reverse selection)', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- for (var i = 0; i < 2; i++) {
- for (var j = 0; j < 2; j++) {
- expect(hot.getCellMeta(i, j).readOnly).toEqual(false);
- }
- }
- selectCell(2, 2, 0, 0);
- contextMenu();
- var menu = $('.htContextMenu .ht_master .htCore tbody');
- menu.find('td').not('.htSeparator').eq(8).simulate('mousedown'); // Make read-only
- for (var _i2 = 0; _i2 < 2; _i2++) {
- for (var _j2 = 0; _j2 < 2; _j2++) {
- expect(hot.getCellMeta(_i2, _j2).readOnly).toEqual(true);
- }
- }
- });
- it('should make a group of selected cells writable if at least one of them is read-only', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- for (var i = 0; i < 2; i++) {
- for (var j = 0; j < 2; j++) {
- expect(hot.getCellMeta(i, j).readOnly).toEqual(false);
- }
- }
- hot.getCellMeta(1, 1).readOnly = true;
- selectCell(0, 0, 2, 2);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(8).simulate('mousedown'); // Make writable
- for (var _i3 = 0; _i3 < 2; _i3++) {
- for (var _j3 = 0; _j3 < 2; _j3++) {
- expect(hot.getCellMeta(_i3, _j3).readOnly).toEqual(false);
- }
- }
- });
- it('should make a group of selected cells writable if at least one of them is read-only (reverse selection)', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- height: 100
- });
- for (var i = 0; i < 2; i++) {
- for (var j = 0; j < 2; j++) {
- expect(hot.getCellMeta(i, j).readOnly).toEqual(false);
- }
- }
- hot.getCellMeta(1, 1).readOnly = true;
- selectCell(2, 2, 0, 0);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(8).simulate('mousedown'); // Make writable
- for (var _i4 = 0; _i4 < 2; _i4++) {
- for (var _j4 = 0; _j4 < 2; _j4++) {
- expect(hot.getCellMeta(_i4, _j4).readOnly).toEqual(false);
- }
- }
- });
- });
- describe('disabling actions', function () {
- it('should not close menu after clicking on disabled item', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: ['undo', 'redo'],
- height: 400
- });
- selectCell(1, 0, 3, 0);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(0).simulate('mousedown'); // Undo
- expect($('.htContextMenu').is(':visible')).toBe(true);
- });
- it('should disable undo and redo action if undoRedo plugin is not enabled ', function () {
- var hot = handsontable({
- contextMenu: true,
- undoRedo: false,
- height: 100
- });
- contextMenu();
- var $menu = $('.htContextMenu .ht_master .htCore');
- expect($menu.find('tbody td:eq(9)').text()).toEqual('Undo');
- expect($menu.find('tbody td:eq(9)').hasClass('htDisabled')).toBe(true);
- expect($menu.find('tbody td:eq(10)').text()).toEqual('Redo');
- expect($menu.find('tbody td:eq(10)').hasClass('htDisabled')).toBe(true);
- });
- it('should disable undo when there is nothing to undo ', function () {
- var hot = handsontable({
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var $menu = $('.htContextMenu .ht_master .htCore');
- expect(hot.undoRedo.isUndoAvailable()).toBe(false);
- expect($menu.find('tbody td:eq(9)').text()).toEqual('Undo');
- expect($menu.find('tbody td:eq(9)').hasClass('htDisabled')).toBe(true);
- closeContextMenu();
- setDataAtCell(0, 0, 'foo');
- contextMenu();
- $menu = $('.htContextMenu .ht_master .htCore');
- expect(hot.undoRedo.isUndoAvailable()).toBe(true);
- expect($menu.find('tbody td:eq(9)').hasClass('htDisabled')).toBe(false);
- });
- it('should disable redo when there is nothing to redo ', function () {
- var hot = handsontable({
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var $menu = $('.htContextMenu .ht_master .htCore');
- expect(hot.undoRedo.isRedoAvailable()).toBe(false);
- expect($menu.find('tbody td:eq(10)').text()).toEqual('Redo');
- expect($menu.find('tbody td:eq(10)').hasClass('htDisabled')).toBe(true);
- closeContextMenu();
- setDataAtCell(0, 0, 'foo');
- hot.undo();
- contextMenu();
- $menu = $('.htContextMenu .ht_master .htCore');
- expect(hot.undoRedo.isRedoAvailable()).toBe(true);
- expect($menu.find('tbody td:eq(10)').hasClass('htDisabled')).toBe(false);
- });
- it('should disable Insert row in context menu when maxRows is reached', function () {
- var hot = handsontable({
- contextMenu: true,
- maxRows: 6,
- height: 100
- });
- contextMenu();
- var $menu = $('.htContextMenu .ht_master .htCore');
- expect($menu.find('tbody td:eq(0)').text()).toEqual('Insert row above');
- expect($menu.find('tbody td:eq(0)').hasClass('htDisabled')).toBe(false);
- expect($menu.find('tbody td:eq(1)').text()).toEqual('Insert row below');
- expect($menu.find('tbody td:eq(1)').hasClass('htDisabled')).toBe(false);
- closeContextMenu();
- alter('insert_row');
- contextMenu();
- $menu = $('.htContextMenu .ht_master .htCore');
- expect($menu.find('tbody td:eq(0)').hasClass('htDisabled')).toBe(true);
- expect($menu.find('tbody td:eq(1)').hasClass('htDisabled')).toBe(true);
- });
- it('should disable Insert col in context menu when maxCols is reached', function () {
- var hot = handsontable({
- contextMenu: true,
- maxCols: 6,
- height: 100
- });
- contextMenu();
- var $menu = $('.htContextMenu .ht_master .htCore');
- expect($menu.find('tbody td:eq(3)').text()).toEqual('Insert column on the left');
- expect($menu.find('tbody td:eq(3)').hasClass('htDisabled')).toBe(false);
- expect($menu.find('tbody td:eq(4)').text()).toEqual('Insert column on the right');
- expect($menu.find('tbody td:eq(4)').hasClass('htDisabled')).toBe(false);
- closeContextMenu();
- alter('insert_col');
- contextMenu();
- $menu = $('.htContextMenu .ht_master .htCore');
- expect($menu.find('tbody td:eq(3)').hasClass('htDisabled')).toBe(true);
- expect($menu.find('tbody td:eq(4)').hasClass('htDisabled')).toBe(true);
- });
- it('should NOT disable Insert col in context menu when only one column exists', function () {
- var hot = handsontable({
- data: [['single col']],
- contextMenu: true,
- maxCols: 10,
- height: 100
- });
- selectCell(0, 0);
- contextMenu();
- var $menu = $('.htContextMenu .ht_master .htCore');
- expect($menu.find('tbody td:eq(3)').text()).toEqual('Insert column on the left');
- expect($menu.find('tbody td:eq(3)').hasClass('htDisabled')).toBe(false);
- expect($menu.find('tbody td:eq(4)').text()).toEqual('Insert column on the right');
- expect($menu.find('tbody td:eq(4)').hasClass('htDisabled')).toBe(false);
- });
- it('should disable Remove col in context menu when rows are selected by headers', function () {
- var hot = handsontable({
- contextMenu: ['remove_col', 'remove_row'],
- height: 100,
- colHeaders: true,
- rowHeaders: true
- });
- var $rowsHeaders = this.$container.find('.ht_clone_left tr th');
- $rowsHeaders.eq(1).simulate('mousedown');
- $rowsHeaders.eq(2).simulate('mouseover');
- $rowsHeaders.eq(3).simulate('mouseover');
- $rowsHeaders.eq(3).simulate('mousemove');
- $rowsHeaders.eq(3).simulate('mouseup');
- contextMenu();
- var $menu = $('.htContextMenu .ht_master .htCore');
- expect($menu.find('tbody td:eq(0)').text()).toEqual('Remove column');
- expect($menu.find('tbody td:eq(0)').hasClass('htDisabled')).toBe(true);
- });
- it('should disable Remove row in context menu when columns are selected by headers', function () {
- var hot = handsontable({
- contextMenu: ['remove_col', 'remove_row'],
- height: 100,
- colHeaders: true,
- rowHeaders: true
- });
- this.$container.find('thead tr:eq(0) th:eq(1)').simulate('mousedown');
- this.$container.find('thead tr:eq(0) th:eq(2)').simulate('mouseover');
- this.$container.find('thead tr:eq(0) th:eq(3)').simulate('mouseover');
- this.$container.find('thead tr:eq(0) th:eq(3)').simulate('mousemove');
- this.$container.find('thead tr:eq(0) th:eq(3)').simulate('mouseup');
- contextMenu();
- var $menu = $('.htContextMenu .ht_master .htCore');
- expect($menu.find('tbody td:eq(1)').text()).toEqual('Remove row');
- expect($menu.find('tbody td:eq(1)').hasClass('htDisabled')).toBe(true);
- });
- });
- describe('custom options', function () {
- it('should have custom items list', function () {
- var callback1 = jasmine.createSpy('callback1');
- var callback2 = jasmine.createSpy('callback2');
- var hot = handsontable({
- contextMenu: {
- items: {
- cust1: {
- name: 'CustomItem1',
- callback: callback1
- },
- cust2: {
- name: 'CustomItem2',
- callback: callback2
- }
- }
- },
- height: 100
- });
- contextMenu();
- expect($('.htContextMenu .ht_master .htCore').find('tbody td').length).toEqual(2);
- expect($('.htContextMenu .ht_master .htCore').find('tbody td').text()).toEqual(['CustomItem1', 'CustomItem2'].join(''));
- $('.htContextMenu .ht_master .htCore').find('tbody td:eq(0)').simulate('mousedown');
- expect(callback1.calls.count()).toEqual(1);
- expect(callback2.calls.count()).toEqual(0);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td:eq(1)').simulate('mousedown');
- expect(callback1.calls.count()).toEqual(1);
- expect(callback2.calls.count()).toEqual(1);
- });
- it('should have custom items list (defined as a function)', function () {
- var enabled = false;
- var hot = handsontable({
- contextMenu: {
- items: {
- cust1: {
- name: function name() {
- if (!enabled) {
- return 'Enable my custom option';
- }
- return 'Disable my custom option';
- },
- callback: function callback() {}
- }
- }
- },
- height: 100
- });
- contextMenu();
- expect($('.htContextMenu .ht_master .htCore').find('tbody td').text()).toEqual('Enable my custom option');
- $('.htContextMenu .ht_master .htCore').find('tbody td:eq(0)').simulate('mousedown');
- enabled = true;
- contextMenu();
- expect($('.htContextMenu .ht_master .htCore').find('tbody td').text()).toEqual('Disable my custom option');
- $('.htContextMenu .ht_master .htCore').find('tbody td:eq(0)').simulate('mousedown');
- });
- it('should enable to define item options globally', function () {
- var callback = jasmine.createSpy('callback');
- var hot = handsontable({
- contextMenu: {
- callback: callback,
- items: {
- cust1: {
- name: 'CustomItem1'
- },
- cust2: {
- name: 'CustomItem2'
- }
- }
- },
- height: 100
- });
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td:eq(0)').simulate('mousedown');
- expect(callback.calls.count()).toEqual(1);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td:eq(1)').simulate('mousedown');
- expect(callback.calls.count()).toEqual(2);
- });
- it('should override default items options', function () {
- var callback = jasmine.createSpy('callback');
- var hot = handsontable({
- contextMenu: {
- items: {
- remove_row: {
- callback: callback
- },
- remove_col: {
- name: 'Delete column'
- }
- }
- },
- height: 100
- });
- contextMenu();
- expect($('.htContextMenu .ht_master .htCore').find('tbody td').length).toEqual(2);
- expect($('.htContextMenu .ht_master .htCore').find('tbody td').text()).toEqual(['Remove row', 'Delete column'].join(''));
- $('.htContextMenu .ht_master .htCore').find('tbody td:eq(0)').simulate('mousedown');
- expect(callback.calls.count()).toEqual(1);
- expect(countCols()).toEqual(5);
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td:eq(1)').simulate('mousedown');
- expect(countCols()).toEqual(4);
- });
- it('should fire item callback after item has been clicked', function () {
- var customItem = {
- name: 'Custom item',
- callback: function callback() {}
- };
- spyOn(customItem, 'callback');
- var hot = handsontable({
- contextMenu: {
- items: {
- customItemKey: customItem
- }
- },
- height: 100
- });
- contextMenu();
- $('.htContextMenu .ht_master .htCore').find('tbody td:eq(0)').simulate('mousedown');
- expect(customItem.callback.calls.count()).toEqual(1);
- expect(customItem.callback.calls.argsFor(0)[0]).toEqual('customItemKey');
- });
- });
- describe('keyboard navigation', function () {
- describe('no item selected', function () {
- it('should select the first item in menu, when user hits ARROW_DOWN', function () {
- var hot = handsontable({
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- expect(menuHot.getSelected()).toBeUndefined();
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should scroll down, when user hits ARROW_DOWN for item in menu below the viewport', function () {
- var hot = handsontable({
- height: 100,
- contextMenu: {
- items: {
- item1: {
- name: 'Item1'
- },
- item2: {
- name: 'Item2'
- },
- item3: {
- name: 'Item3'
- },
- item4: {
- name: 'Item4'
- },
- item5: {
- name: 'Item5'
- },
- item6: {
- name: 'Item6'
- },
- item7: {
- name: 'Item7'
- },
- item8: {
- name: 'Item8'
- },
- item9: {
- name: 'Item9'
- },
- item10: {
- name: 'Item10'
- },
- item11: {
- name: 'Item11'
- },
- item12: {
- name: 'Item12'
- },
- item13: {
- name: 'Item13'
- },
- item14: {
- name: 'Item14'
- },
- item15: {
- name: 'Item15'
- },
- item16: {
- name: 'Item16'
- },
- item17: {
- name: 'Item17'
- },
- item18: {
- name: 'Item18'
- },
- item19: {
- name: 'Item19'
- },
- item20: {
- name: 'Item20'
- },
- item21: {
- name: 'Item21'
- },
- item22: {
- name: 'Item22'
- },
- item23: {
- name: 'Item23'
- },
- item24: {
- name: 'Item24'
- },
- item25: {
- name: 'Item25'
- },
- item26: {
- name: 'Item26'
- },
- item27: {
- name: 'Item27'
- },
- item28: {
- name: 'Item28'
- },
- item29: {
- name: 'Item29'
- },
- item30: {
- name: 'Item30'
- },
- item31: {
- name: 'Item31'
- },
- item32: {
- name: 'Item32'
- },
- item33: {
- name: 'Item33'
- },
- item34: {
- name: 'Item34'
- },
- item35: {
- name: 'Item35'
- },
- item36: {
- name: 'Item36'
- },
- item37: {
- name: 'Item37'
- },
- item38: {
- name: 'Item38'
- },
- item39: {
- name: 'Item39'
- },
- item40: {
- name: 'Item40'
- }
- }
- }
- }),
- scrollHeight;
- contextMenu();
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- if (typeof window.scrollY !== 'undefined') {
- scrollHeight = window.scrollY;
- } else {
- scrollHeight = document.documentElement.scrollTop;
- }
- expect(scrollHeight).not.toBe(0);
- });
- it('should select the first NOT DISABLED item in menu, when user hits ARROW_DOWN', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1',
- disabled: true
- },
- item2: {
- name: 'Item2',
- disabled: true
- },
- item3: {
- name: 'Item3'
- }
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- expect(menuHot.getSelected()).toBeUndefined();
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([2, 0, 2, 0]);
- });
- it('should NOT select any items in menu, when user hits ARROW_DOWN and there is no items enabled', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1',
- disabled: true
- },
- item2: {
- name: 'Item2',
- disabled: true
- },
- item3: {
- name: 'Item3',
- disabled: true
- }
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- expect(menuHot.getSelected()).toBeUndefined();
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toBeUndefined();
- });
- it('should select the last item in menu, when user hits ARROW_UP', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: 'Item1',
- item2: 'Item2',
- item3: 'Item3'
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- expect(menuHot.getSelected()).toBeUndefined();
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([2, 0, 2, 0]);
- });
- it('should select the last NOT DISABLED item in menu, when user hits ARROW_UP', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1'
- },
- item2: {
- name: 'Item2',
- disabled: true
- },
- item3: {
- name: 'Item3',
- disabled: true
- }
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- expect(menuHot.getSelected()).toBeUndefined();
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should NOT select any items in menu, when user hits ARROW_UP and there is no items enabled', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1',
- disabled: true
- },
- item2: {
- name: 'Item2',
- disabled: true
- },
- item3: {
- name: 'Item3',
- disabled: true
- }
- }
- },
- height: 100
- });
- contextMenu();
- var id = $('.htContextMenu')[0].id;
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- expect(menuHot.getSelected()).toBeUndefined();
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toBeUndefined();
- });
- });
- describe('item selected', function () {
- it('should select next item when user hits ARROW_DOWN', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1'
- },
- item2: {
- name: 'Item2'
- },
- item3: {
- name: 'Item3'
- }
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([0, 0, 0, 0]);
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([1, 0, 1, 0]);
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([2, 0, 2, 0]);
- });
- it('should select next item (skipping disabled items) when user hits ARROW_DOWN', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1'
- },
- item2: {
- name: 'Item2',
- disabled: true
- },
- item3: {
- name: 'Item3'
- }
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([0, 0, 0, 0]);
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([2, 0, 2, 0]);
- });
- it('should select next item (skipping separators) when user hits ARROW_DOWN', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1'
- },
- sep1: Handsontable.plugins.ContextMenu.SEPARATOR,
- item2: {
- name: 'Item2'
- },
- item3: {
- name: 'Item3'
- }
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([0, 0, 0, 0]);
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([2, 0, 2, 0]);
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([3, 0, 3, 0]);
- });
- it('should not change selection when last item is selected and user hits ARROW_DOWN', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1'
- },
- item2: {
- name: 'Item2'
- },
- item3: {
- name: 'Item3'
- }
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([0, 0, 0, 0]);
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([1, 0, 1, 0]);
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([2, 0, 2, 0]);
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([2, 0, 2, 0]);
- });
- it('should not change selection when last enabled item is selected and user hits ARROW_DOWN', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1'
- },
- item2: {
- name: 'Item2'
- },
- item3: {
- name: 'Item3',
- disabled: true
- }
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([0, 0, 0, 0]);
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([1, 0, 1, 0]);
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([1, 0, 1, 0]);
- });
- it('should select next item when user hits ARROW_UP', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1'
- },
- item2: {
- name: 'Item2'
- },
- item3: {
- name: 'Item3'
- }
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([2, 0, 2, 0]);
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([1, 0, 1, 0]);
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should select next item (skipping disabled items) when user hits ARROW_UP', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1'
- },
- item2: {
- name: 'Item2',
- disabled: true
- },
- item3: {
- name: 'Item3'
- }
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([2, 0, 2, 0]);
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should select next item (skipping separators) when user hits ARROW_UP', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1'
- },
- sep1: Handsontable.plugins.ContextMenu.SEPARATOR,
- item2: {
- name: 'Item2'
- },
- item3: {
- name: 'Item3'
- }
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([3, 0, 3, 0]);
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([2, 0, 2, 0]);
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should not change selection when first item is selected and user hits ARROW_UP', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1'
- },
- item2: {
- name: 'Item2'
- },
- item3: {
- name: 'Item3'
- }
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([2, 0, 2, 0]);
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([1, 0, 1, 0]);
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([0, 0, 0, 0]);
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should not change selection when first enabled item is selected and user hits ARROW_UP', function () {
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1',
- disabled: true
- },
- item2: {
- name: 'Item2'
- },
- item3: {
- name: 'Item3'
- }
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([2, 0, 2, 0]);
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([1, 0, 1, 0]);
- keyDownUp('arrow_up');
- expect(menuHot.getSelected()).toEqual([1, 0, 1, 0]);
- });
- it('should perform a selected item action, when user hits ENTER', function () {
- var itemAction = jasmine.createSpy('itemAction');
- var hot = handsontable({
- contextMenu: {
- items: {
- item1: {
- name: 'Item1',
- callback: itemAction
- },
- item2: 'Item2'
- }
- },
- height: 100
- });
- contextMenu();
- var menuHot = hot.getPlugin('contextMenu').menu.hotMenu;
- keyDownUp('arrow_down');
- expect(menuHot.getSelected()).toEqual([0, 0, 0, 0]);
- expect(itemAction).not.toHaveBeenCalled();
- keyDownUp('enter');
- expect(itemAction).toHaveBeenCalled();
- expect($(hot.getPlugin('contextMenu').menu).is(':visible')).toBe(false);
- });
- });
- it('should close menu when user hits ESC', function () {
- handsontable({
- contextMenu: true,
- height: 100
- });
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- keyDownUp('esc');
- expect($('.htContextMenu').is(':visible')).toBe(false);
- });
- it('should close sub-menu and parent menu in proper order when user hits ESC twice', function (done) {
- handsontable({
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(9);
- var contextMenuRoot = $('.htContextMenu');
- item.simulate('mouseover');
- setTimeout(function () {
- expect($('.htContextMenuSub_Alignment').is(':visible')).toBe(true);
- keyDownUp('esc');
- expect($('.htContextMenuSub_Alignment').is(':visible')).toBe(false);
- keyDownUp('esc');
- expect($('.htContextMenu').is(':visible')).toBe(false);
- done();
- }, 350); // waits for submenu open delay
- });
- });
- describe('mouse navigation', function () {
- it('should not scroll window position after fireing mouseenter on menu item', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(1000, 5),
- contextMenu: true
- }),
- scrollHeight;
- hot.selectCell(100, 0);
- contextMenu();
- window.scrollTo(0, 0);
- $('.htContextMenu .ht_master .htCore').find('tr td:eq("0")').simulate('mouseenter');
- if (typeof window.scrollY !== 'undefined') {
- scrollHeight = window.scrollY;
- } else {
- scrollHeight = document.documentElement.scrollTop;
- }
- expect(scrollHeight).toBe(0);
- });
- it('should not scroll window position after fireing click on menu', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(1000, 5),
- contextMenu: {
- items: {
- item1: {
- name: 'Item1'
- },
- sep1: Handsontable.plugins.ContextMenu.SEPARATOR,
- item2: {
- name: 'Item2'
- },
- item3: {
- name: 'Item3'
- }
- }
- }
- }),
- scrollHeight;
- hot.selectCell(100, 0);
- contextMenu();
- window.scrollTo(0, 0);
- $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(0).simulate('mousedown');
- if (typeof window.scrollY !== 'undefined') {
- scrollHeight = window.scrollY;
- } else {
- scrollHeight = document.documentElement.scrollTop;
- }
- expect(scrollHeight).toBe(0);
- });
- });
- describe('working with multiple tables', function () {
- beforeEach(function () {
- this.$container2 = $('<div id="' + id + '-2"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container2) {
- this.$container2.handsontable('destroy');
- this.$container2.remove();
- }
- });
- it('should apply enabling/disabling contextMenu using updateSetting only to particular instance of HOT ', function () {
- var hot1 = handsontable({
- contextMenu: false,
- height: 100
- });
- var hot2 = this.$container2.handsontable({
- contextMenu: true,
- height: 100
- });
- hot2 = hot2.handsontable('getInstance');
- var contextMenuContainer = $('.htContextMenu');
- contextMenu();
- expect(hot1.getPlugin('contextMenu').isEnabled()).toBe(false);
- expect(contextMenuContainer.is(':visible')).toBe(false);
- contextMenu2();
- expect(hot2.getPlugin('contextMenu').isEnabled()).toBe(true);
- expect($('.htContextMenu').is(':visible')).toBe(true);
- mouseDown(hot2.rootElement); // close menu
- hot1.updateSettings({
- contextMenu: true
- });
- hot2.updateSettings({
- contextMenu: false
- });
- contextMenu2();
- expect(hot2.getPlugin('contextMenu').isEnabled()).toBe(false);
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- function contextMenu2() {
- var hot = spec().$container2.data('handsontable');
- var selected = hot.getSelected();
- if (!selected) {
- hot.selectCell(0, 0);
- selected = hot.getSelected();
- }
- var cell = hot.getCell(selected[0], selected[1]);
- var cellOffset = $(cell).offset();
- $(cell).simulate('contextmenu', {
- pageX: cellOffset.left,
- pageY: cellOffset.top
- });
- }
- });
- it('should perform a contextMenu action only for particular instance of HOT ', function () {
- var hot1 = handsontable({
- contextMenu: true,
- height: 100
- });
- var hot2 = this.$container2.handsontable({
- contextMenu: true,
- height: 100
- });
- hot2 = hot2.handsontable('getInstance');
- hot1.selectCell(0, 0);
- contextMenu();
- expect(hot1.countRows()).toEqual(5);
- expect(hot2.countRows()).toEqual(5);
- $('.htContextMenu .ht_master .htCore').find('tr td:eq("0")').simulate('mousedown'); // insert row above
- expect(hot1.countRows()).toEqual(6);
- expect(hot2.countRows()).toEqual(5);
- hot2.selectCell(0, 0);
- contextMenu2();
- expect(hot1.countRows()).toEqual(6);
- expect(hot2.countRows()).toEqual(5);
- $('.htContextMenu .ht_master .htCore').find('tr td:eq("0")').simulate('mousedown'); // insert row above
- expect(hot1.countRows()).toEqual(6);
- expect(hot2.countRows()).toEqual(6);
- function contextMenu2() {
- var hot = spec().$container2.data('handsontable');
- var selected = hot.getSelected();
- if (!selected) {
- hot.selectCell(0, 0);
- selected = hot.getSelected();
- }
- var cell = hot.getCell(selected[0], selected[1]);
- var cellOffset = $(cell).offset();
- $(cell).simulate('contextmenu', {
- pageX: cellOffset.left,
- pageY: cellOffset.top
- });
- }
- });
- });
- describe('context menu with native scroll', function () {
- beforeEach(function () {
- var wrapper = $('<div></div>').css({
- width: 400,
- height: 200,
- overflow: 'scroll'
- });
- this.$wrapper = this.$container.wrap(wrapper).parent();
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- this.$wrapper.remove();
- });
- it('should display menu table is not scrolled', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(40, 30),
- colWidths: 50, // can also be a number or a function
- rowHeaders: true,
- colHeaders: true,
- contextMenu: true,
- height: 100
- });
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- });
- it('should display menu table is scrolled', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(40, 30),
- colWidths: 50, // can also be a number or a function
- rowHeaders: true,
- colHeaders: true,
- contextMenu: true,
- height: 100
- });
- var mainHolder = hot.view.wt.wtTable.holder;
- $(mainHolder).scrollTop(300);
- $(mainHolder).scroll();
- selectCell(15, 3);
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- });
- it('should not close the menu, when table is scrolled', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(40, 30),
- colWidths: 50, // can also be a number or a function
- rowHeaders: true,
- colHeaders: true,
- contextMenu: true,
- height: 100
- });
- var $mainHolder = $(hot.view.wt.wtTable.holder);
- selectCell(15, 3);
- var scrollTop = $mainHolder.scrollTop();
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- $mainHolder.scrollTop(scrollTop + 60).scroll();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- contextMenu();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- $mainHolder.scrollTop(scrollTop + 100).scroll();
- expect($('.htContextMenu').is(':visible')).toBe(true);
- });
- it('should not attempt to close menu, when table is scrolled and the menu is already closed', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(40, 30),
- colWidths: 50, // can also be a number or a function
- rowHeaders: true,
- colHeaders: true,
- contextMenu: true,
- height: 100
- });
- var mainHolder = $(hot.view.wt.wtTable.holder);
- selectCell(15, 3);
- var scrollTop = mainHolder.scrollTop();
- contextMenu();
- var $menu = $('.htContextMenu');
- spyOn(hot.getPlugin('contextMenu'), 'close');
- mainHolder.scrollTop(scrollTop + 100).scroll();
- expect(hot.getPlugin('contextMenu').close).not.toHaveBeenCalled();
- });
- it('should not scroll the window when hovering over context menu items (#1897 reopen)', function () {
- this.$wrapper.css('overflow', 'visible');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(403, 303),
- colWidths: 50, // can also be a number or a function
- contextMenu: true
- });
- var beginningScrollX = window.scrollX;
- selectCell(2, 4);
- contextMenu();
- var cmInstance = hot.getPlugin('contextMenu').menu.hotMenu;
- cmInstance.selectCell(3, 0);
- expect(window.scrollX).toEqual(beginningScrollX);
- cmInstance.selectCell(4, 0);
- expect(window.scrollX).toEqual(beginningScrollX);
- cmInstance.selectCell(6, 0);
- expect(window.scrollX).toEqual(beginningScrollX);
- });
- });
- describe('afterContextMenuDefaultOptions hook', function () {
- it('should call afterContextMenuDefaultOptions hook with context menu options as the first param', function () {
- var options;
- var afterContextMenuDefaultOptions = function afterContextMenuDefaultOptions(options_) {
- options = options_;
- options.items.cust1 = {
- name: 'My custom item',
- callback: function callback() {}
- };
- };
- Handsontable.hooks.add('afterContextMenuDefaultOptions', afterContextMenuDefaultOptions);
- var hot = handsontable({
- contextMenu: true,
- height: 100
- });
- contextMenu();
- var $menu = $('.htContextMenu .ht_master .htCore');
- expect(options).toBeDefined();
- expect(options.items).toBeDefined();
- expect($menu.find('tbody td').text()).toContain('My custom item');
- $menu.find('tbody td:eq(0)').simulate('mousedown');
- Handsontable.hooks.remove('afterContextMenuDefaultOptions', afterContextMenuDefaultOptions);
- });
- });
- describe('beforeContextMenuSetItems hook', function () {
- it('should add new menu item even when item is excluded from plugin settings', function () {
- Handsontable.hooks.add('beforeContextMenuSetItems', function (options) {
- if (this === hot || !hot) {
- options.push({
- key: 'test',
- name: 'Test'
- });
- }
- });
- var hot = handsontable({
- contextMenu: ['make_read_only'],
- height: 100
- });
- contextMenu();
- var items = $('.htContextMenu tbody td');
- var actions = items.not('.htSeparator');
- expect(actions.text()).toEqual(['Read only', 'Test'].join(''));
- });
- it('should be called only with items selected in plugin settings', function () {
- var keys = [];
- Handsontable.hooks.add('beforeContextMenuSetItems', function (items) {
- if (this === hot || !hot) {
- keys = items.map(function (v) {
- return v.key;
- });
- }
- });
- var hot = handsontable({
- contextMenu: ['make_read_only', 'col_left'],
- height: 100
- });
- contextMenu();
- expect(keys).toEqual(['make_read_only', 'col_left']);
- });
- });
- });
- /***/ }),
- /* 132 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('ContextMenuReadOnly', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should trigger `afterSetCellMeta` callback after changing cell to read only by context menu', function () {
- var afterSetCellMetaCallback = jasmine.createSpy('afterSetCellMetaCallback');
- var rows = 5,
- columns = 5;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(rows, columns),
- rowHeaders: true,
- colHeaders: true,
- contextMenu: true,
- afterSetCellMeta: afterSetCellMetaCallback
- });
- selectCell(2, 3);
- contextMenu();
- var changeToReadOnluButton = $('.htItemWrapper').filter(function () {
- return $(this).text() === 'Read only';
- })[0];
- $(changeToReadOnluButton).simulate('mousedown');
- expect(afterSetCellMetaCallback).toHaveBeenCalledWith(2, 3, 'readOnly', true, undefined, undefined);
- });
- });
- /***/ }),
- /* 133 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('ContextMenuCopyPaste', function () {
- var id = 'testContainer';
- if (typeof navigator.mimeTypes['application/x-shockwave-flash'] === 'undefined') {
- navigator.mimeTypes['application/x-shockwave-flash'] = {}; // mock Adobe Flash plugin so that contextMenuCopyPaste.js does not throw an error in PhantomJS
- }
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- var wrapper = $('<div></div>').css({
- width: 400,
- height: 200,
- overflow: 'scroll'
- });
- this.$wrapper = this.$container.wrap(wrapper).parent();
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- this.$wrapper.remove();
- $('head').find('script[src*=ZeroClipboard]').remove();
- delete window.ZeroClipboard;
- });
- it('should add Copy and Paste context menu options at the beginning by default', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5),
- rowHeaders: true,
- colHeaders: true,
- minSpareRows: 1,
- contextMenu: true,
- contextMenuCopyPaste: {
- swfPath: '../../demo/swf/ZeroClipboard.swf'
- }
- });
- selectCell(1, 1);
- contextMenu();
- var $contextMenuEntries = $('.htContextMenu .ht_master .htCore tbody').find('td');
- var $copyButton = $contextMenuEntries.find('div').filter(function () {
- return (/Copy/i.test($(this).text())
- );
- }).parents('td');
- var $pasteButton = $contextMenuEntries.find('div').filter(function () {
- return (/Paste/i.test($(this).text())
- );
- }).parents('td');
- expect($contextMenuEntries.index($copyButton)).toEqual(0);
- expect($contextMenuEntries.index($pasteButton)).toEqual(1);
- });
- it('should add Copy and Paste context menu options at the provided index', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5),
- rowHeaders: true,
- colHeaders: true,
- minSpareRows: 1,
- contextMenu: ['row_above', 'copy', 'paste', 'row_below'],
- contextMenuCopyPaste: {
- swfPath: '../../demo/swf/ZeroClipboard.swf'
- }
- });
- selectCell(1, 1);
- contextMenu();
- var $contextMenuEntries = $('.htContextMenu .ht_master .htCore tbody').find('td');
- var $copyButton = $contextMenuEntries.find('div').filter(function () {
- return (/Copy/i.test($(this).text())
- );
- }).parents('td');
- var $pasteButton = $contextMenuEntries.find('div').filter(function () {
- return (/Paste/i.test($(this).text())
- );
- }).parents('td');
- expect($contextMenuEntries.not('[class*=htSeparator]').index($copyButton)).toEqual(1);
- expect($contextMenuEntries.not('[class*=htSeparator]').index($pasteButton)).toEqual(2);
- });
- it('should disable `Copy` and `Paste` items when context menu was triggered from corner header', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5),
- rowHeaders: true,
- colHeaders: true,
- minSpareRows: 1,
- contextMenu: true,
- contextMenuCopyPaste: {
- swfPath: '../../demo/swf/ZeroClipboard.swf'
- }
- });
- $('.ht_clone_top_left_corner .htCore').find('thead').find('th').eq(0).simulate('mousedown', { which: 3 });
- contextMenu();
- expect($('.htContextMenu tbody td.htDisabled').text()).toBe(['Copy', 'Paste', 'Insert column on the left', 'Insert column on the right', 'Remove row', 'Remove column', 'Undo', 'Redo', 'Read only', 'Alignment'].join(''));
- });
- // see https://github.com/handsontable/handsontable/issues/3140
- it('should not throwing error when ContextMenu plugin is disabled', function () {
- var spy = jasmine.createSpy();
- var prevError = window.onerror;
- window.onerror = function () {
- spy();
- };
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5),
- rowHeaders: true,
- colHeaders: true,
- minSpareRows: 1,
- contextMenu: true,
- contextMenuCopyPaste: {
- swfPath: '../../demo/swf/ZeroClipboard.swf'
- }
- });
- hot.getPlugin('contextMenu').disablePlugin();
- $(getCell(0, 0)).simulate('mouseenter');
- expect(spy).not.toHaveBeenCalled();
- window.onerror = prevError;
- });
- });
- /***/ }),
- /* 134 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('CopyPaste', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should remove additional new line from copied text (only safari)', function () {
- var getData = jasmine.createSpy().and.returnValue('a\nb\n\n');
- var preventDefault = jasmine.createSpy();
- var hot = handsontable();
- $('.copyPaste')[0].onpaste({ clipboardData: { getData: getData },
- preventDefault: preventDefault
- });
- if (Handsontable.helper.isSafari()) {
- expect($('.copyPaste')[0].value).toEqual('a\nb\n');
- expect(getData).toHaveBeenCalledWith('Text');
- expect(preventDefault).toHaveBeenCalled();
- } else if (Handsontable.helper.isChrome()) {
- expect($('.copyPaste')[0].value).toBe('a\nb\n\n');
- expect(getData).toHaveBeenCalledWith('Text');
- expect(preventDefault).toHaveBeenCalled();
- }
- });
- it('should allow blocking cutting cells by stopping the immediate propagation', function (done) {
- var onCut = jasmine.createSpy();
- var hot = handsontable({
- data: [['2012', 10, 11, 12, 13, 15, 16], ['2013', 10, 11, 12, 13, 15, 16]],
- beforeKeyDown: function beforeKeyDown(event) {
- if (event.ctrlKey && event.keyCode === Handsontable.helper.KEY_CODES.X) {
- event.isImmediatePropagationEnabled = false;
- }
- }
- });
- hot.copyPaste.copyPasteInstance.cutCallbacks.push(onCut);
- selectCell(0, 0);
- keyDown('ctrl+x');
- setTimeout(function () {
- expect(onCut).not.toHaveBeenCalled();
- done();
- }, 100);
- });
- describe('enabling/disabing plugin', function () {
- it('should enable copyPaste by default', function () {
- var hot = handsontable();
- expect(hot.copyPaste).toBeDefined();
- });
- it('should create copyPaste div if enabled', function () {
- expect($('#CopyPasteDiv').length).toEqual(0);
- var hot = handsontable();
- selectCell(0, 0);
- keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT); // copyPaste div isn't created until you click CTRL
- expect($('#CopyPasteDiv').length).toEqual(1);
- });
- it('should not create copyPaste div if disabled', function () {
- expect($('#CopyPasteDiv').length).toEqual(0);
- var hot = handsontable({
- copyPaste: false
- });
- selectCell(0, 0);
- keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
- expect($('#CopyPasteDiv').length).toEqual(0);
- });
- it('should not create copyPaste property if plugin is disabled', function () {
- var hot = handsontable({
- copyPaste: false
- });
- expect(hot.copyPaste).toBeUndefined();
- });
- it('should enable/disable plugin using updateSettings', function () {
- var hot = handsontable();
- expect(hot.copyPaste).toBeDefined();
- updateSettings({
- copyPaste: false
- });
- expect(hot.copyPaste).toBe(null);
- });
- it('should remove copyPaste div if plugin has been disabled using updateSetting', function () {
- expect($('#CopyPasteDiv').length).toEqual(0);
- var hot = handsontable();
- selectCell(0, 0);
- keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
- expect($('#CopyPasteDiv').length).toEqual(1);
- updateSettings({
- copyPaste: false
- });
- expect($('#CopyPasteDiv').length).toEqual(0);
- selectCell(0, 0);
- keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
- expect($('#CopyPasteDiv').length).toEqual(0);
- });
- });
- describe('setting values copyable', function () {
- it('should set copyable text when selecting a single cell and hitting ctrl', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var copyPasteTextarea = $('textarea.copyPaste');
- expect(copyPasteTextarea.val().length).toEqual(0);
- selectCell(0, 0);
- keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
- expect(copyPasteTextarea.val()).toEqual('A1');
- });
- it('should set copyable text when selecting a single cell and hitting left command', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var copyPasteTextarea = $('textarea.copyPaste');
- expect(copyPasteTextarea.val().length).toEqual(0);
- selectCell(0, 0);
- keyDownUp(Handsontable.helper.KEY_CODES.COMMAND_LEFT);
- expect(copyPasteTextarea.val()).toEqual('A1');
- });
- it('should set copyable text when selecting a single cell and hitting right command', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var copyPasteTextarea = $('textarea.copyPaste');
- expect(copyPasteTextarea.val().length).toEqual(0);
- selectCell(0, 0);
- keyDownUp(Handsontable.helper.KEY_CODES.COMMAND_RIGHT);
- expect(copyPasteTextarea.val()).toEqual('A1');
- });
- it('should set copyable text when selecting multiple cells and hitting ctrl', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var copyPasteTextarea = $('textarea.copyPaste');
- expect(copyPasteTextarea.val().length).toEqual(0);
- selectCell(0, 0, 1, 0);
- keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
- expect(copyPasteTextarea.val()).toEqual('A1\nA2');
- });
- it('should set copyable text when selecting all cells with CTRL+A', function (done) {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var copyPasteTextarea = $('textarea.copyPaste');
- expect(copyPasteTextarea.val().length).toEqual(0);
- selectCell(0, 0);
- $(document.activeElement).simulate('keydown', { keyCode: Handsontable.helper.KEY_CODES.A, ctrlKey: true });
- setTimeout(function () {
- expect(getSelected()).toEqual([0, 0, 1, 1]);
- expect(copyPasteTextarea.val()).toEqual('A1\tB1\nA2\tB2');
- done();
- }, 10);
- });
- it('should not throw error when no cell is selected (#1221)', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- selectCell(0, 0);
- deselectCell();
- function keydownCtrl() {
- $(document).simulate('keydown', {
- keyCode: Handsontable.helper.KEY_CODES.COMMAND_LEFT
- });
- }
- // expect no to throw any exception
- expect(keydownCtrl).not.toThrow();
- });
- it('should set copyable text when selecting a single cell with specified type and hitting ctrl (#1300)', function () {
- handsontable({
- data: [['A', 1], ['B', 2]],
- columns: [{
- type: 'text'
- }, {
- type: 'numeric'
- }]
- });
- var copyPasteTextarea = $('textarea.copyPaste');
- expect(copyPasteTextarea.val().length).toEqual(0);
- selectCell(0, 0, 1, 1);
- keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
- expect(copyPasteTextarea.val()).toEqual('A\t1\nB\t2');
- });
- it('should set copyable text when selecting a single cell with editor type as false (#2574)', function () {
- handsontable({
- data: [['A', 1], ['B', 2]],
- columns: [{
- type: 'text'
- }, {
- editor: false
- }]
- });
- var copyPasteTextarea = $('textarea.copyPaste');
- expect(copyPasteTextarea.val().length).toEqual(0);
- selectCell(1, 1, 1, 1);
- keyDownUp(Handsontable.helper.KEY_CODES.CONTROL_LEFT);
- expect(copyPasteTextarea.val()).toEqual('2');
- });
- describe('working with multiple tables', function () {
- beforeEach(function () {
- this.$container2 = $('<div id="' + id + '2"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container2) {
- this.$container2.handsontable('destroy');
- this.$container2.remove();
- }
- });
- it('should disable copyPaste only in particular table', function () {
- var hot1 = handsontable();
- var hot2 = this.$container2.handsontable({
- copyPaste: false
- });
- expect(hot1.copyPaste).toBeDefined();
- expect(hot2.copyPaste).toBeUndefined();
- });
- it('should create only one CopyPasteDiv regardless of the number of tables', function () {
- var hot1 = handsontable();
- var hot2 = this.$container2.handsontable();
- expect($('#CopyPasteDiv').length).toEqual(1);
- });
- it('should leave CopyPasteDiv as long as at least one table has copyPaste enabled', function () {
- var hot1 = handsontable();
- var hot2 = this.$container2.handsontable().handsontable('getInstance');
- expect($('#CopyPasteDiv').length).toEqual(1);
- hot1.updateSettings({
- copyPaste: false
- });
- expect($('#CopyPasteDiv').length).toEqual(1);
- hot2.updateSettings({
- copyPaste: false
- });
- expect($('#CopyPasteDiv').length).toEqual(0);
- });
- });
- });
- describe('hooks', function () {
- it('should call beforeCut and afterCut during cutting out operation', function () {
- var beforeCutSpy = jasmine.createSpy('beforeCut');
- var afterCutSpy = jasmine.createSpy('afterCut');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- beforeCut: beforeCutSpy,
- afterCut: afterCutSpy
- });
- selectCell(0, 0);
- keyDown('ctrl');
- keyDown('ctrl+x');
- expect(beforeCutSpy.calls.count()).toEqual(1);
- expect(beforeCutSpy).toHaveBeenCalledWith([['A1']], [{ startRow: 0, startCol: 0, endRow: 0, endCol: 0 }], void 0, void 0, void 0, void 0);
- expect(afterCutSpy.calls.count()).toEqual(1);
- expect(afterCutSpy).toHaveBeenCalledWith([['A1']], [{ startRow: 0, startCol: 0, endRow: 0, endCol: 0 }], void 0, void 0, void 0, void 0);
- });
- it('should call beforeCopy and afterCopy during copying operation', function () {
- var beforeCopySpy = jasmine.createSpy('beforeCopy');
- var afterCopySpy = jasmine.createSpy('afterCopy');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- beforeCopy: beforeCopySpy,
- afterCopy: afterCopySpy
- });
- selectCell(0, 0);
- keyDown('ctrl');
- keyDown('ctrl+c');
- expect(beforeCopySpy.calls.count()).toEqual(1);
- expect(beforeCopySpy).toHaveBeenCalledWith([['A1']], [{ startRow: 0, startCol: 0, endRow: 0, endCol: 0 }], void 0, void 0, void 0, void 0);
- expect(afterCopySpy.calls.count()).toEqual(1);
- expect(afterCopySpy).toHaveBeenCalledWith([['A1']], [{ startRow: 0, startCol: 0, endRow: 0, endCol: 0 }], void 0, void 0, void 0, void 0);
- });
- it('should call beforePaste and afterPaste during copying operation', function (done) {
- var beforePasteSpy = jasmine.createSpy('beforePaste');
- var afterPasteSpy = jasmine.createSpy('afterPaste');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- beforePaste: beforePasteSpy,
- afterPaste: afterPasteSpy
- });
- selectCell(0, 0);
- keyDown('ctrl');
- hot.copyPaste.triggerPaste(null, 'Kia');
- setTimeout(function () {
- expect(beforePasteSpy.calls.count()).toEqual(1);
- expect(beforePasteSpy).toHaveBeenCalledWith([['Kia']], [{ startRow: 0, startCol: 0, endRow: 0, endCol: 0 }], void 0, void 0, void 0, void 0);
- expect(afterPasteSpy.calls.count()).toEqual(1);
- expect(afterPasteSpy).toHaveBeenCalledWith([['Kia']], [{ startRow: 0, startCol: 0, endRow: 0, endCol: 0 }], void 0, void 0, void 0, void 0);
- done();
- }, 60);
- });
- it('should be possible to block cutting out', function () {
- var afterCutSpy = jasmine.createSpy('afterCut');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- beforeCut: function beforeCut() {
- return false;
- },
- afterCut: afterCutSpy
- });
- selectCell(0, 0);
- keyDown('ctrl');
- keyDown('ctrl+x');
- expect(afterCutSpy.calls.count()).toEqual(0);
- });
- it('should be possible to block copying', function () {
- var afterCopySpy = jasmine.createSpy('afterCopy');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- beforeCopy: function beforeCopy() {
- return false;
- },
- afterCopy: afterCopySpy
- });
- selectCell(0, 0);
- keyDown('ctrl');
- keyDown('ctrl+c');
- expect(afterCopySpy.calls.count()).toEqual(0);
- });
- it('should be possible to block pasting', function (done) {
- var afterPasteSpy = jasmine.createSpy('afterPaste');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- beforePaste: function beforePaste() {
- return false;
- },
- afterPaste: afterPasteSpy
- });
- selectCell(0, 0);
- keyDown('ctrl');
- hot.copyPaste.triggerPaste(null, 'Kia');
- setTimeout(function () {
- expect(afterPasteSpy.calls.count()).toEqual(0);
- done();
- }, 60);
- });
- });
- });
- /***/ }),
- /* 135 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('CustomBorders', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- var wrapper = $('<div></div>').css({
- width: 400,
- height: 200,
- overflow: 'scroll'
- });
- this.$wrapper = this.$container.wrap(wrapper).parent();
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- this.$wrapper.remove();
- });
- it('should draw custom borders for single td', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(7, 7),
- colHeaders: true,
- rowHeaders: true,
- customBorders: [{
- row: 2,
- col: 2,
- left: {
- width: 2,
- color: 'red'
- },
- right: {
- width: 1,
- color: 'green'
- }
- }]
- });
- // [top,left, bottom, right]
- var borders = $('.wtBorder.border_row2col2');
- expect(borders.length).toEqual(20); // 4 times 5 elements (top,right, bottom, left, corner)
- expect(borders[0].className).toContain('hidden'); // hidden top
- expect(borders[1].style.backgroundColor).toEqual('red'); // left red
- expect(borders[1].style.width).toEqual('2px'); // left 2px width
- expect(borders[2].className).toContain('hidden'); // hidden bottom
- expect(borders[3].style.backgroundColor).toEqual('green'); // green right
- expect(borders[3].style.width).toEqual('1px'); // right 1px width
- });
- it('should draw custom borders for range', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(7, 7),
- colHeaders: true,
- rowHeaders: true,
- customBorders: [{
- range: {
- from: {
- row: 1,
- col: 1
- },
- to: {
- row: 3,
- col: 4
- }
- },
- top: {
- width: 2,
- color: 'black'
- },
- left: {
- width: 2,
- color: 'red'
- },
- bottom: {
- width: 2,
- color: 'red'
- },
- right: {
- width: 3,
- color: 'black'
- }
- }]
- });
- for (var row = 1; row <= 3; row++) {
- for (var column = 1; column <= 4; column++) {
- if (row == 1) {
- var topRow = $('.wtBorder.border_row' + row + 'col' + column);
- expect(topRow.length).toEqual(20); // borders for all tables (main and hiders)
- expect(topRow[0].style.backgroundColor).toEqual('black');
- expect(topRow[0].style.height).toEqual('2px');
- }
- if (column == 1) {
- var leftColumn = $('.wtBorder.border_row' + row + 'col' + column);
- expect(leftColumn.length).toEqual(20); // borders for all tables (main and hiders)
- expect(leftColumn[1].style.backgroundColor).toEqual('red');
- expect(leftColumn[1].style.width).toEqual('2px');
- }
- if (row == 3) {
- var bottomRow = $('.wtBorder.border_row' + row + 'col' + column);
- expect(bottomRow.length).toEqual(20); // borders for all tables (main and hiders)
- expect(bottomRow[2].style.backgroundColor).toEqual('red');
- expect(bottomRow[2].style.height).toEqual('2px');
- }
- if (column == 4) {
- var rightColumn = $('.wtBorder.border_row' + row + 'col' + column);
- expect(rightColumn.length).toEqual(20); // borders for all tables (main and hiders)
- expect(rightColumn[3].style.backgroundColor).toEqual('black');
- expect(rightColumn[3].style.width).toEqual('3px');
- }
- }
- }
- });
- it('should draw top border from context menu options', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- customBorders: true
- });
- var defaultBorder = {
- color: '#000',
- width: 1
- },
- empty = {
- hide: true
- };
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(10);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- var button = contextSubMenu.find('.ht_master .htCore tbody td').not('.htSeparator').eq(0);
- button.simulate('mousedown');
- // expect(getCellMeta(0,0).borders.hasOwnProperty('top')).toBe(true);
- expect(getCellMeta(0, 0).borders.top).toEqual(defaultBorder);
- expect(getCellMeta(0, 0).borders.left).toEqual(empty);
- expect(getCellMeta(0, 0).borders.bottom).toEqual(empty);
- expect(getCellMeta(0, 0).borders.right).toEqual(empty);
- done();
- }, 350);
- });
- it('should draw left border from context menu options', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- customBorders: true
- });
- var defaultBorder = {
- color: '#000',
- width: 1
- },
- empty = {
- hide: true
- };
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(10);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- var button = contextSubMenu.find('.ht_master .htCore tbody td').not('.htSeparator').eq(3);
- button.simulate('mousedown');
- /* eslint-disable no-prototype-builtins */
- expect(getCellMeta(0, 0).borders.hasOwnProperty('left')).toBe(true);
- expect(getCellMeta(0, 0).borders.top).toEqual(empty);
- expect(getCellMeta(0, 0).borders.left).toEqual(defaultBorder);
- expect(getCellMeta(0, 0).borders.bottom).toEqual(empty);
- expect(getCellMeta(0, 0).borders.right).toEqual(empty);
- done();
- }, 350);
- });
- it('should draw right border from context menu options', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- customBorders: true
- });
- var defaultBorder = {
- color: '#000',
- width: 1
- },
- empty = {
- hide: true
- };
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(10);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- var button = contextSubMenu.find('.ht_master .htCore tbody td').not('.htSeparator').eq(1);
- button.simulate('mousedown');
- /* eslint-disable no-prototype-builtins */
- expect(getCellMeta(0, 0).borders.hasOwnProperty('right')).toBe(true);
- expect(getCellMeta(0, 0).borders.top).toEqual(empty);
- expect(getCellMeta(0, 0).borders.left).toEqual(empty);
- expect(getCellMeta(0, 0).borders.bottom).toEqual(empty);
- expect(getCellMeta(0, 0).borders.right).toEqual(defaultBorder);
- done();
- }, 350);
- });
- it('should draw bottom border from context menu options', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- customBorders: true
- });
- var defaultBorder = {
- color: '#000',
- width: 1
- },
- empty = {
- hide: true
- };
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(10);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- var button = contextSubMenu.find('.ht_master .htCore tbody td').not('.htSeparator').eq(2);
- button.simulate('mousedown');
- /* eslint-disable no-prototype-builtins */
- expect(getCellMeta(0, 0).borders.hasOwnProperty('right')).toBe(true);
- expect(getCellMeta(0, 0).borders.top).toEqual(empty);
- expect(getCellMeta(0, 0).borders.left).toEqual(empty);
- expect(getCellMeta(0, 0).borders.bottom).toEqual(defaultBorder);
- expect(getCellMeta(0, 0).borders.right).toEqual(empty);
- done();
- }, 350);
- });
- it('should remove all bottoms border from context menu options', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- contextMenu: true,
- customBorders: [{
- row: 0,
- col: 0,
- left: {
- width: 2,
- color: 'red'
- },
- right: {
- width: 1,
- color: 'green'
- }
- }]
- });
- contextMenu();
- var item = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator').eq(10);
- item.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + item.text());
- var button = contextSubMenu.find('.ht_master .htCore tbody td').not('.htSeparator').eq(4);
- button.simulate('mousedown');
- expect(getCellMeta(0, 0).borders).toBeUndefined();
- done();
- }, 350);
- });
- it('should disable `Borders` context menu item when menu was triggered from corner header', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5),
- rowHeaders: true,
- colHeaders: true,
- contextMenu: true,
- customBorders: true
- });
- $('.ht_clone_top_left_corner .htCore').find('thead').find('th').eq(0).simulate('mousedown', { which: 3 });
- contextMenu();
- expect($('.htContextMenu tbody td.htDisabled').text()).toBe(['Insert column on the left', 'Insert column on the right', 'Remove row', 'Remove column', 'Undo', 'Redo', 'Read only', 'Alignment', 'Borders'].join(''));
- });
- });
- /***/ }),
- /* 136 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('DragToScroll', function () {
- function createBoundaries() {
- return {
- top: 100,
- left: 100,
- width: 900,
- height: 900,
- bottom: 1000,
- right: 1000
- };
- }
- var dragToScroll = new Handsontable.plugins.DragToScroll();
- dragToScroll.setBoundaries(createBoundaries());
- it('exact top, exact left should be in boundaries', function () {
- dragToScroll.setCallback(function (scrollX, scrollY) {
- expect(scrollX).toEqual(0);
- expect(scrollY).toEqual(0);
- });
- dragToScroll.check(100, 100);
- });
- it('exact bottom, exact right should be in boundaries', function () {
- dragToScroll.setCallback(function (scrollX, scrollY) {
- expect(scrollX).toEqual(0);
- expect(scrollY).toEqual(0);
- });
- dragToScroll.check(1000, 1000);
- });
- it('less than top, less than left should be out in "top" direction', function () {
- dragToScroll.setCallback(function (scrollX, scrollY) {
- expect(scrollX).toEqual(-1);
- expect(scrollY).toEqual(-1);
- });
- dragToScroll.check(99, 99);
- });
- it('exact top, less than left should be out in "left" direction', function () {
- dragToScroll.setCallback(function (scrollX, scrollY) {
- expect(scrollX).toEqual(-1);
- expect(scrollY).toEqual(0);
- });
- dragToScroll.check(99, 100);
- });
- it('less than top, more than right should be out in "top" direction', function () {
- dragToScroll.setCallback(function (scrollX, scrollY) {
- expect(scrollX).toEqual(1);
- expect(scrollY).toEqual(-1);
- });
- dragToScroll.check(1001, 99);
- });
- it('more than bottom, more than right should be out in "bottom" direction', function () {
- dragToScroll.setCallback(function (scrollX, scrollY) {
- expect(scrollX).toEqual(1);
- expect(scrollY).toEqual(1);
- });
- dragToScroll.check(1001, 1001);
- });
- it('exact bottom, more than right should be out in "right" direction', function () {
- dragToScroll.setCallback(function (scrollX, scrollY) {
- expect(scrollX).toEqual(1);
- expect(scrollY).toEqual(0);
- });
- dragToScroll.check(1001, 1000);
- });
- it('more than bottom, less than left should be out in "bottom" direction', function () {
- dragToScroll.setCallback(function (scrollX, scrollY) {
- expect(scrollX).toEqual(-1);
- expect(scrollY).toEqual(1);
- });
- dragToScroll.check(99, 1001);
- });
- });
- /***/ }),
- /* 137 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('manualColumnFreeze', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('freezeColumn', function () {
- it('should increase fixedColumnsLeft setting', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnFreeze: true
- });
- var plugin = hot.getPlugin('manualColumnFreeze');
- plugin.freezeColumn(4);
- expect(hot.getSettings().fixedColumnsLeft).toEqual(1);
- });
- it('should freeze (make fixed) the column provided as an argument', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnFreeze: true
- });
- var plugin = hot.getPlugin('manualColumnFreeze');
- var movePlugin = hot.getPlugin('manualColumnMove');
- plugin.freezeColumn(5);
- expect(movePlugin.columnsMapper.getValueByIndex(0)).toEqual(5);
- });
- });
- describe('unfreezeColumn', function () {
- it('should decrease fixedColumnsLeft setting', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnFreeze: true,
- fixedColumnsLeft: 1
- });
- var plugin = hot.getPlugin('manualColumnFreeze');
- plugin.unfreezeColumn(0);
- expect(hot.getSettings().fixedColumnsLeft).toEqual(0);
- });
- it('should unfreeze (make non-fixed) the column provided as an argument', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnFreeze: true,
- fixedColumnsLeft: 3
- });
- var plugin = hot.getPlugin('manualColumnFreeze');
- var movePlugin = hot.getPlugin('manualColumnMove');
- plugin.unfreezeColumn(0);
- expect(hot.getSettings().fixedColumnsLeft).toEqual(2);
- expect(movePlugin.columnsMapper.getValueByIndex(0)).toEqual(1);
- expect(movePlugin.columnsMapper.getValueByIndex(1)).toEqual(2);
- expect(movePlugin.columnsMapper.getValueByIndex(2)).toEqual(0);
- });
- });
- describe('functionality', function () {
- it('should add a \'freeze this column\' context menu entry for non-fixed columns', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnFreeze: true,
- contextMenu: true
- });
- selectCell(1, 1);
- contextMenu();
- var freezeEntry = $(hot.getPlugin('contextMenu').menu.container).find('div').filter(function () {
- return $(this).text() === 'Freeze this column';
- });
- expect(freezeEntry.size()).toEqual(1);
- });
- it('should add a \'unfreeze this column\' context menu entry for fixed columns', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnFreeze: true,
- contextMenu: true,
- fixedColumnsLeft: 2
- });
- selectCell(1, 1);
- contextMenu();
- var freezeEntry = $(hot.getPlugin('contextMenu').menu.container).find('div').filter(function () {
- return $(this).text() === 'Unfreeze this column';
- });
- expect(freezeEntry.size()).toEqual(1);
- });
- it('should fix the desired column after clicking the \'freeze this column\' context menu entry', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnFreeze: true,
- fixedColumnsLeft: 1,
- contextMenu: true
- });
- selectCell(1, 3);
- var dataAtCell = hot.getDataAtCell(1, 3);
- contextMenu();
- var freezeEntry = $(hot.getPlugin('contextMenu').menu.container).find('div').filter(function () {
- if ($(this).text() === 'Freeze this column') {
- return true;
- }
- return false;
- });
- expect(freezeEntry.size()).toEqual(1);
- freezeEntry.eq(0).simulate('mousedown');
- expect(hot.getSettings().fixedColumnsLeft).toEqual(2);
- expect(hot.getDataAtCell(1, 1)).toEqual(dataAtCell);
- });
- it('should unfix the desired column (and revert it to it\'s original position) after clicking the \'unfreeze this column\' context menu entry', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnFreeze: true,
- fixedColumnsLeft: 3,
- manualColumnMove: [0, 2, 5, 3, 4, 1, 6, 7, 8, 9],
- contextMenu: true,
- rowHeaders: true
- });
- var dataAtCell = hot.getDataAtCell(1, 0);
- expect(dataAtCell).toEqual('A2');
- dataAtCell = hot.getDataAtCell(1, 1);
- expect(dataAtCell).toEqual('C2');
- dataAtCell = hot.getDataAtCell(1, 2);
- expect(dataAtCell).toEqual('F2');
- selectCell(1, 1);
- contextMenu();
- var freezeEntry = $(hot.getPlugin('contextMenu').menu.container).find('div').filter(function () {
- return $(this).text() === 'Unfreeze this column';
- });
- freezeEntry.eq(0).simulate('mousedown');
- expect(hot.getSettings().fixedColumnsLeft).toEqual(2);
- dataAtCell = hot.getDataAtCell(1, 0);
- expect(dataAtCell).toEqual('A2');
- dataAtCell = hot.getDataAtCell(1, 1);
- expect(dataAtCell).toEqual('F2');
- dataAtCell = hot.getDataAtCell(1, 2);
- expect(dataAtCell).toEqual('C2');
- selectCell(1, 1);
- contextMenu();
- freezeEntry = $(hot.getPlugin('contextMenu').menu.container).find('div').filter(function () {
- if ($(this).text() === 'Unfreeze this column') {
- return true;
- }
- return false;
- });
- freezeEntry.eq(0).simulate('mousedown');
- expect(hot.getSettings().fixedColumnsLeft).toEqual(1);
- dataAtCell = hot.getDataAtCell(1, 0);
- expect(dataAtCell).toEqual('A2');
- dataAtCell = hot.getDataAtCell(1, 1);
- expect(dataAtCell).toEqual('C2');
- dataAtCell = hot.getDataAtCell(1, 2);
- expect(dataAtCell).toEqual('D2');
- dataAtCell = hot.getDataAtCell(1, 5);
- expect(dataAtCell).toEqual('F2');
- // Use the modified columns position.
- hot.updateSettings({
- fixedColumnsLeft: 0,
- manualColumnMove: [0, 2, 5, 3, 4, 1, 6, 7, 8, 9]
- });
- hot.getSettings().fixedColumnsLeft = 0;
- selectCell(1, 2);
- contextMenu();
- freezeEntry = $(hot.getPlugin('contextMenu').menu.container).find('div').filter(function () {
- return $(this).text() === 'Freeze this column';
- });
- freezeEntry.eq(0).simulate('mousedown');
- expect(hot.getSettings().fixedColumnsLeft).toEqual(1);
- dataAtCell = hot.getDataAtCell(1, 0);
- expect(dataAtCell).toEqual('F2');
- selectCell(1, 0);
- contextMenu();
- freezeEntry = $(hot.getPlugin('contextMenu').menu.container).find('div').filter(function () {
- return $(this).text() === 'Unfreeze this column';
- });
- freezeEntry.eq(0).simulate('mousedown');
- expect(hot.getSettings().fixedColumnsLeft).toEqual(0);
- dataAtCell = hot.getDataAtCell(1, 2);
- expect(dataAtCell).toEqual('F2');
- });
- });
- });
- /***/ }),
- /* 138 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('manualColumnMove', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('init', function () {
- it('should change column order at init', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnMove: [1, 2, 0]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('C1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('A1');
- });
- });
- describe('persistentState', function () {
- it('should load data from cache after initialization of new Handsontable instance', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnMove: true,
- persistentState: true
- });
- var dataAt0x2Cell = getDataAtCell(0, 2);
- var manualColumnMovePlugin = hot.getPlugin('manualColumnMove');
- manualColumnMovePlugin.moveColumn(2, 0);
- manualColumnMovePlugin.persistentStateSave();
- hot.destroy();
- this.$container.remove();
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnMove: true,
- persistentState: true
- });
- expect(getDataAtCell(0, 0)).toEqual(dataAt0x2Cell);
- done();
- });
- it('should work with updateSettings properly', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnMove: true,
- persistentState: true
- });
- var dataAt0x2Cell = getDataAtCell(0, 2);
- var manualColumnMovePlugin = hot.getPlugin('manualColumnMove');
- manualColumnMovePlugin.moveColumn(2, 0);
- manualColumnMovePlugin.persistentStateSave();
- updateSettings({});
- expect(getDataAtCell(0, 0)).toEqual(dataAt0x2Cell);
- });
- });
- describe('updateSettings', function () {
- it('should be enabled after specifying it in updateSettings config', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- colHeaders: true
- });
- updateSettings({
- manualColumnMove: true
- });
- this.$container.find('thead tr:eq(0) th:eq(0)').simulate('mousedown');
- this.$container.find('thead tr:eq(0) th:eq(0)').simulate('mouseup');
- expect(this.$container.hasClass('after-selection--columns')).toBeGreaterThan(0);
- });
- it('should change the default column order with updateSettings', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnMove: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('C1');
- updateSettings({
- manualColumnMove: [2, 1, 0]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('C1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('A1');
- });
- it('should change column order with updateSettings', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnMove: [1, 2, 0]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('C1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('A1');
- updateSettings({
- manualColumnMove: [2, 1, 0]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('C1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('A1');
- });
- it('should update columnsMapper when updateSettings change numbers of columns', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnMove: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('C1');
- hot.getPlugin('manualColumnMove').moveColumn(2, 0);
- updateSettings({
- columns: [{ data: 2 }, { data: 0 }, { data: 1 }]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('C1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('A1');
- });
- it('should reset column order with updateSettings when undefined is passed', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnMove: [1, 2, 0]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('C1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('A1');
- updateSettings({
- manualColumnMove: void 0
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('C1');
- });
- });
- describe('loadData', function () {
- it('should increase numbers of columns if it is necessary', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- manualColumnMove: true
- });
- hot.loadData(Handsontable.helper.createSpreadsheetData(10, 10));
- expect(countRows()).toEqual(10);
- expect(hot.getPlugin('manualColumnMove').columnsMapper.__arrayMap.length).toEqual(10);
- });
- it('should decrease numbers of columns if it is necessary', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- manualColumnMove: true
- });
- hot.loadData(Handsontable.helper.createSpreadsheetData(2, 2));
- expect(countRows()).toEqual(2);
- expect(hot.getPlugin('manualColumnMove').columnsMapper.__arrayMap.length).toEqual(2);
- });
- });
- describe('moving', function () {
- it('should move column by API', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- colHeaders: true,
- manualColumnMove: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('C1');
- hot.getPlugin('manualColumnMove').moveColumn(2, 0);
- hot.render();
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('C1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('B1');
- });
- it('should move many columns by API', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- colHeaders: true,
- manualColumnMove: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('C1');
- hot.getPlugin('manualColumnMove').moveColumns([7, 9, 8], 0);
- hot.render();
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('H1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('J1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('I1');
- });
- it('should trigger an beforeColumnMove event before column move', function () {
- var beforeMoveColumnCallback = jasmine.createSpy('beforeMoveColumnCallback');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- colHeaders: true,
- manualColumnMove: true,
- beforeColumnMove: beforeMoveColumnCallback
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('C1');
- hot.getPlugin('manualColumnMove').moveColumns([8, 9, 7], 0);
- hot.render();
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('I1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('J1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('H1');
- expect(beforeMoveColumnCallback).toHaveBeenCalledWith([8, 9, 7], 0, void 0, void 0, void 0, void 0);
- });
- it('should trigger an afterColumnMove event after column move', function () {
- var afterMoveColumnCallback = jasmine.createSpy('afterMoveColumnCallback');
- this.$container.height(150);
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- colHeaders: true,
- manualColumnMove: true,
- afterColumnMove: afterMoveColumnCallback
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('C1');
- hot.getPlugin('manualColumnMove').moveColumns([8, 9, 7], 0);
- hot.render();
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('I1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('J1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('H1');
- expect(afterMoveColumnCallback).toHaveBeenCalledWith([8, 9, 7], 0, void 0, void 0, void 0, void 0);
- });
- it('should move the second column to the first column', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- colHeaders: true,
- manualColumnMove: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('C1');
- var $rowsHeaders = this.$container.find('.ht_clone_top tr th');
- $rowsHeaders.eq(1).simulate('mousedown');
- $rowsHeaders.eq(1).simulate('mouseup');
- $rowsHeaders.eq(1).simulate('mousedown');
- $rowsHeaders.eq(0).simulate('mouseover');
- $rowsHeaders.eq(0).simulate('mousemove');
- $rowsHeaders.eq(0).simulate('mouseup');
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('C1');
- });
- it('should move the second row to the third row', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- colHeaders: true,
- manualColumnMove: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('B1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('C1');
- var $rowsHeaders = this.$container.find('.ht_clone_top tr th');
- $rowsHeaders.eq(1).simulate('mousedown');
- $rowsHeaders.eq(1).simulate('mouseup');
- $rowsHeaders.eq(1).simulate('mousedown');
- $rowsHeaders.eq(3).simulate('mouseover');
- $rowsHeaders.eq(3).simulate('mousemove');
- $rowsHeaders.eq(3).simulate('mouseup');
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').text()).toEqual('C1');
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').text()).toEqual('B1');
- });
- it('should properly scrolling viewport if mouse is over part-visible cell', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 20),
- colHeaders: true,
- rowHeaders: true,
- manualColumnMove: true,
- width: 600,
- height: 600,
- colWidths: 47
- });
- hot.selectCell(0, 19);
- setTimeout(function () {
- expect(hot.view.wt.wtTable.getFirstVisibleColumn()).toBeGreaterThan(8);
- var $rowsHeaders = spec().$container.find('.ht_clone_top tr th');
- $rowsHeaders.eq(2).simulate('mousedown');
- $rowsHeaders.eq(2).simulate('mouseup');
- $rowsHeaders.eq(2).simulate('mousedown');
- $rowsHeaders.eq(1).simulate('mouseover');
- $rowsHeaders.eq(1).simulate('mousemove');
- $rowsHeaders.eq(1).simulate('mouseup');
- }, 50);
- setTimeout(function () {
- expect(hot.view.wt.wtTable.getFirstVisibleColumn()).toBeLessThan(9);
- done();
- }, 150);
- });
- it('moving column should keep cell meta created using cells function', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- colHeaders: true,
- manualColumnMove: true,
- cells: function cells(row, col) {
- if (row == 1 && col == 0) {
- this.readOnly = true;
- }
- }
- });
- var htCore = getHtCore();
- expect(htCore.find('tbody tr:eq(1) td:eq(0)')[0].className.indexOf('htDimmed')).toBeGreaterThan(-1);
- hot.getPlugin('manualColumnMove').moveColumn(0, 3);
- hot.render();
- expect(htCore.find('tbody tr:eq(1) td:eq(2)')[0].className.indexOf('htDimmed')).toBeGreaterThan(-1);
- });
- it('moving column should keep cell meta created using cell array', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- colHeaders: true,
- manualColumnMove: true,
- cell: [{ row: 1, col: 0, readOnly: true }]
- });
- var htCore = getHtCore();
- expect(htCore.find('tbody tr:eq(1) td:eq(0)')[0].className.indexOf('htDimmed')).toBeGreaterThan(-1);
- hot.getPlugin('manualColumnMove').moveColumn(3, 0);
- hot.render();
- expect(htCore.find('tbody tr:eq(1) td:eq(1)')[0].className.indexOf('htDimmed')).toBeGreaterThan(-1);
- });
- });
- describe('copy-paste', function () {
- it('should create new columns is are needed', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- colHeaders: true,
- manualColumnMove: true
- });
- var changesSet = [[3, 4, 'A1'], [3, 5, 'B1'], [3, 6, 'C1'], [3, 7, 'D1']];
- // unfortunately couse of security rules, we can't simulate native mechanism (e.g. CTRL+C -> CTRL+V)
- hot.setDataAtCell(changesSet, void 0, void 0, 'CopyPaste.paste');
- expect(hot.countCols()).toEqual(8);
- });
- });
- describe('undoRedo', function () {
- xit('should back changes', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- colHeaders: true,
- manualColumnMove: true
- });
- hot.getPlugin('manualColumnMove').moveColumn(1, 4);
- hot.render();
- expect(hot.getDataAtCell(1, 3)).toBe('B2');
- hot.undo();
- expect(hot.getDataAtCell(1, 3)).toBe('D2');
- });
- xit('should revert changes', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- colHeaders: true,
- manualColumnMove: true
- });
- hot.getPlugin('manualColumnMove').moveColumn(1, 4);
- hot.render();
- expect(hot.getDataAtCell(1, 3)).toBe('A2');
- hot.undo();
- expect(hot.getDataAtCell(1, 1)).toBe('A2');
- hot.redo();
- expect(hot.getDataAtCell(1, 3)).toBe('A2');
- });
- });
- });
- /***/ }),
- /* 139 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('manualColumnMove', function () {
- var id = 'testContainer';
- var arrayOfArrays = Handsontable.helper.createSpreadsheetData(30, 30);
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('UI', function () {
- it('should append UI elements to wtHider after click on row header', function () {
- var hot = handsontable({
- data: arrayOfArrays.slice(),
- colHeaders: true,
- manualColumnMove: true
- });
- var $headerTH = this.$container.find('thead tr:eq(0) th:eq(0)');
- $headerTH.simulate('mousedown');
- $headerTH.simulate('mouseup');
- $headerTH.simulate('mousedown');
- expect(this.$container.find('.ht__manualColumnMove--guideline').length).toBe(1);
- expect(this.$container.find('.ht__manualColumnMove--backlight').length).toBe(1);
- });
- it('should part of UI elements be visible on dragging action', function () {
- var hot = handsontable({
- data: arrayOfArrays.slice(),
- colHeaders: true,
- manualColumnMove: true
- });
- var $headerTH = this.$container.find('thead tr:eq(0) th:eq(0)');
- $headerTH.simulate('mousedown');
- $headerTH.simulate('mouseup');
- $headerTH.simulate('mousedown');
- expect(this.$container.find('.ht__manualColumnMove--guideline:visible').length).toBe(0);
- expect(this.$container.find('.ht__manualColumnMove--backlight:visible').length).toBe(1);
- });
- it('should all of UI elements be visible on dragging action', function () {
- var hot = handsontable({
- data: arrayOfArrays.slice(),
- colHeaders: true,
- manualColumnMove: true
- });
- var $headers = [this.$container.find('thead tr:eq(0) th:eq(0)'), this.$container.find('thead tr:eq(0) th:eq(1)'), this.$container.find('thead tr:eq(0) th:eq(2)')];
- $headers[0].simulate('mousedown');
- $headers[0].simulate('mouseup');
- $headers[0].simulate('mousedown');
- $headers[1].simulate('mouseover');
- $headers[2].simulate('mouseover');
- expect(this.$container.find('.ht__manualColumnMove--guideline:visible').length).toBe(1);
- expect(this.$container.find('.ht__manualColumnMove--backlight:visible').length).toBe(1);
- });
- it('should set properly width for the backlight element when stretchH is enabled', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(30, 5),
- width: 600,
- colHeaders: true,
- stretchH: 'all',
- manualColumnMove: true
- });
- var $headerTH = this.$container.find('thead tr:eq(0) th:eq(1)');
- $headerTH.simulate('mousedown');
- $headerTH.simulate('mouseup');
- $headerTH.simulate('mousedown');
- expect(this.$container.find('.ht__manualColumnMove--backlight')[0].offsetWidth).toBe($headerTH[0].offsetWidth);
- });
- it('should set properly width for the backlight element when stretchH is enabled and column order was changed', function () {
- var hot = handsontable({
- data: [{ id: 1, flag: 'EUR', currencyCode: 'EUR', currency: 'Euro', level: 0.9033, units: 'EUR / USD', asOf: '08/19/2015', onedChng: 0.0026 }],
- width: 600,
- colHeaders: true,
- stretchH: 'all',
- manualColumnMove: [2, 4, 6, 3, 1, 0],
- columns: [{ data: 'id', type: 'numeric', width: 40 }, { data: 'currencyCode', type: 'text' }, { data: 'currency', type: 'text' }, { data: 'level', type: 'numeric', format: '0.0000' }, { data: 'units', type: 'text' }, { data: 'asOf', type: 'date', dateFormat: 'MM/DD/YYYY' }, { data: 'onedChng', type: 'numeric', format: '0.00%' }]
- });
- var $headerTH = this.$container.find('thead tr:eq(0) th:eq(6)');
- $headerTH.simulate('mousedown');
- $headerTH.simulate('mouseup');
- $headerTH.simulate('mousedown');
- $headerTH.simulate('mouseup');
- $headerTH.simulate('mousedown');
- expect(this.$container.find('.ht__manualColumnMove--backlight')[0].offsetWidth).toBe($headerTH[0].offsetWidth);
- });
- it('should not run moving ui if mousedown was fired on sorting element', function () {
- var hot = handsontable({
- data: arrayOfArrays.slice(),
- colHeaders: true,
- manualColumnMove: true,
- columnSorting: true
- });
- var $headerTH = this.$container.find('thead tr:eq(0) th:eq(6)');
- var $summaryElement = $headerTH.find('.columnSorting');
- $headerTH.simulate('mousedown');
- $headerTH.simulate('mouseup');
- $headerTH.simulate('mousedown');
- $headerTH.simulate('mouseup');
- var $backlight = this.$container.find('.ht__manualColumnMove--backlight')[0];
- $summaryElement.simulate('mousedown');
- var displayProp = $backlight.currentStyle ? $backlight.currentStyle.display : getComputedStyle($backlight, null).display;
- expect(displayProp).toEqual('none');
- });
- });
- });
- /***/ }),
- /* 140 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('manualColumnResize', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should change column widths at init', function () {
- handsontable({
- manualColumnResize: [100, 150, 180]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').outerWidth()).toBe(100);
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').outerWidth()).toBe(150);
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').outerWidth()).toBe(180);
- });
- it('should be enabled after specifying it in updateSettings config', function () {
- var hot = handsontable({
- data: [{ id: 1, name: 'Ted', lastName: 'Right' }, { id: 2, name: 'Frank', lastName: 'Honest' }, { id: 3, name: 'Joan', lastName: 'Well' }, { id: 4, name: 'Sid', lastName: 'Strong' }, { id: 5, name: 'Jane', lastName: 'Neat' }],
- colHeaders: true
- });
- updateSettings({ manualColumnResize: true });
- this.$container.find('thead tr:eq(0) th:eq(0)').simulate('mouseover');
- expect($('.manualColumnResizer').size()).toBeGreaterThan(0);
- });
- it('should change the default column widths with updateSettings', function () {
- handsontable({
- manualColumnResize: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').outerWidth()).toBe(50);
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').outerWidth()).toBe(50);
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').outerWidth()).toBe(50);
- updateSettings({
- manualColumnResize: [60, 50, 80]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').outerWidth()).toBe(60);
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').outerWidth()).toBe(50);
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').outerWidth()).toBe(80);
- });
- it('should change column widths with updateSettings', function () {
- handsontable({
- manualColumnResize: [100, 150, 180]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').outerWidth()).toBe(100);
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').outerWidth()).toBe(150);
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').outerWidth()).toBe(180);
- updateSettings({
- manualColumnResize: [60, 50, 80]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').outerWidth()).toBe(60);
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').outerWidth()).toBe(50);
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').outerWidth()).toBe(80);
- });
- it('should reset column widths when undefined is passed', function () {
- handsontable({
- manualColumnResize: [100, 150, 180]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').outerWidth()).toBe(100);
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').outerWidth()).toBe(150);
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').outerWidth()).toBe(180);
- updateSettings({
- manualColumnResize: void 0
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').outerWidth()).toBe(50);
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').outerWidth()).toBe(50);
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').outerWidth()).toBe(50);
- });
- it('should not reset column widths when `true` is passed', function () {
- handsontable({
- manualColumnResize: [100, 150, 180]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').outerWidth()).toBe(100);
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').outerWidth()).toBe(150);
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').outerWidth()).toBe(180);
- updateSettings({
- manualColumnResize: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').outerWidth()).toBe(100);
- expect(this.$container.find('tbody tr:eq(0) td:eq(1)').outerWidth()).toBe(150);
- expect(this.$container.find('tbody tr:eq(0) td:eq(2)').outerWidth()).toBe(180);
- });
- it('should resize (narrowing) appropriate columns, even when stretchH `all` is enabled', function () {
- this.$container.css('width', '910px');
- handsontable({
- colHeaders: true,
- manualColumnResize: true,
- stretchH: 'all'
- });
- resizeColumn(1, 65);
- var $columnHeaders = this.$container.find('thead tr:eq(1) th');
- expect($columnHeaders.eq(0).width()).toBe(209);
- expect($columnHeaders.eq(1).width()).toBe(64);
- expect($columnHeaders.eq(2).width()).toBe(210);
- expect($columnHeaders.eq(3).width()).toBe(210);
- expect($columnHeaders.eq(4).width()).toBe(211);
- });
- it('should resize (extending) appropriate columns, even when stretchH `all` is enabled', function () {
- this.$container.css('width', '910px');
- handsontable({
- colHeaders: true,
- manualColumnResize: true,
- stretchH: 'all'
- });
- resizeColumn(1, 400);
- var $columnHeaders = this.$container.find('thead tr:eq(1) th');
- expect($columnHeaders.eq(0).width()).toBe(125);
- expect($columnHeaders.eq(1).width()).toBe(399);
- expect($columnHeaders.eq(2).width()).toBe(126);
- expect($columnHeaders.eq(3).width()).toBe(126);
- expect($columnHeaders.eq(4).width()).toBe(128);
- });
- it('should resize (narrowing) selected columns', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 20),
- colHeaders: true,
- manualColumnResize: true
- });
- var $columnHeaders = this.$container.find('thead tr:eq(0) th');
- var $colHeader = this.$container.find('thead tr:eq(0) th:eq(1)');
- $colHeader.simulate('mouseover');
- var $resizer = this.$container.find('.manualColumnResizer');
- var resizerPosition = $resizer.position();
- this.$container.find('tr:eq(0) th:eq(1)').simulate('mousedown');
- this.$container.find('tr:eq(0) th:eq(2)').simulate('mouseover');
- this.$container.find('tr:eq(0) th:eq(3)').simulate('mouseover');
- this.$container.find('tr:eq(0) th:eq(3)').simulate('mousemove');
- this.$container.find('tr:eq(0) th:eq(3)').simulate('mouseup');
- $resizer.simulate('mousedown', { clientX: resizerPosition.left });
- $resizer.simulate('mousemove', { clientX: this.$container.find('tr:eq(0) th:eq(1)').position().left + 29 });
- $resizer.simulate('mouseup');
- setTimeout(function () {
- expect($columnHeaders.eq(1).width()).toBe(33);
- expect($columnHeaders.eq(2).width()).toBe(34);
- expect($columnHeaders.eq(3).width()).toBe(34);
- done();
- }, 1000);
- });
- it('should resize (expanding) selected columns', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 20),
- colHeaders: true,
- manualColumnResize: true
- });
- var $columnHeaders = this.$container.find('thead tr:eq(0) th');
- var $colHeader = this.$container.find('thead tr:eq(0) th:eq(1)');
- $colHeader.simulate('mouseover');
- var $resizer = this.$container.find('.manualColumnResizer');
- var resizerPosition = $resizer.position();
- this.$container.find('tr:eq(0) th:eq(1)').simulate('mousedown');
- this.$container.find('tr:eq(0) th:eq(2)').simulate('mouseover');
- this.$container.find('tr:eq(0) th:eq(3)').simulate('mouseover');
- this.$container.find('tr:eq(0) th:eq(3)').simulate('mousemove');
- this.$container.find('tr:eq(0) th:eq(3)').simulate('mouseup');
- $resizer.simulate('mousedown', { clientX: resizerPosition.left });
- $resizer.simulate('mousemove', { clientX: this.$container.find('tr:eq(0) th:eq(1)').position().left + 150 });
- $resizer.simulate('mouseup');
- setTimeout(function () {
- expect($columnHeaders.eq(1).width()).toBe(154);
- expect($columnHeaders.eq(2).width()).toBe(155);
- expect($columnHeaders.eq(3).width()).toBe(155);
- done();
- }, 1000);
- });
- it('should resize appropriate columns to calculated stretch width after double click on column handler when stretchH is set as `all`', function (done) {
- this.$container.css('width', '910px');
- handsontable({
- colHeaders: true,
- manualColumnResize: true,
- stretchH: 'all'
- });
- resizeColumn(1, 65);
- var $columnHeaders = this.$container.find('thead tr:eq(1) th');
- expect($columnHeaders.eq(0).width()).toBe(209);
- expect($columnHeaders.eq(1).width()).toBe(64);
- expect($columnHeaders.eq(2).width()).toBe(210);
- expect($columnHeaders.eq(3).width()).toBe(210);
- expect($columnHeaders.eq(4).width()).toBe(211);
- var $th = $columnHeaders.eq(1);
- $th.simulate('mouseover');
- var $resizer = this.$container.find('.manualColumnResizer');
- var resizerPosition = $resizer.position();
- $resizer.simulate('mousedown', { clientX: resizerPosition.left });
- $resizer.simulate('mouseup');
- $resizer.simulate('mousedown', { clientX: resizerPosition.left });
- $resizer.simulate('mouseup');
- setTimeout(function () {
- expect($columnHeaders.eq(0).width()).toBe(180);
- expect($columnHeaders.eq(1).width()).toBe(181);
- expect($columnHeaders.eq(2).width()).toBe(181);
- expect($columnHeaders.eq(3).width()).toBe(181);
- expect($columnHeaders.eq(4).width()).toBe(181);
- done();
- }, 1000);
- });
- it('should resize appropriate columns to calculated autoColumnSize width after double click on column handler when stretchH is set as `last`', function (done) {
- this.$container.css('width', '910px');
- handsontable({
- colHeaders: true,
- manualColumnResize: true,
- stretchH: 'last'
- });
- resizeColumn(0, 65);
- var $columnHeaders = this.$container.find('thead tr:eq(0) th');
- expect($columnHeaders.eq(0).width()).toBe(63);
- expect($columnHeaders.eq(1).width()).toBe(48);
- expect($columnHeaders.eq(2).width()).toBe(49);
- expect($columnHeaders.eq(3).width()).toBe(49);
- expect($columnHeaders.eq(4).width()).toBe(694);
- var $th = $columnHeaders.eq(0);
- $th.simulate('mouseover');
- var $resizer = this.$container.find('.manualColumnResizer');
- var resizerPosition = $resizer.position();
- $resizer.simulate('mousedown', { clientX: resizerPosition.left });
- $resizer.simulate('mouseup');
- $resizer.simulate('mousedown', { clientX: resizerPosition.left });
- $resizer.simulate('mouseup');
- setTimeout(function () {
- expect($columnHeaders.eq(0).width()).toBeAroundValue(19);
- expect($columnHeaders.eq(1).width()).toBe(48);
- expect($columnHeaders.eq(2).width()).toBe(49);
- expect($columnHeaders.eq(3).width()).toBe(49);
- expect($columnHeaders.eq(4).width()).toBeAroundValue(738);
- done();
- }, 1000);
- });
- it('should resize appropriate columns, even if the column order was changed with manualColumnMove plugin', function () {
- handsontable({
- colHeaders: ['First', 'Second', 'Third'],
- manualColumnMove: [2, 1, 0, 3],
- manualColumnResize: true
- });
- var $columnHeaders = this.$container.find('thead tr:eq(0) th');
- var initialColumnWidths = [];
- $columnHeaders.each(function () {
- initialColumnWidths.push($(this).width());
- });
- resizeColumn.call(this, 0, 100);
- var $resizedTh = $columnHeaders.eq(0);
- expect($resizedTh.text()).toEqual('Third');
- expect($resizedTh.outerWidth()).toEqual(100);
- // Sizes of remaining columns should stay the same
- for (var i = 1; i < $columnHeaders.length; i++) {
- expect($columnHeaders.eq(i).width()).toEqual(initialColumnWidths[i]);
- }
- });
- it('should trigger an afterColumnResize event after column size changes', function () {
- var afterColumnResizeCallback = jasmine.createSpy('afterColumnResizeCallback');
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 3),
- colHeaders: true,
- manualColumnResize: true,
- afterColumnResize: afterColumnResizeCallback
- });
- expect(colWidth(this.$container, 0)).toEqual(50);
- resizeColumn(0, 100);
- expect(afterColumnResizeCallback).toHaveBeenCalledWith(0, 100, void 0, void 0, void 0, void 0);
- expect(colWidth(this.$container, 0)).toEqual(100);
- });
- it('should not trigger an afterColumnResize event if column size does not change (mouseMove event width delta = 0)', function () {
- var afterColumnResizeCallback = jasmine.createSpy('afterColumnResizeCallback');
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 3),
- colHeaders: true,
- manualColumnResize: true,
- afterColumnResize: afterColumnResizeCallback
- });
- expect(colWidth(this.$container, 0)).toEqual(50);
- resizeColumn(0, 50);
- expect(afterColumnResizeCallback).not.toHaveBeenCalled();
- expect(colWidth(this.$container, 0)).toEqual(50);
- });
- it('should not trigger an afterColumnResize event if column size does not change (no mouseMove event)', function () {
- var afterColumnResizeCallback = jasmine.createSpy('afterColumnResizeCallback');
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 3),
- colHeaders: true,
- manualColumnResize: true,
- afterColumnResize: afterColumnResizeCallback
- });
- expect(colWidth(this.$container, 0)).toEqual(50);
- var $th = this.$container.find('thead tr:eq(0) th:eq(0)');
- $th.simulate('mouseover');
- var $resizer = this.$container.find('.manualColumnResizer');
- var resizerPosition = $resizer.position();
- $resizer.simulate('mousedown', { clientX: resizerPosition.left });
- $resizer.simulate('mouseup');
- expect(afterColumnResizeCallback).not.toHaveBeenCalled();
- expect(colWidth(this.$container, 0)).toEqual(50);
- });
- it('should trigger an afterColumnResize after column size changes, after double click', function (done) {
- var afterColumnResizeCallback = jasmine.createSpy('afterColumnResizeCallback');
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 3),
- colHeaders: true,
- manualColumnResize: true,
- afterColumnResize: afterColumnResizeCallback
- });
- expect(colWidth(this.$container, 0)).toEqual(50);
- var $th = this.$container.find('thead tr:eq(0) th:eq(0)');
- $th.simulate('mouseover');
- var $resizer = this.$container.find('.manualColumnResizer');
- var resizerPosition = $resizer.position();
- $resizer.simulate('mousedown', { clientX: resizerPosition.left });
- $resizer.simulate('mouseup');
- $resizer.simulate('mousedown', { clientX: resizerPosition.left });
- $resizer.simulate('mouseup');
- setTimeout(function () {
- expect(afterColumnResizeCallback.calls.count()).toEqual(1);
- expect(afterColumnResizeCallback.calls.argsFor(0)[0]).toEqual(0);
- // All modern browsers returns width = 25px, but IE8 seems to compute width differently and returns 24px
- expect(afterColumnResizeCallback.calls.argsFor(0)[1]).toBeInArray([30, 31, 32, 24, 25]);
- expect(colWidth(spec().$container, 0)).toBeInArray([30, 31, 32, 24, 25]);
- done();
- }, 1000);
- });
- it('should autosize column after double click (when initial width is not defined)', function (done) {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 3),
- colHeaders: true,
- manualColumnResize: true,
- columns: [{ width: 100 }, { width: 200 }, {}]
- });
- expect(colWidth(this.$container, 0)).toEqual(100);
- expect(colWidth(this.$container, 1)).toEqual(200);
- expect(colWidth(this.$container, 2)).toEqual(50);
- resizeColumn(2, 300);
- var $resizer = this.$container.find('.manualColumnResizer');
- var resizerPosition = $resizer.position();
- $resizer.simulate('mousedown', { clientX: resizerPosition.left });
- $resizer.simulate('mouseup');
- $resizer.simulate('mousedown', { clientX: resizerPosition.left });
- $resizer.simulate('mouseup');
- setTimeout(function () {
- expect(colWidth(spec().$container, 2)).toBeAroundValue(29, 3);
- done();
- }, 1000);
- });
- it('should autosize selected columns after double click on handler', function (done) {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(9, 9),
- colHeaders: true,
- manualColumnResize: true
- });
- resizeColumn(2, 300);
- this.$container.find('thead tr:eq(0) th:eq(1)').simulate('mousedown');
- this.$container.find('thead tr:eq(0) th:eq(2)').simulate('mouseover');
- this.$container.find('thead tr:eq(0) th:eq(3)').simulate('mouseover');
- this.$container.find('thead tr:eq(0) th:eq(3)').simulate('mousemove');
- this.$container.find('thead tr:eq(0) th:eq(3)').simulate('mouseup');
- var $resizer = spec().$container.find('.manualColumnResizer');
- var resizerPosition = $resizer.position();
- setTimeout(function () {
- $resizer.simulate('mousedown', { clientX: resizerPosition.left });
- $resizer.simulate('mouseup');
- $resizer.simulate('mousedown', { clientX: resizerPosition.left });
- $resizer.simulate('mouseup');
- }, 600);
- setTimeout(function () {
- expect(colWidth(spec().$container, 1)).toBeAroundValue(32, 2);
- expect(colWidth(spec().$container, 2)).toBeAroundValue(32, 2);
- expect(colWidth(spec().$container, 3)).toBeAroundValue(32, 2);
- done();
- }, 1200);
- });
- it('should adjust resize handles position after table size changed', function () {
- var maxed = false;
- handsontable({
- colHeaders: true,
- manualColumnResize: true,
- stretchH: 'all',
- width: function width() {
- return maxed ? 614 : 200;
- }
- });
- this.$container.find('thead th:eq(0)').simulate('mouseover');
- var handle = this.$container.find('.manualColumnResizer');
- var handleBox = handle[0].getBoundingClientRect();
- var th0 = this.$container.find('thead th:eq(0)');
- var thBox = th0[0].getBoundingClientRect();
- expect(handleBox.left + handleBox.width).toEqual(thBox.left + thBox.width - 1);
- maxed = true;
- render();
- this.$container.find('thead th:eq(0)').simulate('mouseover');
- handleBox = handle[0].getBoundingClientRect();
- thBox = th0[0].getBoundingClientRect();
- expect(handleBox.left + handleBox.width).toEqual(thBox.left + thBox.width - 1);
- });
- it('should display the resize handle in the correct place after the table has been scrolled', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 20),
- colHeaders: true,
- manualColumnResize: true,
- height: 100,
- width: 200
- });
- var mainHolder = hot.view.wt.wtTable.holder;
- var $colHeader = this.$container.find('.ht_clone_top thead tr:eq(0) th:eq(2)');
- $colHeader.simulate('mouseover');
- var $handle = this.$container.find('.manualColumnResizer');
- $handle[0].style.background = 'red';
- expect($colHeader.offset().left + $colHeader.width() - 5).toBeCloseTo($handle.offset().left, 0);
- expect($colHeader.offset().top).toBeCloseTo($handle.offset().top, 0);
- $(mainHolder).scrollLeft(200);
- hot.render();
- $colHeader = this.$container.find('.ht_clone_top thead tr:eq(0) th:eq(3)');
- $colHeader.simulate('mouseover');
- expect($colHeader.offset().left + $colHeader.width() - 5).toBeCloseTo($handle.offset().left, 0);
- expect($colHeader.offset().top).toBeCloseTo($handle.offset().top, 0);
- });
- describe('handle and guide', function () {
- it('should display the resize handle in the proper position and with a proper size', function () {
- var hot = handsontable({
- data: [{ id: 1, name: 'Ted', lastName: 'Right' }, { id: 2, name: 'Frank', lastName: 'Honest' }, { id: 3, name: 'Joan', lastName: 'Well' }, { id: 4, name: 'Sid', lastName: 'Strong' }, { id: 5, name: 'Jane', lastName: 'Neat' }],
- colHeaders: true,
- manualColumnResize: true
- });
- var $headerTH = this.$container.find('thead tr:eq(0) th:eq(1)');
- $headerTH.simulate('mouseover');
- var $handle = $('.manualColumnResizer');
- expect($handle.offset().left).toEqual($headerTH.offset().left + $headerTH.outerWidth() - $handle.outerWidth() - 1);
- expect($handle.height()).toEqual($headerTH.outerHeight());
- });
- });
- });
- /***/ }),
- /* 141 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('manualRowMove', function () {
- var id = 'testContainer';
- var arrayOfObjects = [{ id: 1, name: 'Ted', lastName: 'Right' }, { id: 2, name: 'Frank', lastName: 'Honest' }, { id: 3, name: 'Joan', lastName: 'Well' }, { id: 4, name: 'Sid', lastName: 'Strong' }, { id: 5, name: 'Jane', lastName: 'Neat' }, { id: 6, name: 'Chuck', lastName: 'Jackson' }, { id: 7, name: 'Meg', lastName: 'Jansen' }, { id: 8, name: 'Rob', lastName: 'Norris' }, { id: 9, name: 'Sean', lastName: 'O\'Hara' }, { id: 10, name: 'Eve', lastName: 'Branson' }];
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('init', function () {
- it('should change row order at init', function () {
- handsontable({
- data: arrayOfObjects,
- manualRowMove: [1, 2, 0]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('3');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('1');
- });
- });
- describe('updateSettings', function () {
- it('should be enabled after specifying it in updateSettings config', function () {
- handsontable({
- data: arrayOfObjects,
- rowHeaders: true
- });
- updateSettings({
- manualRowMove: true
- });
- this.$container.find('tbody tr:eq(0) th:eq(0)').simulate('mousedown');
- this.$container.find('tbody tr:eq(0) th:eq(0)').simulate('mouseup');
- expect(this.$container.hasClass('after-selection--rows')).toBeGreaterThan(0);
- });
- it('should change the default row order with updateSettings', function () {
- handsontable({
- data: arrayOfObjects,
- manualRowMove: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- updateSettings({
- manualRowMove: [2, 1, 0]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('3');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('1');
- });
- it('should change row order with updateSettings', function () {
- handsontable({
- data: arrayOfObjects,
- manualRowMove: [1, 2, 0]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('3');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('1');
- updateSettings({
- manualRowMove: [2, 1, 0]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('3');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('1');
- });
- it('should reset row order with updateSettings when undefined is passed', function () {
- handsontable({
- data: arrayOfObjects,
- manualRowMove: [1, 2, 0]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('3');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('1');
- updateSettings({
- manualRowMove: void 0
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- });
- it('should not change row order with updateSettings when `true` is passed', function () {
- handsontable({
- data: arrayOfObjects,
- manualRowMove: [1, 2, 0]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('3');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('1');
- updateSettings({
- manualRowMove: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('3');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('1');
- });
- });
- describe('loadData', function () {
- it('should increase numbers of rows if it is necessary', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- manualRowMove: true
- });
- hot.loadData(Handsontable.helper.createSpreadsheetData(10, 10));
- expect(countRows()).toEqual(10);
- expect(hot.getPlugin('manualRowMove').rowsMapper.__arrayMap.length).toEqual(10);
- });
- it('should decrease numbers of rows if it is necessary', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- manualRowMove: true
- });
- hot.loadData(Handsontable.helper.createSpreadsheetData(2, 2));
- expect(countRows()).toEqual(2);
- expect(hot.getPlugin('manualRowMove').rowsMapper.__arrayMap.length).toEqual(2);
- });
- });
- describe('moving', function () {
- it('should move row by API', function () {
- var hot = handsontable({
- data: arrayOfObjects,
- rowHeaders: true,
- manualRowMove: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- hot.getPlugin('manualRowMove').moveRow(2, 0);
- hot.render();
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('3');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('2');
- });
- it('should move many rows by API', function () {
- var hot = handsontable({
- data: arrayOfObjects,
- rowHeaders: true,
- manualRowMove: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- hot.getPlugin('manualRowMove').moveRows([7, 9, 8], 0);
- hot.render();
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('8');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('10');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('9');
- });
- it('should trigger an beforeRowMove event before row move', function () {
- var beforeMoveRowCallback = jasmine.createSpy('beforeMoveRowCallback');
- var hot = handsontable({
- data: arrayOfObjects,
- rowHeaders: true,
- manualRowMove: true,
- beforeRowMove: beforeMoveRowCallback
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- hot.getPlugin('manualRowMove').moveRows([8, 9, 7], 0);
- hot.render();
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('9');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('10');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('8');
- expect(beforeMoveRowCallback).toHaveBeenCalledWith([8, 9, 7], 0, void 0, void 0, void 0, void 0);
- });
- it('should trigger an afterRowMove event after row move', function () {
- var afterMoveRowCallback = jasmine.createSpy('afterMoveRowCallback');
- this.$container.height(150);
- var hot = handsontable({
- data: arrayOfObjects,
- rowHeaders: true,
- manualRowMove: true,
- afterRowMove: afterMoveRowCallback
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- hot.getPlugin('manualRowMove').moveRows([8, 9, 7], 0);
- hot.render();
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('9');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('10');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('8');
- expect(afterMoveRowCallback).toHaveBeenCalledWith([8, 9, 7], 0, void 0, void 0, void 0, void 0);
- });
- it('should move the second row to the first row', function () {
- var hot = handsontable({
- data: arrayOfObjects,
- rowHeaders: true,
- manualRowMove: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- var $rowsHeaders = this.$container.find('.ht_clone_left tr th');
- $rowsHeaders.eq(1).simulate('mousedown');
- $rowsHeaders.eq(1).simulate('mouseup');
- $rowsHeaders.eq(1).simulate('mousedown');
- $rowsHeaders.eq(0).simulate('mouseover');
- $rowsHeaders.eq(0).simulate('mousemove');
- $rowsHeaders.eq(0).simulate('mouseup');
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- });
- it('should move the second row to the third row', function () {
- handsontable({
- data: arrayOfObjects,
- rowHeaders: true,
- manualRowMove: true
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('2');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('3');
- var $rowsHeaders = this.$container.find('.ht_clone_left tr th');
- $rowsHeaders.eq(1).simulate('mousedown');
- $rowsHeaders.eq(1).simulate('mouseup');
- $rowsHeaders.eq(1).simulate('mousedown');
- $rowsHeaders.eq(3).simulate('mouseover');
- $rowsHeaders.eq(3).simulate('mousemove');
- $rowsHeaders.eq(3).simulate('mouseup');
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('1');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('3');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('2');
- });
- it('should not move row if it\'s not needed', function () {
- var cache = [];
- handsontable({
- data: arrayOfObjects,
- rowHeaders: true,
- manualRowMove: true,
- afterRowMove: function afterRowMove(rows, target) {
- cache.push(rows);
- }
- });
- var $rowsHeaders = this.$container.find('.ht_clone_left tr th');
- $rowsHeaders.eq(1).simulate('mousedown');
- $rowsHeaders.eq(1).simulate('mouseup');
- $rowsHeaders.eq(1).simulate('mousedown');
- $rowsHeaders.eq(3).simulate('mouseup');
- expect(cache.length).toEqual(0);
- });
- it('should properly scrolling viewport if mouse is over part-visible cell', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(20, 20),
- colHeaders: true,
- rowHeaders: true,
- manualRowMove: true,
- width: 600,
- height: 600,
- rowHeights: 47
- });
- var ev = {};
- hot.selectCell(19, 0);
- setTimeout(function () {
- expect(hot.view.wt.wtTable.getFirstVisibleRow()).toBeGreaterThan(8);
- var $rowsHeaders = spec().$container.find('.ht_clone_left tr th');
- $rowsHeaders.eq(10).simulate('mousedown');
- $rowsHeaders.eq(10).simulate('mouseup');
- $rowsHeaders.eq(10).simulate('mousedown');
- $rowsHeaders.eq(8).simulate('mouseover');
- $rowsHeaders.eq(8).simulate('mousemove');
- $rowsHeaders.eq(8).simulate('mouseup');
- }, 50);
- setTimeout(function () {
- expect(hot.view.wt.wtTable.getFirstVisibleRow()).toBeLessThan(8);
- done();
- }, 150);
- });
- it('moving row should keep cell meta created using cells function', function () {
- var hot = handsontable({
- data: arrayOfObjects,
- rowHeaders: true,
- manualRowMove: true,
- cells: function cells(row, col) {
- if (row == 1 && col == 0) {
- this.readOnly = true;
- }
- }
- });
- var htCore = getHtCore();
- expect(htCore.find('tbody tr:eq(1) td:eq(0)')[0].className.indexOf('htDimmed')).toBeGreaterThan(-1);
- hot.getPlugin('manualRowMove').moveRow(1, 3);
- hot.render();
- expect(htCore.find('tbody tr:eq(2) td:eq(0)')[0].className.indexOf('htDimmed')).toBeGreaterThan(-1);
- });
- it('moving row should keep cell meta created using cell array', function () {
- var hot = handsontable({
- data: arrayOfObjects,
- rowHeaders: true,
- manualRowMove: true,
- cell: [{ row: 1, col: 0, readOnly: true }]
- });
- var htCore = getHtCore();
- expect(htCore.find('tbody tr:eq(1) td:eq(0)')[0].className.indexOf('htDimmed')).toBeGreaterThan(-1);
- hot.getPlugin('manualRowMove').moveRow(3, 1);
- hot.render();
- expect(htCore.find('tbody tr:eq(2) td:eq(0)')[0].className.indexOf('htDimmed')).toBeGreaterThan(-1);
- });
- });
- describe('undoRedo', function () {
- it('should back changes', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- rowHeaders: true,
- manualRowMove: true
- });
- hot.getPlugin('manualRowMove').moveRow(1, 4);
- hot.render();
- expect(hot.getDataAtCell(3, 0)).toBe('A2');
- hot.undo();
- expect(hot.getDataAtCell(1, 0)).toBe('A2');
- });
- it('should revert changes', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- rowHeaders: true,
- manualRowMove: true
- });
- hot.getPlugin('manualRowMove').moveRow(1, 4);
- hot.render();
- expect(hot.getDataAtCell(3, 0)).toBe('A2');
- hot.undo();
- expect(hot.getDataAtCell(1, 0)).toBe('A2');
- hot.redo();
- expect(hot.getDataAtCell(3, 0)).toBe('A2');
- });
- });
- });
- /***/ }),
- /* 142 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('manualRowMove', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('UI', function () {
- it('should append UI elements to wtHider after click on row header', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(30, 30),
- rowHeaders: true,
- manualRowMove: true
- });
- var $headerTH = this.$container.find('tbody tr:eq(0) th:eq(0)');
- $headerTH.simulate('mousedown');
- $headerTH.simulate('mouseup');
- $headerTH.simulate('mousedown');
- expect(this.$container.find('.ht__manualRowMove--guideline').length).toBe(1);
- expect(this.$container.find('.ht__manualRowMove--backlight').length).toBe(1);
- });
- it('should part of UI elements be visible on dragging action', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(30, 30),
- rowHeaders: true,
- manualRowMove: true
- });
- var $headerTH = this.$container.find('tbody tr:eq(0) th:eq(0)');
- $headerTH.simulate('mousedown');
- $headerTH.simulate('mouseup');
- $headerTH.simulate('mousedown');
- expect(this.$container.find('.ht__manualRowMove--guideline:visible').length).toBe(0);
- expect(this.$container.find('.ht__manualRowMove--backlight:visible').length).toBe(1);
- });
- it('should all of UI elements be visible on dragging action', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(30, 30),
- rowHeaders: true,
- manualRowMove: true
- });
- var $headers = [this.$container.find('tbody tr:eq(0) th:eq(0)'), this.$container.find('tbody tr:eq(1) th:eq(0)'), this.$container.find('tbody tr:eq(2) th:eq(0)')];
- $headers[0].simulate('mousedown');
- $headers[0].simulate('mouseup');
- $headers[0].simulate('mousedown');
- $headers[1].simulate('mouseover');
- $headers[2].simulate('mouseover');
- expect(this.$container.find('.ht__manualRowMove--guideline:visible').length).toBe(1);
- expect(this.$container.find('.ht__manualRowMove--backlight:visible').length).toBe(1);
- });
- });
- });
- /***/ }),
- /* 143 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('manualRowResize', function () {
- var id = 'test';
- var defaultRowHeight = 22;
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should change row heights at init', function () {
- handsontable({
- rowHeaders: true,
- manualRowResize: [50, 40, 100]
- });
- expect(rowHeight(this.$container, 0)).toEqual(51);
- expect(rowHeight(this.$container, 1)).toEqual(40);
- expect(rowHeight(this.$container, 2)).toEqual(100);
- });
- it('should be enabled after specifying it in updateSettings config', function () {
- var hot = handsontable({
- data: [{ id: 1, name: 'Ted', lastName: 'Right' }, { id: 2, name: 'Frank', lastName: 'Honest' }, { id: 3, name: 'Joan', lastName: 'Well' }, { id: 4, name: 'Sid', lastName: 'Strong' }, { id: 5, name: 'Jane', lastName: 'Neat' }],
- rowHeaders: true
- });
- updateSettings({ manualRowResize: true });
- this.$container.find('tbody tr:eq(0) th:eq(0)').simulate('mouseover');
- expect($('.manualRowResizer').size()).toBeGreaterThan(0);
- });
- it('should change the default row height with updateSettings', function () {
- handsontable({
- manualRowResize: true
- });
- expect(rowHeight(this.$container, 0)).toEqual(defaultRowHeight + 2); // + Double border
- expect(rowHeight(this.$container, 1)).toEqual(defaultRowHeight + 1); // + Single border
- expect(rowHeight(this.$container, 2)).toEqual(defaultRowHeight + 1); // + Single border
- updateSettings({
- manualRowResize: [60, 50, 80]
- });
- expect(rowHeight(this.$container, 0)).toEqual(61);
- expect(rowHeight(this.$container, 1)).toEqual(50);
- expect(rowHeight(this.$container, 2)).toEqual(80);
- });
- it('should change the row height with updateSettings', function () {
- handsontable({
- manualRowResize: [60, 50, 80]
- });
- expect(rowHeight(this.$container, 0)).toEqual(61);
- expect(rowHeight(this.$container, 1)).toEqual(50);
- expect(rowHeight(this.$container, 2)).toEqual(80);
- updateSettings({
- manualRowResize: [30, 80, 100]
- });
- expect(rowHeight(this.$container, 0)).toEqual(31);
- expect(rowHeight(this.$container, 1)).toEqual(80);
- expect(rowHeight(this.$container, 2)).toEqual(100);
- });
- it('should not change the row height when `true` is passing', function () {
- handsontable({
- manualRowResize: [60, 50, 80]
- });
- expect(rowHeight(this.$container, 0)).toEqual(61);
- expect(rowHeight(this.$container, 1)).toEqual(50);
- expect(rowHeight(this.$container, 2)).toEqual(80);
- updateSettings({
- manualRowResize: true
- });
- expect(rowHeight(this.$container, 0)).toEqual(61);
- expect(rowHeight(this.$container, 1)).toEqual(50);
- expect(rowHeight(this.$container, 2)).toEqual(80);
- });
- it('should change the row height to defaults when undefined is passed', function () {
- handsontable({
- manualRowResize: [60, 50, 80]
- });
- expect(rowHeight(this.$container, 0)).toEqual(61);
- expect(rowHeight(this.$container, 1)).toEqual(50);
- expect(rowHeight(this.$container, 2)).toEqual(80);
- updateSettings({
- manualRowResize: void 0
- });
- expect(rowHeight(this.$container, 0)).toEqual(defaultRowHeight + 2); // + Double border
- expect(rowHeight(this.$container, 1)).toEqual(defaultRowHeight + 1); // + Single border
- expect(rowHeight(this.$container, 2)).toEqual(defaultRowHeight + 1); // + Single border
- });
- it('should reset row height', function () {
- handsontable({
- manualRowResize: true
- });
- expect(rowHeight(this.$container, 0)).toEqual(defaultRowHeight + 2);
- expect(rowHeight(this.$container, 1)).toEqual(defaultRowHeight + 1);
- expect(rowHeight(this.$container, 2)).toEqual(defaultRowHeight + 1);
- updateSettings({
- manualRowResize: true
- });
- expect(rowHeight(this.$container, 0)).toEqual(defaultRowHeight + 2);
- expect(rowHeight(this.$container, 1)).toEqual(defaultRowHeight + 1);
- expect(rowHeight(this.$container, 2)).toEqual(defaultRowHeight + 1);
- });
- it('should trigger afterRowResize event after row height changes', function () {
- var afterRowResizeCallback = jasmine.createSpy('afterRowResizeCallback');
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- rowHeaders: true,
- manualRowResize: true,
- afterRowResize: afterRowResizeCallback
- });
- expect(rowHeight(this.$container, 0)).toEqual(defaultRowHeight + 2);
- resizeRow(0, 100);
- expect(afterRowResizeCallback).toHaveBeenCalledWith(0, 100, void 0, void 0, void 0, void 0);
- expect(rowHeight(this.$container, 0)).toEqual(101);
- });
- it('should not trigger afterRowResize event if row height does not change (delta = 0)', function () {
- var afterRowResizeCallback = jasmine.createSpy('afterRowResizeCallback');
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- rowHeaders: true,
- manualRowResize: true,
- afterRowResize: afterRowResizeCallback
- });
- expect(rowHeight(this.$container, 0)).toEqual(defaultRowHeight + 2);
- resizeRow(0, defaultRowHeight);
- expect(afterRowResizeCallback).not.toHaveBeenCalled();
- expect(rowHeight(this.$container, 0)).toEqual(defaultRowHeight + 2);
- });
- it('should not trigger afterRowResize event after if row height does not change (no mousemove event)', function () {
- var afterRowResizeCallback = jasmine.createSpy('afterRowResizeCallback');
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- rowHeaders: true,
- manualRowResize: true,
- afterRowResize: afterRowResizeCallback
- });
- expect(rowHeight(this.$container, 0)).toEqual(defaultRowHeight + 2);
- var $th = this.$container.find('tbody tr:eq(0) th:eq(0)');
- $th.simulate('mouseover');
- var $resizer = this.$container.find('.manualRowResizer');
- var resizerPosition = $resizer.position();
- $resizer.simulate('mousedown', {
- clientY: resizerPosition.top
- });
- $resizer.simulate('mouseup');
- expect(afterRowResizeCallback).not.toHaveBeenCalled();
- expect(rowHeight(this.$container, 0)).toEqual(defaultRowHeight + 2);
- });
- it('should trigger an afterRowResize after row size changes, after double click', function (done) {
- var afterRowResizeCallback = jasmine.createSpy('afterRowResizeCallback');
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- rowHeaders: true,
- manualRowResize: true,
- autoRowSize: true,
- afterRowResize: afterRowResizeCallback
- });
- expect(rowHeight(this.$container, 0)).toEqual(defaultRowHeight + 2);
- var $th = this.$container.find('tbody tr:eq(2) th:eq(0)');
- $th.simulate('mouseover');
- var $resizer = this.$container.find('.manualRowResizer');
- var resizerPosition = $resizer.position();
- $resizer.simulate('mousedown', {
- clientY: resizerPosition.top
- });
- $resizer.simulate('mouseup');
- $resizer.simulate('mousedown', {
- clientY: resizerPosition.top
- });
- $resizer.simulate('mouseup');
- setTimeout(function () {
- expect(afterRowResizeCallback.calls.count()).toEqual(1);
- expect(afterRowResizeCallback.calls.argsFor(0)[0]).toEqual(2);
- expect(afterRowResizeCallback.calls.argsFor(0)[1]).toEqual(defaultRowHeight + 1);
- expect(rowHeight(spec().$container, 2)).toEqual(defaultRowHeight + 1);
- done();
- }, 1000);
- });
- it('should not trigger afterRowResize event after if row height does not change (no dblclick event)', function () {
- var afterRowResizeCallback = jasmine.createSpy('afterRowResizeCallback');
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- rowHeaders: true,
- manualRowResize: true,
- afterRowResize: afterRowResizeCallback
- });
- expect(rowHeight(this.$container, 0)).toEqual(defaultRowHeight + 2);
- var $th = this.$container.find('tbody tr:eq(2) th:eq(0)');
- $th.simulate('mouseover');
- var $resizer = this.$container.find('.manualRowResizer');
- var resizerPosition = $resizer.position();
- $resizer.simulate('mousedown', {
- clientY: resizerPosition.top
- });
- $resizer.simulate('mouseup');
- expect(afterRowResizeCallback).not.toHaveBeenCalled();
- expect(rowHeight(this.$container, 0)).toEqual(defaultRowHeight + 2);
- });
- it('should display the resize handle in the correct place after the table has been scrolled', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(20, 20),
- rowHeaders: true,
- manualRowResize: true,
- height: 100,
- width: 200
- });
- var mainHolder = hot.view.wt.wtTable.holder;
- var $rowHeader = this.$container.find('.ht_clone_left tbody tr:eq(2) th:eq(0)');
- $rowHeader.simulate('mouseover');
- var $handle = this.$container.find('.manualRowResizer');
- $handle[0].style.background = 'red';
- expect($rowHeader.offset().left).toBeCloseTo($handle.offset().left, 0);
- expect($rowHeader.offset().top + $rowHeader.height() - 5).toBeCloseTo($handle.offset().top, 0);
- $(mainHolder).scrollTop(200);
- $(mainHolder).scroll();
- $rowHeader = this.$container.find('.ht_clone_left tbody tr:eq(2) th:eq(0)');
- $rowHeader.simulate('mouseover');
- expect($rowHeader.offset().left).toBeCloseTo($handle.offset().left, 0);
- expect($rowHeader.offset().top + $rowHeader.height() - 5).toBeCloseTo($handle.offset().top, 0);
- });
- it('should autosize selected rows after double click on handler', function (done) {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(9, 9),
- rowHeaders: true,
- manualRowResize: true
- });
- resizeRow(2, 300);
- var $resizer = this.$container.find('.manualRowResizer');
- var resizerPosition = $resizer.position();
- this.$container.find('.ht_clone_left tbody tr:eq(1) th:eq(0)').simulate('mousedown');
- this.$container.find('.ht_clone_left tbody tr:eq(2) th:eq(0)').simulate('mouseover');
- this.$container.find('.ht_clone_left tbody tr:eq(3) th:eq(0)').simulate('mouseover');
- this.$container.find('.ht_clone_left tbody tr:eq(3) th:eq(0)').simulate('mousemove');
- this.$container.find('.ht_clone_left tbody tr:eq(3) th:eq(0)').simulate('mouseup');
- setTimeout(function () {
- $resizer.simulate('mousedown', { clientY: resizerPosition.top });
- $resizer.simulate('mouseup');
- $resizer.simulate('mousedown', { clientY: resizerPosition.top });
- $resizer.simulate('mouseup');
- }, 600);
- setTimeout(function () {
- expect(rowHeight(spec().$container, 1)).toBeAroundValue(24);
- expect(rowHeight(spec().$container, 2)).toBeAroundValue(24);
- expect(rowHeight(spec().$container, 3)).toBeAroundValue(24);
- done();
- }, 1600);
- });
- it('should resize (expanding and narrowing) selected rows', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 20),
- rowHeaders: true,
- manualRowResize: true
- });
- resizeRow(2, 60);
- var $rowsHeaders = this.$container.find('.ht_clone_left tr th');
- this.$container.find('.ht_clone_left tbody tr:eq(1) th:eq(0)').simulate('mouseover');
- $rowsHeaders.eq(1).simulate('mousedown');
- $rowsHeaders.eq(2).simulate('mouseover');
- $rowsHeaders.eq(3).simulate('mouseover');
- $rowsHeaders.eq(3).simulate('mousemove');
- $rowsHeaders.eq(3).simulate('mouseup');
- var $resizer = this.$container.find('.manualRowResizer');
- var resizerPosition = $resizer.position();
- setTimeout(function () {
- $resizer.simulate('mousedown', { clientY: resizerPosition.top });
- $resizer.simulate('mousemove', { clientY: resizerPosition.top - $rowsHeaders.eq(3).height() + 80 });
- $resizer.simulate('mouseup');
- expect($rowsHeaders.eq(1).height()).toEqual(80);
- expect($rowsHeaders.eq(2).height()).toEqual(80);
- expect($rowsHeaders.eq(3).height()).toEqual(80);
- }, 600);
- setTimeout(function () {
- $resizer.simulate('mousedown', { clientY: resizerPosition.top });
- $resizer.simulate('mousemove', { clientY: resizerPosition.top - $rowsHeaders.eq(3).height() + 35 });
- $resizer.simulate('mouseup');
- expect($rowsHeaders.eq(1).height()).toEqual(35);
- expect($rowsHeaders.eq(2).height()).toEqual(35);
- expect($rowsHeaders.eq(3).height()).toEqual(35);
- done();
- }, 1800);
- });
- describe('handle and guide', function () {
- it('should display the resize handle in the proper position and with a proper size', function () {
- var hot = handsontable({
- data: [{ id: 1, name: 'Ted', lastName: 'Right' }, { id: 2, name: 'Frank', lastName: 'Honest' }, { id: 3, name: 'Joan', lastName: 'Well' }, { id: 4, name: 'Sid', lastName: 'Strong' }, { id: 5, name: 'Jane', lastName: 'Neat' }],
- rowHeaders: true,
- manualRowResize: true
- });
- var $headerTH = this.$container.find('tbody tr:eq(1) th:eq(0)');
- $headerTH.simulate('mouseover');
- var $handle = $('.manualRowResizer');
- expect($handle.offset().top).toBeCloseTo($headerTH.offset().top + $headerTH.outerHeight() - $handle.outerHeight() - 1, 0);
- expect($handle.width()).toBeCloseTo($headerTH.outerWidth(), 0);
- });
- });
- });
- /***/ }),
- /* 144 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('MergeCells', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('mergeCells option', function () {
- it('should merge cell in startup', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5),
- mergeCells: [{ row: 0, col: 0, rowspan: 2, colspan: 2 }]
- });
- var TD = hot.rootElement.querySelector('td');
- expect(TD.getAttribute('rowspan')).toBe('2');
- expect(TD.getAttribute('colspan')).toBe('2');
- });
- });
- describe('mergeCells updateSettings', function () {
- it('should allow to overwrite the initial settings using the updateSettings method', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 10),
- mergeCells: [{ row: 0, col: 0, rowspan: 2, colspan: 2 }]
- });
- var TD = hot.rootElement.querySelector('td');
- expect(TD.getAttribute('rowspan')).toBe('2');
- expect(TD.getAttribute('colspan')).toBe('2');
- updateSettings({
- mergeCells: [{ row: 2, col: 2, rowspan: 2, colspan: 2 }]
- });
- TD = hot.rootElement.querySelector('td');
- expect(TD.getAttribute('rowspan')).toBe(null);
- expect(TD.getAttribute('colspan')).toBe(null);
- TD = getCell(2, 2);
- expect(TD.getAttribute('rowspan')).toBe('2');
- expect(TD.getAttribute('colspan')).toBe('2');
- });
- it('should allow resetting the merged cells by changing it to \'true\'', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 10),
- mergeCells: [{ row: 0, col: 0, rowspan: 2, colspan: 2 }]
- });
- var TD = hot.rootElement.querySelector('td');
- expect(TD.getAttribute('rowspan')).toBe('2');
- expect(TD.getAttribute('colspan')).toBe('2');
- updateSettings({
- mergeCells: true
- });
- TD = hot.rootElement.querySelector('td');
- expect(TD.getAttribute('rowspan')).toBe(null);
- expect(TD.getAttribute('colspan')).toBe(null);
- });
- it('should allow resetting and turning off the mergeCells plugin by changing mergeCells to \'false\'', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 10),
- mergeCells: [{ row: 0, col: 0, rowspan: 2, colspan: 2 }]
- });
- var TD = hot.rootElement.querySelector('td');
- expect(TD.getAttribute('rowspan')).toBe('2');
- expect(TD.getAttribute('colspan')).toBe('2');
- updateSettings({
- mergeCells: false
- });
- TD = hot.rootElement.querySelector('td');
- expect(TD.getAttribute('rowspan')).toBe(null);
- expect(TD.getAttribute('colspan')).toBe(null);
- });
- });
- describe('mergeCells copy', function () {
- it('should not copy text of cells that are merged into another cell', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5),
- mergeCells: [{ row: 0, col: 0, rowspan: 2, colspan: 2 }]
- });
- expect(hot.getCopyableText(0, 0, 2, 2)).toBe('A1\t\tC1\n\t\tC2\nA3\tB3\tC3');
- });
- });
- describe('merged cells selection', function () {
- it('should select the whole range of cells which form a merged cell', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(4, 4),
- mergeCells: [{
- row: 0,
- col: 0,
- colspan: 4,
- rowspan: 1
- }]
- });
- var $table = this.$container.find('table.htCore');
- var $td = $table.find('tr:eq(0) td:eq(0)');
- expect($td.attr('rowspan')).toEqual('1');
- expect($td.attr('colspan')).toEqual('4');
- expect(hot.getSelected()).toBeUndefined();
- hot.selectCell(0, 0);
- expect(hot.getSelected()).toEqual([0, 0, 0, 3]);
- deselectCell();
- hot.selectCell(0, 1);
- expect(hot.getSelected()).toEqual([0, 0, 0, 3]);
- });
- it('should always make a rectangular selection, when selecting merged and not merged cells', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(4, 4),
- mergeCells: [{
- row: 1,
- col: 1,
- colspan: 3,
- rowspan: 2
- }]
- });
- var $table = this.$container.find('table.htCore');
- var $td = $table.find('tr:eq(1) td:eq(1)');
- expect($td.attr('rowspan')).toEqual('2');
- expect($td.attr('colspan')).toEqual('3');
- expect(hot.getSelected()).toBeUndefined();
- hot.selectCell(0, 0);
- expect(hot.getSelected()).toEqual([0, 0, 0, 0]);
- deselectCell();
- hot.selectCell(0, 0, 1, 1);
- expect(hot.getSelected()).not.toEqual([0, 0, 1, 1]);
- expect(hot.getSelected()).toEqual([0, 0, 2, 3]);
- deselectCell();
- hot.selectCell(0, 1, 1, 1);
- expect(hot.getSelected()).toEqual([0, 1, 2, 3]);
- });
- it('should not switch the selection start point when selecting from non-merged cells to merged cells', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 10),
- mergeCells: [{ row: 1, col: 1, rowspan: 3, colspan: 3 }, { row: 3, col: 4, rowspan: 2, colspan: 2 }]
- });
- $(hot.getCell(6, 6)).simulate('mousedown');
- expect(hot.getSelectedRange().from.col).toEqual(6);
- expect(hot.getSelectedRange().from.row).toEqual(6);
- $(hot.getCell(1, 1)).simulate('mouseenter');
- expect(hot.getSelectedRange().from.col).toEqual(6);
- expect(hot.getSelectedRange().from.row).toEqual(6);
- $(hot.getCell(3, 3)).simulate('mouseenter');
- expect(hot.getSelectedRange().from.col).toEqual(6);
- expect(hot.getSelectedRange().from.row).toEqual(6);
- $(hot.getCell(4, 4)).simulate('mouseenter');
- expect(hot.getSelectedRange().from.col).toEqual(6);
- expect(hot.getSelectedRange().from.row).toEqual(6);
- });
- it('should select cells in the correct direction when changing selections around a merged range', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 10),
- mergeCells: [{ row: 4, col: 4, rowspan: 2, colspan: 2 }]
- });
- hot.selectCell(5, 5, 5, 2);
- expect(hot.getSelectedRange().getDirection()).toEqual('SE-NW');
- hot.selectCell(4, 4, 2, 5);
- expect(hot.getSelectedRange().getDirection()).toEqual('SW-NE');
- hot.selectCell(4, 4, 5, 7);
- expect(hot.getSelectedRange().getDirection()).toEqual('NW-SE');
- hot.selectCell(4, 5, 7, 5);
- expect(hot.getSelectedRange().getDirection()).toEqual('NE-SW');
- });
- it('should not add an area class to the selected cell if a single merged cell is selected', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(6, 6),
- mergeCells: [{
- row: 1,
- col: 1,
- colspan: 3,
- rowspan: 2
- }]
- });
- selectCell(1, 1);
- expect(getCell(1, 1).className.indexOf('area')).toEqual(-1);
- selectCell(1, 1, 4, 4);
- expect(getCell(1, 1).className.indexOf('area')).not.toEqual(-1);
- selectCell(1, 1);
- expect(getCell(1, 1).className.indexOf('area')).toEqual(-1);
- selectCell(0, 0);
- expect(getCell(1, 1).className.indexOf('area')).toEqual(-1);
- });
- });
- describe('merged cells scroll', function () {
- it('getCell should return merged cell parent', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5),
- mergeCells: [{ row: 0, col: 0, rowspan: 2, colspan: 2 }],
- height: 100,
- width: 400
- });
- var mergedCellParent = hot.getCell(0, 0);
- var mergedCellHidden = hot.getCell(1, 1);
- expect(mergedCellHidden).toBe(mergedCellParent);
- });
- it('should scroll viewport to beginning of a merged cell when it\'s clicked', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5),
- mergeCells: [{ row: 5, col: 0, rowspan: 2, colspan: 2 }],
- height: 100,
- width: 400
- });
- var mainHolder = hot.view.wt.wtTable.holder;
- mainHolder.scrollTop = 130;
- hot.render();
- expect(mainHolder.scrollTop).toBe(130);
- var TD = hot.getCell(5, 0);
- mouseDown(TD);
- mouseUp(TD);
- var mergedCellScrollTop = mainHolder.scrollTop;
- expect(mergedCellScrollTop).toBeLessThan(130);
- expect(mergedCellScrollTop).toBeGreaterThan(0);
- mainHolder.scrollTop = 0;
- hot.render();
- mainHolder.scrollTop = 130;
- hot.render();
- TD = hot.getCell(5, 2);
- mouseDown(TD);
- mouseUp(TD);
- var regularCellScrollTop = mainHolder.scrollTop;
- expect(mergedCellScrollTop).toBe(regularCellScrollTop);
- });
- it('should render whole merged cell even when most rows are not in the viewport - scrolled to top', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(40, 5),
- mergeCells: [{ row: 1, col: 0, rowspan: 21, colspan: 2 }, { row: 21, col: 2, rowspan: 18, colspan: 2 }],
- height: 100,
- width: 400
- });
- expect(hot.countRenderedRows()).toBe(39);
- });
- it('should render whole merged cell even when most rows are not in the viewport - scrolled to bottom', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(40, 5),
- mergeCells: [{ row: 1, col: 0, rowspan: 21, colspan: 2 }, { row: 21, col: 2, rowspan: 18, colspan: 2 }],
- height: 100,
- width: 400
- });
- var mainHolder = hot.view.wt.wtTable.holder;
- $(mainHolder).scrollTop(99999);
- hot.render();
- expect(hot.countRenderedRows()).toBe(39);
- });
- it('should render whole merged cell even when most columns are not in the viewport - scrolled to the left', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(5, 40),
- mergeCells: [{ row: 0, col: 1, rowspan: 2, colspan: 21 }, { row: 2, col: 21, rowspan: 2, colspan: 18 }],
- height: 100,
- width: 400
- });
- expect(hot.countRenderedCols()).toBe(39);
- });
- it('should render whole merged cell even when most columns are not in the viewport - scrolled to the right', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(5, 40),
- mergeCells: [{ row: 0, col: 1, rowspan: 2, colspan: 21 }, { row: 2, col: 21, rowspan: 2, colspan: 18 }],
- height: 100,
- width: 400
- });
- this.$container.scrollLeft(99999);
- hot.render();
- expect(hot.countRenderedCols()).toBe(39);
- });
- });
- describe('merge cells shift', function () {
- it('should shift the merged cells right, when inserting a column on the left side of them', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(20, 20),
- mergeCells: [{ row: 1, col: 1, rowspan: 2, colspan: 2 }, { row: 2, col: 5, rowspan: 2, colspan: 2 }],
- height: 400,
- width: 400
- });
- hot.alter('insert_col', 3, 2);
- expect(hot.mergeCells.mergedCellInfoCollection[0].col).toEqual(1);
- expect(hot.mergeCells.mergedCellInfoCollection[1].col).toEqual(6);
- });
- it('should shift the merged cells left, when removing a column on the left side of them', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(20, 20),
- mergeCells: [{ row: 1, col: 1, rowspan: 2, colspan: 2 }, { row: 2, col: 5, rowspan: 2, colspan: 2 }],
- height: 400,
- width: 400
- });
- hot.alter('remove_col', 3, 2);
- expect(hot.mergeCells.mergedCellInfoCollection[0].col).toEqual(1);
- expect(hot.mergeCells.mergedCellInfoCollection[1].col).toEqual(4);
- });
- it('should shift the merged cells down, when inserting a row above them', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(20, 20),
- mergeCells: [{ row: 1, col: 1, rowspan: 2, colspan: 2 }, { row: 5, col: 5, rowspan: 2, colspan: 2 }],
- height: 400,
- width: 400
- });
- hot.alter('insert_row', 3, 2);
- expect(hot.mergeCells.mergedCellInfoCollection[0].row).toEqual(1);
- expect(hot.mergeCells.mergedCellInfoCollection[1].row).toEqual(6);
- });
- it('should shift the merged cells down, when inserting a row above them', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(20, 20),
- mergeCells: [{ row: 1, col: 1, rowspan: 2, colspan: 2 }, { row: 5, col: 5, rowspan: 2, colspan: 2 }],
- height: 400,
- width: 400
- });
- hot.alter('remove_row', 3, 2);
- expect(hot.mergeCells.mergedCellInfoCollection[0].row).toEqual(1);
- expect(hot.mergeCells.mergedCellInfoCollection[1].row).toEqual(4);
- });
- });
- xdescribe('canMergeRange', function () {
- it('should return false if start and end cell is the same', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5)
- });
- var mergeCells = new Handsontable.plugins.MergeCells(hot);
- var coordsFrom = new WalkontableCellCoords(0, 1);
- var cellRange = new WalkontableCellRange(coordsFrom, coordsFrom, new WalkontableCellCoords(0, 1));
- var result = mergeCells.canMergeRange(cellRange);
- expect(result).toBe(false);
- });
- it('should return true for 2 consecutive cells in the same column', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5)
- });
- var mergeCells = new Handsontable.plugins.MergeCells(hot);
- var coordsFrom = new WalkontableCellCoords(0, 1);
- var cellRange = new WalkontableCellRange(coordsFrom, coordsFrom, new WalkontableCellCoords(1, 1));
- var result = mergeCells.canMergeRange(cellRange);
- expect(result).toBe(true);
- });
- it('should return true for 2 consecutive cells in the same row', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5)
- });
- var mergeCells = new Handsontable.MergeCells(hot);
- var coordsFrom = new WalkontableCellCoords(0, 1);
- var cellRange = new WalkontableCellRange(coordsFrom, coordsFrom, new WalkontableCellCoords(0, 2));
- var result = mergeCells.canMergeRange(cellRange);
- expect(result).toBe(true);
- });
- it('should return true for 4 neighboring cells', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5)
- });
- var mergeCells = new Handsontable.MergeCells(hot);
- var coordsFrom = new WalkontableCellCoords(0, 1);
- var cellRange = new WalkontableCellRange(coordsFrom, coordsFrom, new WalkontableCellCoords(1, 2));
- var result = mergeCells.canMergeRange(cellRange);
- expect(result).toBe(true);
- });
- });
- xdescribe('modifyTransform', function () {
- it('should not transform arrow right when entering a merged cell', function () {
- var mergeCellsSettings = [{ row: 1, col: 1, rowspan: 3, colspan: 3 }];
- var coords = new WalkontableCellCoords(1, 0);
- var currentSelection = new WalkontableCellRange(coords, coords, coords);
- var mergeCells = new Handsontable.MergeCells(mergeCellsSettings);
- var inDelta = new WalkontableCellCoords(0, 1);
- mergeCells.modifyTransform('modifyTransformStart', currentSelection, inDelta);
- expect(inDelta).toEqual(new WalkontableCellCoords(0, 1));
- });
- it('should transform arrow right when leaving a merged cell', function () {
- var mergeCellsSettings = [{ row: 1, col: 1, rowspan: 3, colspan: 3 }];
- var coords = new WalkontableCellCoords(1, 1);
- var currentSelection = new WalkontableCellRange(coords, coords, coords);
- var mergeCells = new Handsontable.MergeCells(mergeCellsSettings);
- var inDelta = new WalkontableCellCoords(0, 1);
- mergeCells.modifyTransform('modifyTransformStart', currentSelection, inDelta);
- expect(inDelta).toEqual(new WalkontableCellCoords(0, 3));
- });
- it('should transform arrow right when leaving a merged cell (return to desired row)', function () {
- var mergeCellsSettings = [{ row: 1, col: 1, rowspan: 3, colspan: 3 }];
- var mergeCells = new Handsontable.MergeCells(mergeCellsSettings);
- var coords = new WalkontableCellCoords(2, 0);
- var currentSelection = new WalkontableCellRange(coords, coords, coords);
- var inDelta = new WalkontableCellCoords(0, 1);
- mergeCells.modifyTransform('modifyTransformStart', currentSelection, inDelta);
- expect(inDelta).toEqual(new WalkontableCellCoords(-1, 1));
- coords = new WalkontableCellCoords(1, 1);
- currentSelection = new WalkontableCellRange(coords, coords, coords);
- inDelta = new WalkontableCellCoords(0, 1);
- mergeCells.modifyTransform('modifyTransformStart', currentSelection, inDelta);
- expect(inDelta).toEqual(new WalkontableCellCoords(1, 3));
- });
- it('should transform arrow left when entering a merged cell', function () {
- var mergeCellsSettings = [{ row: 1, col: 1, rowspan: 3, colspan: 3 }];
- var coords = new WalkontableCellCoords(1, 4);
- var currentSelection = new WalkontableCellRange(coords, coords, coords);
- var mergeCells = new Handsontable.MergeCells(mergeCellsSettings);
- var inDelta = new WalkontableCellCoords(0, -1);
- mergeCells.modifyTransform('modifyTransformStart', currentSelection, inDelta);
- expect(inDelta).toEqual(new WalkontableCellCoords(0, -3));
- });
- it('should not transform arrow left when leaving a merged cell', function () {
- var mergeCellsSettings = [{ row: 1, col: 1, rowspan: 3, colspan: 3 }];
- var coords = new WalkontableCellCoords(1, 1);
- var currentSelection = new WalkontableCellRange(coords, coords, coords);
- var mergeCells = new Handsontable.MergeCells(mergeCellsSettings);
- var inDelta = new WalkontableCellCoords(0, -1);
- mergeCells.modifyTransform('modifyTransformStart', currentSelection, inDelta);
- expect(inDelta).toEqual(new WalkontableCellCoords(0, -1));
- });
- it('should transform arrow left when leaving a merged cell (return to desired row)', function () {
- var mergeCellsSettings = [{ row: 1, col: 1, rowspan: 3, colspan: 3 }];
- var mergeCells = new Handsontable.MergeCells(mergeCellsSettings);
- var coords = new WalkontableCellCoords(2, 4);
- var currentSelection = new WalkontableCellRange(coords, coords, coords);
- var inDelta = new WalkontableCellCoords(0, -1);
- mergeCells.modifyTransform('modifyTransformStart', currentSelection, inDelta);
- expect(inDelta).toEqual(new WalkontableCellCoords(-1, -3));
- coords = new WalkontableCellCoords(1, 1);
- currentSelection = new WalkontableCellRange(coords, coords, coords);
- inDelta = new WalkontableCellCoords(0, -1);
- mergeCells.modifyTransform('modifyTransformStart', currentSelection, inDelta);
- expect(inDelta).toEqual(new WalkontableCellCoords(1, -1));
- });
- it('should not transform arrow down when entering a merged cell', function () {
- var mergeCellsSettings = [{ row: 1, col: 1, rowspan: 3, colspan: 3 }];
- var coords = new WalkontableCellCoords(0, 1);
- var currentSelection = new WalkontableCellRange(coords, coords, coords);
- var mergeCells = new Handsontable.MergeCells(mergeCellsSettings);
- var inDelta = new WalkontableCellCoords(0, -1);
- mergeCells.modifyTransform('modifyTransformStart', currentSelection, inDelta);
- expect(inDelta).toEqual(new WalkontableCellCoords(0, -1));
- });
- it('should transform arrow down when leaving a merged cell', function () {
- var mergeCellsSettings = [{ row: 1, col: 1, rowspan: 3, colspan: 3 }];
- var coords = new WalkontableCellCoords(1, 1);
- var currentSelection = new WalkontableCellRange(coords, coords, coords);
- var mergeCells = new Handsontable.MergeCells(mergeCellsSettings);
- var inDelta = new WalkontableCellCoords(1, 0);
- mergeCells.modifyTransform('modifyTransformStart', currentSelection, inDelta);
- expect(inDelta).toEqual(new WalkontableCellCoords(3, 0));
- });
- it('should transform arrow up when entering a merged cell', function () {
- var mergeCellsSettings = [{ row: 1, col: 1, rowspan: 3, colspan: 3 }];
- var coords = new WalkontableCellCoords(4, 1);
- var currentSelection = new WalkontableCellRange(coords, coords, coords);
- var mergeCells = new Handsontable.MergeCells(mergeCellsSettings);
- var inDelta = new WalkontableCellCoords(-1, 0);
- mergeCells.modifyTransform('modifyTransformStart', currentSelection, inDelta);
- expect(inDelta).toEqual(new WalkontableCellCoords(-3, 0));
- });
- it('should not transform arrow up when leaving a merged cell', function () {
- var mergeCellsSettings = [{ row: 1, col: 1, rowspan: 3, colspan: 3 }];
- var coords = new WalkontableCellCoords(1, 1);
- var currentSelection = new WalkontableCellRange(coords, coords, coords);
- var mergeCells = new Handsontable.MergeCells(mergeCellsSettings);
- var inDelta = new WalkontableCellCoords(-1, 0);
- mergeCells.modifyTransform('modifyTransformStart', currentSelection, inDelta);
- expect(inDelta).toEqual(new WalkontableCellCoords(-1, 0));
- });
- });
- describe('ContextMenu', function () {
- it('should disable `Merge cells` context menu item when context menu was triggered from corner header', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 5),
- rowHeaders: true,
- colHeaders: true,
- contextMenu: true,
- mergeCells: true
- });
- $('.ht_clone_top_left_corner .htCore').find('thead').find('th').eq(0).simulate('mousedown', { which: 3 });
- contextMenu();
- expect($('.htContextMenu tbody td.htDisabled').text()).toBe(['Insert column on the left', 'Insert column on the right', 'Remove row', 'Remove column', 'Undo', 'Redo', 'Read only', 'Alignment', 'Merge cells'].join(''));
- });
- });
- });
- /***/ }),
- /* 145 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('HandsontableObserveChanges', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- function createHOT(data, observeChanges) {
- return handsontable({
- data: data,
- width: 200,
- height: 200,
- observeChanges: observeChanges
- });
- }
- describe('refreshing table after changes have been detected', function () {
- describe('array data', function () {
- it('should render newly added row', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- data.push(['A3', 'B3']);
- var htCore = getHtCore();
- setTimeout(function () {
- expect(htCore.find('tr').length).toEqual(3);
- expect(htCore.find('col').length).toEqual(2);
- done();
- }, 200);
- });
- it('should render newly added column', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- data[0].push('C1');
- data[1].push('C2');
- setTimeout(function () {
- expect(htCore.find('tr').length).toEqual(2);
- expect(htCore.find('col').length).toEqual(3);
- done();
- }, 200);
- });
- it('should render removed row', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- data.splice(0, 1); // removes one row at index 0
- setTimeout(function () {
- expect(htCore.find('tr').length).toEqual(1);
- expect(htCore.find('col').length).toEqual(2);
- done();
- }, 200);
- });
- it('should render removed column', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- data[0].splice(0, 1); // removes one column at index 0 in first row
- data[1].splice(0, 1); // removes one column at index 0 in second row
- setTimeout(function () {
- expect(htCore.find('tr').length).toEqual(2);
- expect(htCore.find('col').length).toEqual(1);
- done();
- }, 200);
- });
- it('should render cell change from string to string', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- data[0][0] = 'new string';
- setTimeout(function () {
- expect(htCore.find('td:eq(0)').html()).toEqual('new string');
- done();
- }, 200);
- });
- it('should render cell change in a new row', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- data.push(['A3', 'B3']);
- setTimeout(function () {
- expect(htCore.find('tr:eq(2) td:eq(0)').html()).toEqual('A3');
- data[2][0] = 'new string';
- }, 200);
- setTimeout(function () {
- expect(htCore.find('tr:eq(2) td:eq(0)').html()).toEqual('new string');
- done();
- }, 1200);
- });
- it('should not render cell change when turned off (`observeChanges: false`)', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- createHOT(data, false);
- var htCore = getHtCore();
- data[0][0] = 'new string';
- setTimeout(function () {
- expect(htCore.find('td:eq(0)').html()).toEqual('A1');
- done();
- }, 100);
- });
- });
- describe('object data', function () {
- it('should render newly added row', function (done) {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- data.push({ prop0: 'A3', prop1: 'B3' });
- setTimeout(function () {
- expect(htCore.find('tr').length).toEqual(3);
- expect(htCore.find('col').length).toEqual(2);
- done();
- }, 200);
- });
- it('should render removed row', function (done) {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- data.splice(0, 1); // removes one row at index 0
- setTimeout(function () {
- expect(htCore.find('tr').length).toEqual(1);
- expect(htCore.find('col').length).toEqual(2);
- done();
- }, 200);
- });
- it('should render cell change from string to string', function (done) {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- data[0].prop0 = 'new string';
- setTimeout(function () {
- expect(htCore.find('td:eq(0)').html()).toEqual('new string');
- done();
- }, 200);
- });
- it('should render cell change in a new row', function (done) {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- data.push({ prop0: 'A3', prop1: 'B3' });
- setTimeout(function () {
- expect(htCore.find('tr:eq(2) td:eq(0)').html()).toEqual('A3');
- data[2].prop0 = 'new string';
- }, 200);
- setTimeout(function () {
- expect(htCore.find('tr:eq(2) td:eq(0)').html()).toEqual('new string');
- done();
- }, 1200);
- });
- it('should not break with undefined data properties', function () {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- data[0].prop0 = undefined;
- expect(function () {
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- }).not.toThrow();
- });
- it('should not render cell change when turned off (`observeChanges: false`)', function (done) {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- createHOT(data, false);
- var htCore = getHtCore();
- data[0].prop0 = 'new string';
- setTimeout(function () {
- expect(htCore.find('td:eq(0)').html()).toEqual('A1');
- done();
- }, 200);
- });
- });
- });
- describe('enabling/disabling plugin', function () {
- it('should be possible to enable plugin using updateSettings', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, false);
- var htCore = getHtCore();
- data[0][0] = 'new string';
- setTimeout(function () {
- expect(htCore.find('td:eq(0)').html()).toEqual('A1');
- updateSettings({
- observeChanges: true
- });
- data[1][0] = 'another new string';
- }, 200);
- setTimeout(function () {
- expect(htCore.find('tr:eq(1) td:eq(0)').html()).toEqual('another new string');
- done();
- }, 400);
- });
- it('should be possible to disable plugin using updateSettings', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- data[0][0] = 'new string';
- setTimeout(function () {
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').html()).toEqual('new string');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').html()).toEqual('A2');
- updateSettings({
- observeChanges: false
- });
- data[1][0] = 'another new string';
- }, 200);
- setTimeout(function () {
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').html()).toEqual('new string');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').html()).toEqual('A2');
- hot.render();
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').html()).toEqual('new string');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').html()).toEqual('another new string');
- done();
- }, 300);
- });
- it('should be possible to pause observing changes without disabling the plugin', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- data[0][0] = 'new string';
- setTimeout(function () {
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').html()).toEqual('new string');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').html()).toEqual('A2');
- hot.pauseObservingChanges();
- data[1][0] = 'another new string';
- }, 200);
- setTimeout(function () {
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').html()).toEqual('new string');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').html()).toEqual('A2');
- hot.render();
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').html()).toEqual('new string');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').html()).toEqual('another new string');
- done();
- }, 300);
- });
- it('should be possible to resume observing changes after it was paused', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- hot.pauseObservingChanges();
- data[0][0] = 'new string';
- setTimeout(function () {
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').html()).toEqual('A1');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').html()).toEqual('A2');
- hot.resumeObservingChanges();
- data[1][0] = 'another new string';
- }, 100);
- setTimeout(function () {
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').html()).toEqual('new string');
- expect(htCore.find('tbody tr:eq(1) td:eq(0)').html()).toEqual('another new string');
- done();
- }, 1200);
- });
- });
- describe('observeChanges fires appropriate events when changes are detected', function () {
- describe('array data', function () {
- it('should fire afterChangesObserved event after changes has been noticed', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var afterChangesObservedCallback = jasmine.createSpy('afterChangesObservedCallback');
- hot.addHook('afterChangesObserved', afterChangesObservedCallback);
- data[0][0] = 'new string';
- setTimeout(function () {
- expect(afterChangesObservedCallback.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- it('should fire afterCreateRow event after detecting that new row has been added', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var afterCreateRowCallback = jasmine.createSpy('afterCreateRowCallback');
- hot.addHook('afterCreateRow', afterCreateRowCallback);
- data.push(['A2', 'B2']);
- setTimeout(function () {
- expect(afterCreateRowCallback.calls.count()).toEqual(1);
- expect(afterCreateRowCallback).toHaveBeenCalledWith(2, 1, 'ObserveChanges.change', undefined, undefined, undefined);
- done();
- }, 200);
- });
- it('should fire afterRemoveRow event after detecting that row has been removed', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var afterRemoveRowCallback = jasmine.createSpy('afterRemoveRowCallback');
- hot.addHook('afterRemoveRow', afterRemoveRowCallback);
- data.pop();
- setTimeout(function () {
- expect(afterRemoveRowCallback.calls.count()).toEqual(1);
- expect(afterRemoveRowCallback).toHaveBeenCalledWith(1, 1, 'ObserveChanges.change', undefined, undefined, undefined);
- done();
- }, 200);
- });
- it('should fire afterRemoveRow event after detecting that multiple rows have been removed', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var afterRemoveRowCallback = jasmine.createSpy('afterRemoveRowCallback');
- hot.addHook('afterRemoveRow', afterRemoveRowCallback);
- data.splice(0, 2);
- setTimeout(function () {
- expect(afterRemoveRowCallback.calls.count()).toEqual(2);
- // The order of run hooks depends on whether objectObserve uses native Object.observe or a shim
- var args = [];
- args.push(afterRemoveRowCallback.calls.argsFor(0));
- args.push(afterRemoveRowCallback.calls.argsFor(1));
- expect(args).toContain([1, 1, 'ObserveChanges.change', undefined, undefined, undefined]);
- expect(args).toContain([0, 1, 'ObserveChanges.change', undefined, undefined, undefined]);
- done();
- }, 200);
- });
- it('should fire afterCreateCol event after detecting that new col has been added', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var afterCreateColCallback = jasmine.createSpy('afterCreateColCallback');
- hot.addHook('afterCreateCol', afterCreateColCallback);
- data[0].push('C1');
- data[1].push('C2');
- setTimeout(function () {
- expect(afterCreateColCallback.calls.count()).toEqual(1);
- expect(afterCreateColCallback.calls.argsFor(0)).toEqual([2, 1, 'ObserveChanges.change', undefined, undefined, undefined]);
- done();
- }, 200);
- });
- it('should fire afterRemoveCol event after detecting that col has been removed', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var afterRemoveColCallback = jasmine.createSpy('afterRemoveColCallback');
- hot.addHook('afterRemoveCol', afterRemoveColCallback);
- data[0].pop();
- data[1].pop();
- setTimeout(function () {
- expect(afterRemoveColCallback.calls.count()).toEqual(1);
- expect(afterRemoveColCallback.calls.argsFor(0)).toEqual([1, 1, 'ObserveChanges.change', undefined, undefined, undefined]);
- done();
- }, 200);
- });
- it('should fire afterRemoveCol event after detecting that multiple cols have been removed', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var afterRemoveColCallback = jasmine.createSpy('afterRemoveColCallback');
- hot.addHook('afterRemoveCol', afterRemoveColCallback);
- data[0].pop();
- data[0].pop();
- data[1].pop();
- data[1].pop();
- setTimeout(function () {
- expect(afterRemoveColCallback.calls.count()).toEqual(2);
- // The order of run hooks depends on whether objectObserve uses native Object.observe or a shim
- var args = [];
- args.push(afterRemoveColCallback.calls.argsFor(0));
- args.push(afterRemoveColCallback.calls.argsFor(1));
- expect(args).toContain([1, 1, 'ObserveChanges.change', undefined, undefined, undefined]);
- expect(args).toContain([0, 1, 'ObserveChanges.change', undefined, undefined, undefined]);
- done();
- }, 200);
- });
- it('should fire afterChange event after detecting that table data has changed', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- hot.addHook('afterChange', afterChangeCallback);
- data[0][0] = 'new string';
- setTimeout(function () {
- expect(afterChangeCallback.calls.count()).toEqual(1);
- expect(afterChangeCallback).toHaveBeenCalledWith([0, 0, null, 'new string'], 'ObserveChanges.change', undefined, undefined, undefined, undefined);
- done();
- }, 200);
- });
- });
- describe('object data', function () {
- it('should fire afterChangesObserved event after changes has been noticed', function (done) {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- var hot = createHOT(data, true);
- var afterChangesObservedCallback = jasmine.createSpy('afterChangesObservedCallback');
- hot.addHook('afterChangesObserved', afterChangesObservedCallback);
- data[0].prop0 = 'new string';
- setTimeout(function () {
- expect(afterChangesObservedCallback.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- it('should fire afterCreateRow event after detecting that new row has been added', function (done) {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- var hot = createHOT(data, true);
- var afterCreateRowCallback = jasmine.createSpy('afterCreateRowCallback');
- hot.addHook('afterCreateRow', afterCreateRowCallback);
- data.push({ prop0: 'A2', prop1: 'B2' });
- setTimeout(function () {
- expect(afterCreateRowCallback.calls.count()).toEqual(1);
- expect(afterCreateRowCallback).toHaveBeenCalledWith(2, 1, 'ObserveChanges.change', undefined, undefined, undefined);
- done();
- }, 200);
- });
- it('should fire afterRemoveRow event after detecting that row has been removed', function (done) {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- var hot = createHOT(data, true);
- var afterRemoveRowCallback = jasmine.createSpy('afterRemoveRowCallback');
- hot.addHook('afterRemoveRow', afterRemoveRowCallback);
- data.pop();
- setTimeout(function () {
- expect(afterRemoveRowCallback.calls.count()).toEqual(1);
- expect(afterRemoveRowCallback).toHaveBeenCalledWith(1, 1, 'ObserveChanges.change', undefined, undefined, undefined);
- done();
- }, 200);
- });
- it('should fire afterRemoveRow event after detecting that multiple rows have been removed', function (done) {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- var hot = createHOT(data, true);
- var afterRemoveRowCallback = jasmine.createSpy('afterRemoveRowCallback');
- hot.addHook('afterRemoveRow', afterRemoveRowCallback);
- data.splice(0, 2);
- setTimeout(function () {
- expect(afterRemoveRowCallback.calls.count()).toEqual(2);
- // The order of run hooks depends on whether objectObserve uses native Object.observe or a shim
- var args = [];
- args.push(afterRemoveRowCallback.calls.argsFor(0));
- args.push(afterRemoveRowCallback.calls.argsFor(1));
- expect(args).toContain([1, 1, 'ObserveChanges.change', undefined, undefined, undefined]);
- expect(args).toContain([0, 1, 'ObserveChanges.change', undefined, undefined, undefined]);
- done();
- }, 200);
- });
- it('should fire afterChange event after detecting that table data has changed', function (done) {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- var hot = createHOT(data, true);
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- hot.addHook('afterChange', afterChangeCallback);
- data[0].prop0 = 'new string';
- setTimeout(function () {
- expect(afterChangeCallback.calls.count()).toEqual(1);
- expect(afterChangeCallback).toHaveBeenCalledWith([0, 'prop0', null, 'new string'], 'ObserveChanges.change', undefined, undefined, undefined, undefined);
- done();
- }, 200);
- });
- });
- });
- describe('using HOT data manipulation methods, when observeChanges plugin is enabled', function () {
- describe('array data', function () {
- it('should run render ONCE after detecting that new row has been added', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var afterRenderSpy = jasmine.createSpy('afterRenderSpy');
- hot.addHook('afterRender', afterRenderSpy);
- alter('insert_row');
- setTimeout(function () {
- expect(countRows()).toEqual(3);
- expect(afterRenderSpy.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- it('should run render ONCE after detecting that row has been removed', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var afterRenderSpy = jasmine.createSpy('afterRenderSpy');
- hot.addHook('afterRender', afterRenderSpy);
- var afterChangesObservedCallback = jasmine.createSpy('afterChangesObservedCallback');
- hot.addHook('afterChangesObserved', afterChangesObservedCallback);
- alter('remove_row');
- setTimeout(function () {
- expect(countRows()).toEqual(1);
- expect(afterChangesObservedCallback.calls.count()).toEqual(1);
- expect(afterRenderSpy.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- it('should run render ONCE after detecting that new column has been added', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var afterRenderSpy = jasmine.createSpy('afterRenderSpy');
- hot.addHook('afterRender', afterRenderSpy);
- alter('insert_col');
- setTimeout(function () {
- expect(countCols()).toEqual(3);
- expect(afterRenderSpy.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- it('should run render ONCE after detecting that column has been removed', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var afterRenderSpy = jasmine.createSpy('afterRenderSpy');
- hot.addHook('afterRender', afterRenderSpy);
- var afterChangesObservedCallback = jasmine.createSpy('afterChangesObservedCallback');
- hot.addHook('afterChangesObserved', afterChangesObservedCallback);
- alter('remove_col');
- setTimeout(function () {
- expect(countCols()).toEqual(1);
- expect(afterChangesObservedCallback.calls.count()).toEqual(1);
- expect(afterRenderSpy.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- it('should run render ONCE after detecting that table data has changed', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- var afterRenderSpy = jasmine.createSpy('afterRenderSpy');
- hot.addHook('afterRender', afterRenderSpy);
- var afterChangesObservedCallback = jasmine.createSpy('afterChangesObservedCallback');
- hot.addHook('afterChangesObserved', afterChangesObservedCallback);
- setDataAtCell(0, 0, 'new value');
- setTimeout(function () {
- expect(htCore.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('new value');
- expect(afterChangesObservedCallback.calls.count()).toEqual(1);
- expect(afterRenderSpy.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- });
- describe('object data', function () {
- it('should run render ONCE after detecting that new row has been added', function (done) {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- var hot = createHOT(data, true);
- var afterRenderSpy = jasmine.createSpy('afterRenderSpy');
- hot.addHook('afterRender', afterRenderSpy);
- alter('insert_row');
- setTimeout(function () {
- expect(countRows()).toEqual(3);
- expect(afterRenderSpy.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- it('should run render ONCE after detecting that row has been removed', function (done) {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- var hot = createHOT(data, true);
- var afterRenderSpy = jasmine.createSpy('afterRenderSpy');
- hot.addHook('afterRender', afterRenderSpy);
- var afterChangesObservedCallback = jasmine.createSpy('afterChangesObservedCallback');
- hot.addHook('afterChangesObserved', afterChangesObservedCallback);
- alter('remove_row');
- setTimeout(function () {
- expect(countRows()).toEqual(1);
- expect(afterChangesObservedCallback.calls.count()).toEqual(1);
- expect(afterRenderSpy.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- it('should run render ONCE after detecting that table data has changed', function (done) {
- var data = Handsontable.helper.createSpreadsheetObjectData(2, 2);
- var hot = createHOT(data, true);
- var afterRenderSpy = jasmine.createSpy('afterRenderSpy');
- hot.addHook('afterRender', afterRenderSpy);
- var afterChangesObservedCallback = jasmine.createSpy('afterChangesObservedCallback');
- hot.addHook('afterChangesObserved', afterChangesObservedCallback);
- setDataAtRowProp(0, 'prop0', 'new value');
- setTimeout(function () {
- expect(spec().$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('new value');
- expect(afterChangesObservedCallback.calls.count()).toEqual(1);
- expect(afterRenderSpy.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- });
- });
- describe('refreshing table after changes have been detected', function () {
- it('should observe changes to new data bound using loadData', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var newData = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- hot.loadData(newData);
- var afterRenderSpy = jasmine.createSpy('afterRenderSpy');
- hot.addHook('afterRender', afterRenderSpy);
- newData.push(['A3', 'B3']);
- setTimeout(function () {
- expect(afterRenderSpy.calls.count()).toBe(1);
- expect(htCore.find('tr').length).toEqual(3);
- expect(htCore.find('col').length).toEqual(2);
- done();
- }, 200);
- });
- it('should not observe changes to old data after it was replaced using loadData', function (done) {
- var data = Handsontable.helper.createSpreadsheetData(2, 2);
- var newData = Handsontable.helper.createSpreadsheetData(2, 2);
- var hot = createHOT(data, true);
- var htCore = getHtCore();
- hot.loadData(newData);
- var afterRenderSpy = jasmine.createSpy('afterRenderSpy');
- hot.addHook('afterRender', afterRenderSpy);
- data.push(['A3', 'B3']);
- setTimeout(function () {
- expect(afterRenderSpy.calls.count()).toBe(0);
- expect(htCore.find('tr').length).toEqual(2);
- expect(htCore.find('col').length).toEqual(2);
- done();
- }, 1000);
- });
- });
- });
- /***/ }),
- /* 146 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('persistentState', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- window.localStorage.clear();
- });
- it('should save data, when persistentStateSave is run', function () {
- var hot = handsontable({
- persistentState: true
- });
- hot.runHooks('persistentStateSave', 'testData', 100);
- var rawStoredData = window.localStorage[id + '_testData'];
- expect(rawStoredData).toBeDefined();
- var storedData = JSON.parse(rawStoredData);
- expect(storedData).toEqual(100);
- });
- it('should NOT save data, when persistentStateSave is run, if plugin is not enabled', function () {
- var hot = handsontable({
- persistentState: false
- });
- hot.runHooks('persistentStateSave', 'testData', 100);
- var rawStoredData = window.localStorage[id + '_testData'];
- expect(rawStoredData).toBeUndefined();
- });
- it('should load data, when persistentStateLoad is run', function () {
- var hot = handsontable({
- persistentState: true
- });
- hot.runHooks('persistentStateSave', 'testData', 100);
- var storedData = {};
- hot.runHooks('persistentStateLoad', 'testData', storedData);
- expect(storedData.value).toEqual(100);
- });
- it('should NOT load data, when persistentStateLoad is run, if plugin is not enabled', function () {
- var hot = handsontable({
- persistentState: false
- });
- // We have to manually save data, as persistentStateSave won't work when the plugin is disabled
- window.localStorage[id + '_testData'] = JSON.stringify(100);
- var storedData = {};
- hot.runHooks('persistentStateLoad', 'testData', storedData);
- expect(storedData.value).toBeUndefined();
- });
- it('should clear the data under the given key, when persistentStateReset is run', function () {
- var hot = handsontable({
- persistentState: true
- });
- hot.runHooks('persistentStateSave', 'testData', 100);
- var storedData = {};
- hot.runHooks('persistentStateLoad', 'testData', storedData);
- expect(storedData.value).toEqual(100);
- hot.runHooks('persistentStateReset', 'testData');
- storedData = {};
- hot.runHooks('persistentStateLoad', 'testData', storedData);
- expect(storedData.value).toBeUndefined();
- });
- it('should NOT clear the data under the given key, when persistentStateReset is run', function () {
- var hot = handsontable({
- persistentState: false
- });
- // We have to manually save data, as persistentStateSave won't work when the plugin is disabled
- window.localStorage[id + '_testData'] = JSON.stringify(100);
- var storedData = {};
- hot.runHooks('persistentStateReset', 'testData');
- expect(JSON.parse(window.localStorage[id + '_testData'])).toEqual(100);
- });
- it('should clear all data, when persistentStateReset is run without specifying a key to reset', function () {
- var hot = handsontable({
- persistentState: true
- });
- hot.runHooks('persistentStateSave', 'testData0', 100);
- hot.runHooks('persistentStateSave', 'testData1', 'foo');
- hot.runHooks('persistentStateSave', 'testData2', 200);
- var storedData = [{}, {}, {}];
- hot.runHooks('persistentStateLoad', 'testData0', storedData[0]);
- hot.runHooks('persistentStateLoad', 'testData1', storedData[1]);
- hot.runHooks('persistentStateLoad', 'testData2', storedData[2]);
- expect(storedData[0].value).toEqual(100);
- expect(storedData[1].value).toEqual('foo');
- expect(storedData[2].value).toEqual(200);
- hot.runHooks('persistentStateReset');
- storedData = [{}, {}, {}];
- hot.runHooks('persistentStateLoad', 'testData0', storedData[0]);
- hot.runHooks('persistentStateLoad', 'testData1', storedData[1]);
- hot.runHooks('persistentStateLoad', 'testData2', storedData[2]);
- expect(storedData[0].value).toBeUndefined();
- expect(storedData[1].value).toBeUndefined();
- expect(storedData[2].value).toBeUndefined();
- });
- it('should allow to DISABLE plugin with updateSettings', function () {
- var hot = handsontable({
- persistentState: true
- });
- hot.runHooks('persistentStateSave', 'testData', 100);
- var storedData = {};
- hot.runHooks('persistentStateLoad', 'testData', storedData);
- expect(storedData.value).toEqual(100);
- updateSettings({
- persistentState: false
- });
- storedData = {};
- hot.runHooks('persistentStateLoad', 'testData', storedData);
- expect(storedData.value).toBeUndefined();
- });
- it('should allow to ENABLE plugin with updateSettings', function () {
- var hot = handsontable({
- persistentState: false
- });
- hot.runHooks('persistentStateSave', 'testData', 100);
- var storedData = {};
- hot.runHooks('persistentStateLoad', 'testData', storedData);
- expect(storedData.value).toBeUndefined();
- updateSettings({
- persistentState: true
- });
- hot.runHooks('persistentStateSave', 'testData', 100);
- storedData = {};
- hot.runHooks('persistentStateLoad', 'testData', storedData);
- expect(storedData.value).toEqual(100);
- });
- });
- /***/ }),
- /* 147 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Search plugin', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('enabling/disabling plugin', function () {
- it('should expose `search` object when plugin is enabled', function () {
- var hot = handsontable({
- search: true
- });
- expect(hot.search).toBeDefined();
- });
- it('should NOT expose `search` object when plugin is disabled', function () {
- var hot = handsontable({
- search: false
- });
- expect(hot.search).not.toBeDefined();
- });
- it('plugin should be disabled by default', function () {
- var hot = handsontable();
- expect(hot.search).not.toBeDefined();
- });
- it('should disable plugin using updateSettings', function () {
- var hot = handsontable({
- search: true
- });
- expect(hot.search).toBeDefined();
- updateSettings({
- search: false
- });
- expect(hot.search).not.toBeDefined();
- });
- it('should enable plugin using updateSettings', function () {
- var hot = handsontable({
- search: false
- });
- expect(hot.search).not.toBeDefined();
- updateSettings({
- search: true
- });
- expect(hot.search).toBeDefined();
- });
- });
- describe('query method', function () {
- afterEach(function () {
- Handsontable.plugins.Search.global.setDefaultQueryMethod(Handsontable.plugins.Search.DEFAULT_QUERY_METHOD);
- });
- it('should use the default query method if no queryMethod is passed to query function', function () {
- spyOn(Handsontable.plugins.Search, 'DEFAULT_QUERY_METHOD');
- var defaultQueryMethod = Handsontable.plugins.Search.DEFAULT_QUERY_METHOD;
- Handsontable.plugins.Search.global.setDefaultQueryMethod(defaultQueryMethod);
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- var searchResult = hot.search.query('A');
- expect(defaultQueryMethod.calls.count()).toEqual(25);
- });
- it('should use the custom default query method if no queryMethod is passed to query function', function () {
- var customDefaultQueryMethod = jasmine.createSpy('customDefaultQueryMethod');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- Handsontable.plugins.Search.global.setDefaultQueryMethod(customDefaultQueryMethod);
- var searchResult = hot.search.query('A');
- expect(customDefaultQueryMethod.calls.count()).toEqual(25);
- });
- it('should use the query method from the constructor if no queryMethod is passed to query function', function () {
- var customQueryMethod = jasmine.createSpy('customDefaultQueryMethod');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: {
- queryMethod: customQueryMethod
- }
- });
- var searchResult = hot.search.query('A');
- expect(customQueryMethod.calls.count()).toEqual(25);
- });
- it('should use method passed to query function', function () {
- var customQueryMethod = jasmine.createSpy('customQueryMethod');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- var searchResult = hot.search.query('A', null, customQueryMethod);
- expect(customQueryMethod.calls.count()).toEqual(25);
- });
- });
- describe('default query method', function () {
- it('should use query method to find phrase', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- var searchResult = hot.search.query('A');
- expect(searchResult.length).toEqual(5);
- for (var i = 0; i < searchResult.length; i++) {
- expect(searchResult[i].row).toEqual(i);
- expect(searchResult[i].col).toEqual(0);
- expect(searchResult[i].data).toEqual(hot.getDataAtCell(i, 0));
- }
- });
- it('default query method should be case insensitive', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- var searchResult = hot.search.query('a');
- expect(searchResult.length).toEqual(5);
- searchResult = hot.search.query('A');
- expect(searchResult.length).toEqual(5);
- });
- it('default query method should work with numeric values', function () {
- var hot = handsontable({
- data: [[1, 2], [22, 4]],
- search: true
- });
- var searchResult = hot.search.query('2');
- expect(searchResult.length).toEqual(2);
- });
- it('default query method should interpret query as string, not regex', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- var searchResult = hot.search.query('A*');
- expect(searchResult.length).toEqual(0);
- });
- it('default query method should always return false if query string is empty', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- var searchResult = hot.search.query('A');
- expect(searchResult.length).toEqual(5);
- searchResult = hot.search.query('');
- expect(searchResult.length).toEqual(0);
- });
- it('default query method should always return false if no query string has been specified', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- var searchResult = hot.search.query('A');
- expect(searchResult.length).toEqual(5);
- searchResult = hot.search.query();
- expect(searchResult.length).toEqual(0);
- });
- it('default query method should always return false if no query string is not a string', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- var searchResult = hot.search.query('A');
- expect(searchResult.length).toEqual(5);
- searchResult = hot.search.query([1, 2, 3]);
- expect(searchResult.length).toEqual(0);
- });
- });
- describe('search callback', function () {
- afterEach(function () {
- Handsontable.plugins.Search.global.setDefaultCallback(Handsontable.plugins.Search.DEFAULT_CALLBACK);
- });
- it('should invoke default callback for each cell', function () {
- spyOn(Handsontable.plugins.Search, 'DEFAULT_CALLBACK');
- var defaultCallback = Handsontable.plugins.Search.DEFAULT_CALLBACK;
- Handsontable.plugins.Search.global.setDefaultCallback(defaultCallback);
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- var searchResult = hot.search.query('A');
- expect(defaultCallback.calls.count()).toEqual(25);
- });
- it('should change the default callback', function () {
- spyOn(Handsontable.plugins.Search, 'DEFAULT_CALLBACK');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- var defaultCallback = jasmine.createSpy('defaultCallback');
- Handsontable.plugins.Search.global.setDefaultCallback(defaultCallback);
- var searchResult = hot.search.query('A');
- expect(Handsontable.plugins.Search.DEFAULT_CALLBACK).not.toHaveBeenCalled();
- expect(defaultCallback.calls.count()).toEqual(25);
- });
- it('should invoke callback passed in constructor', function () {
- var searchCallback = jasmine.createSpy('searchCallback');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: {
- callback: searchCallback
- }
- });
- var searchResult = hot.search.query('A');
- expect(searchCallback.calls.count()).toEqual(25);
- });
- it('should invoke custom callback for each cell which has been tested', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- var searchCallback = jasmine.createSpy('searchCallback');
- var searchResult = hot.search.query('A', searchCallback);
- expect(searchCallback.calls.count()).toEqual(25);
- for (var rowIndex = 0, rowCount = countRows(); rowIndex < rowCount; rowIndex++) {
- for (var colIndex = 0, colCount = countCols(); colIndex < colCount; colIndex++) {
- var callArgs = searchCallback.calls.argsFor(rowIndex * 5 + colIndex);
- expect(callArgs[0]).toEqual(hot);
- expect(callArgs[1]).toEqual(rowIndex);
- expect(callArgs[2]).toEqual(colIndex);
- expect(callArgs[3]).toEqual(hot.getDataAtCell(rowIndex, colIndex));
- if (colIndex == 0) {
- expect(callArgs[4]).toBe(true);
- } else {
- expect(callArgs[4]).toBe(false);
- }
- }
- }
- });
- });
- describe('default search callback', function () {
- it('should add isSearchResult = true, to cell properties of all matched cells', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- var searchResult = hot.search.query('2');
- for (var rowIndex = 0, rowCount = countRows(); rowIndex < rowCount; rowIndex++) {
- for (var colIndex = 0, colCount = countCols(); colIndex < colCount; colIndex++) {
- var cellProperties = getCellMeta(rowIndex, colIndex);
- if (rowIndex == 1) {
- expect(cellProperties.isSearchResult).toBeTruthy();
- } else {
- expect(cellProperties.isSearchResult).toBeFalsy();
- }
- }
- }
- });
- });
- describe('search result decorator', function () {
- it('should add default search result class to cells which mach the query', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: true
- });
- var searchResult = hot.search.query('2');
- render();
- for (var rowIndex = 0, rowCount = countRows(); rowIndex < rowCount; rowIndex++) {
- for (var colIndex = 0, colCount = countCols(); colIndex < colCount; colIndex++) {
- var cell = getCell(rowIndex, colIndex);
- if (rowIndex == 1) {
- expect($(cell).hasClass(Handsontable.plugins.Search.DEFAULT_SEARCH_RESULT_CLASS)).toBe(true);
- } else {
- expect($(cell).hasClass(Handsontable.plugins.Search.DEFAULT_SEARCH_RESULT_CLASS)).toBe(false);
- }
- }
- }
- });
- it('should add custom search result class to cells which mach the query', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- search: {
- searchResultClass: 'customSearchResultClass'
- }
- });
- var searchResult = hot.search.query('2');
- render();
- for (var rowIndex = 0, rowCount = countRows(); rowIndex < rowCount; rowIndex++) {
- for (var colIndex = 0, colCount = countCols(); colIndex < colCount; colIndex++) {
- var cell = getCell(rowIndex, colIndex);
- if (rowIndex == 1) {
- expect($(cell).hasClass('customSearchResultClass')).toBe(true);
- } else {
- expect($(cell).hasClass('customSearchResultClass')).toBe(false);
- }
- }
- }
- });
- });
- describe('HOT properties compatibility', function () {
- it('should work properly when the last row is empty', function () {
- // connected with https://github.com/handsontable/handsontable/issues/1606
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- colHeaders: true,
- search: true,
- minSpareRows: 1
- }),
- errorThrown = false;
- try {
- hot.search.query('A');
- } catch (err) {
- errorThrown = true;
- }
- expect(errorThrown).toBe(false);
- });
- });
- });
- /***/ }),
- /* 148 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- describe('UndoRedo', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('core features', function () {
- describe('Array data', function () {
- describe('undo', function () {
- it('should undo single change', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var HOT = getInstance();
- setDataAtCell(0, 0, 'X1');
- expect(getDataAtCell(0, 0)).toBe('X1');
- HOT.undo();
- expect(getDataAtCell(0, 0)).toBe('A1');
- });
- it('should undo single change on cell with validator', function (done) {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var HOT = getInstance();
- setDataAtCell(0, 0, 'X1');
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('X1');
- HOT.undo();
- }, 200);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('A1');
- done();
- }, 400);
- });
- it('should undo creation of a single row', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- expect(countRows()).toEqual(2);
- alter('insert_row');
- expect(countRows()).toEqual(3);
- HOT.undo();
- expect(countRows()).toEqual(2);
- });
- it('should undo creation of multiple rows', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- expect(countRows()).toEqual(2);
- alter('insert_row', 0, 5);
- expect(countRows()).toEqual(7);
- HOT.undo();
- expect(countRows()).toEqual(2);
- });
- it('should undo creation of multiple rows with minSpareRows', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 1),
- minSpareRows: 2
- });
- expect(getData()).toEqual([['A1'], ['A2'], [null], [null]]);
- setDataAtCell(2, 0, 'A3');
- setDataAtCell(4, 0, 'A4');
- expect(getData()).toEqual([['A1'], ['A2'], ['A3'], [null], ['A4'], [null], [null]]);
- HOT.undo();
- HOT.undo();
- expect(getData()).toEqual([['A1'], ['A2'], [null], [null]]);
- });
- it('should undo removal of single row', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 2)
- });
- expect(countRows()).toEqual(3);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- alter('remove_row', 1);
- expect(countRows()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A3');
- expect(getDataAtCell(1, 1)).toEqual('B3');
- HOT.undo();
- expect(countRows()).toEqual(3);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- });
- it('should undo removal of multiple rows', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 2)
- });
- expect(countRows()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- expect(getDataAtCell(3, 0)).toEqual('A4');
- expect(getDataAtCell(3, 1)).toEqual('B4');
- alter('remove_row', 1, 2);
- expect(countRows()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A4');
- expect(getDataAtCell(1, 1)).toEqual('B4');
- HOT.undo();
- expect(countRows()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- expect(getDataAtCell(3, 0)).toEqual('A4');
- expect(getDataAtCell(3, 1)).toEqual('B4');
- });
- it('should undo creation of a single column (colHeaders: undefined)', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 3)
- });
- expect(countCols()).toEqual(3);
- alter('insert_col');
- expect(countCols()).toEqual(4);
- HOT.undo();
- expect(countCols()).toEqual(3);
- });
- it('should undo creation of a single column (colHeaders: true)', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 3),
- colHeaders: true
- });
- expect(countCols()).toEqual(3);
- expect(getColHeader()).toEqual(['A', 'B', 'C']);
- alter('insert_col');
- expect(countCols()).toEqual(4);
- expect(getColHeader()).toEqual(['A', 'B', 'C', 'D']);
- HOT.undo();
- expect(countCols()).toEqual(3);
- expect(getColHeader()).toEqual(['A', 'B', 'C']);
- });
- it('should undo creation of a single column (colHeaders: Array)', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 3),
- colHeaders: ['Header1', 'Header2', 'Header3']
- });
- expect(countCols()).toEqual(3);
- expect(getColHeader()).toEqual(['Header1', 'Header2', 'Header3']);
- alter('insert_col', 1);
- expect(countCols()).toEqual(4);
- expect(getColHeader()).toEqual(['Header1', 'B', 'Header2', 'Header3']);
- HOT.undo();
- expect(countCols()).toEqual(3);
- expect(getColHeader()).toEqual(['Header1', 'Header2', 'Header3']);
- });
- it('should undo creation of multiple columns (colHeaders: undefined)', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- expect(countCols()).toEqual(2);
- alter('insert_col', 1, 5);
- expect(countCols()).toEqual(7);
- HOT.undo();
- expect(countCols()).toEqual(2);
- });
- it('should undo creation of multiple columns (colHeaders: true)', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- colHeaders: true
- });
- expect(countCols()).toEqual(2);
- expect(getColHeader()).toEqual(['A', 'B']);
- alter('insert_col', 1, 5);
- expect(countCols()).toEqual(7);
- expect(getColHeader()).toEqual(['A', 'B', 'C', 'D', 'E', 'F', 'G']);
- HOT.undo();
- expect(countCols()).toEqual(2);
- expect(getColHeader()).toEqual(['A', 'B']);
- });
- it('should undo creation of multiple columns (colHeaders: Array)', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- colHeaders: ['Header1', 'Header2']
- });
- expect(countCols()).toEqual(2);
- expect(getColHeader()).toEqual(['Header1', 'Header2']);
- alter('insert_col', 1, 5);
- expect(countCols()).toEqual(7);
- expect(getColHeader()).toEqual(['Header1', 'B', 'C', 'D', 'E', 'F', 'Header2']);
- HOT.undo();
- expect(countCols()).toEqual(2);
- expect(getColHeader()).toEqual(['Header1', 'Header2']);
- });
- it('should undo creation of multiple columns with minSpareCols', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 1),
- minSpareCols: 2
- });
- expect(getData()).toEqual([['A1', null, null]]);
- setDataAtCell(0, 1, 'B1');
- setDataAtCell(0, 3, 'C1');
- expect(getData()).toEqual([['A1', 'B1', null, 'C1', null, null]]);
- HOT.undo();
- HOT.undo();
- expect(getData()).toEqual([['A1', null, null]]);
- });
- it('should undo removal of single column (colHeaders: undefined)', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 3)
- });
- expect(countCols()).toEqual(3);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(0, 2)).toEqual('C1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(1, 2)).toEqual('C2');
- alter('remove_col', 1);
- expect(countCols()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('C1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('C2');
- HOT.undo();
- expect(countCols()).toEqual(3);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(0, 2)).toEqual('C1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(1, 2)).toEqual('C2');
- });
- it('should undo removal of single column (colHeaders: true)', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- colHeaders: true
- });
- expect(countCols()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getColHeader()).toEqual(['A', 'B']);
- alter('remove_col');
- expect(countCols()).toEqual(1);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toBeNull();
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toBeNull();
- expect(getColHeader()).toEqual(['A']);
- HOT.undo();
- expect(countCols()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getColHeader()).toEqual(['A', 'B']);
- });
- it('should undo removal of single column (colHeaders: Array)', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- colHeaders: ['Header1', 'Header2']
- });
- expect(countCols()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getColHeader()).toEqual(['Header1', 'Header2']);
- alter('remove_col');
- expect(countCols()).toEqual(1);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toBeNull();
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toBeNull();
- expect(getColHeader()).toEqual(['Header1']);
- HOT.undo();
- expect(countCols()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getColHeader()).toEqual(['Header1', 'Header2']);
- });
- it('should undo removal of multiple columns (colHeaders: undefined)', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 4)
- });
- expect(countCols()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(0, 2)).toEqual('C1');
- expect(getDataAtCell(0, 3)).toEqual('D1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(1, 2)).toEqual('C2');
- expect(getDataAtCell(1, 3)).toEqual('D2');
- alter('remove_col', 1, 2);
- expect(countCols()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('D1');
- expect(getDataAtCell(0, 2)).toBeNull();
- expect(getDataAtCell(0, 3)).toBeNull();
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('D2');
- expect(getDataAtCell(1, 2)).toBeNull();
- expect(getDataAtCell(1, 3)).toBeNull();
- HOT.undo();
- expect(countCols()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(0, 2)).toEqual('C1');
- expect(getDataAtCell(0, 3)).toEqual('D1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(1, 2)).toEqual('C2');
- expect(getDataAtCell(1, 3)).toEqual('D2');
- });
- it('should undo removal of multiple columns (colHeaders: true)', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 4),
- colHeaders: true
- });
- expect(countCols()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(0, 2)).toEqual('C1');
- expect(getDataAtCell(0, 3)).toEqual('D1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(1, 2)).toEqual('C2');
- expect(getDataAtCell(1, 3)).toEqual('D2');
- expect(getColHeader()).toEqual(['A', 'B', 'C', 'D']);
- alter('remove_col', 1, 3);
- expect(countCols()).toEqual(1);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toBeNull();
- expect(getDataAtCell(0, 2)).toBeNull();
- expect(getDataAtCell(0, 3)).toBeNull();
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toBeNull();
- expect(getDataAtCell(1, 2)).toBeNull();
- expect(getDataAtCell(1, 3)).toBeNull();
- expect(getColHeader()).toEqual(['A']);
- HOT.undo();
- expect(countCols()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(0, 2)).toEqual('C1');
- expect(getDataAtCell(0, 3)).toEqual('D1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(1, 2)).toEqual('C2');
- expect(getDataAtCell(1, 3)).toEqual('D2');
- expect(getColHeader()).toEqual(['A', 'B', 'C', 'D']);
- });
- it('should undo removal of multiple columns (colHeaders: Array)', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 4),
- colHeaders: ['Header1', 'Header2', 'Header3', 'Header4']
- });
- expect(countCols()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(0, 2)).toEqual('C1');
- expect(getDataAtCell(0, 3)).toEqual('D1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(1, 2)).toEqual('C2');
- expect(getDataAtCell(1, 3)).toEqual('D2');
- expect(getColHeader()).toEqual(['Header1', 'Header2', 'Header3', 'Header4']);
- alter('remove_col', 1, 2);
- expect(countCols()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('D1');
- expect(getDataAtCell(0, 2)).toBeNull();
- expect(getDataAtCell(0, 3)).toBeNull();
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('D2');
- expect(getDataAtCell(1, 2)).toBeNull();
- expect(getDataAtCell(1, 3)).toBeNull();
- expect(getColHeader()).toEqual(['Header1', 'Header4']);
- HOT.undo();
- expect(countCols()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(0, 2)).toEqual('C1');
- expect(getDataAtCell(0, 3)).toEqual('D1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(1, 2)).toEqual('C2');
- expect(getDataAtCell(1, 3)).toEqual('D2');
- expect(getColHeader()).toEqual(['Header1', 'Header2', 'Header3', 'Header4']);
- });
- it('should undo removal of multiple columns (with a used manualColumnMove)', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 7),
- manualColumnMove: [3, 2, 0, 6, 1, 5, 4]
- });
- expect(countCols()).toEqual(7);
- expect(getDataAtRow(0)).toEqual(['D1', 'C1', 'A1', 'G1', 'B1', 'F1', 'E1']);
- alter('remove_col', 1, 3);
- expect(countCols()).toEqual(4);
- expect(getDataAtRow(0)).toEqual(['D1', 'B1', 'F1', 'E1']);
- // HOT.undo();
- //
- // expect(countCols()).toEqual(7);
- // expect(getDataAtRow(0)).toEqual(['D1', 'C1', 'A1', 'G1', 'B1', 'F1', 'E1']);
- });
- it('should undo multiple changes', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var HOT = getInstance();
- setDataAtCell(0, 0, 'X1');
- setDataAtCell(1, 0, 'X2');
- setDataAtCell(0, 1, 'Y1');
- setDataAtCell(1, 1, 'Y2');
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('Y1');
- expect(getDataAtCell(1, 1)).toBe('Y2');
- HOT.undo();
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('Y1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.undo();
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.undo();
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('A2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.undo();
- expect(getDataAtCell(0, 0)).toBe('A1');
- expect(getDataAtCell(1, 0)).toBe('A2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.undo();
- expect(getDataAtCell(0, 0)).toBe('A1');
- expect(getDataAtCell(1, 0)).toBe('A2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- });
- it('should undo multiple changes in cells with validators', function (done) {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var HOT = getInstance();
- setDataAtCell(0, 0, 'X1');
- setDataAtCell(1, 0, 'X2');
- setDataAtCell(0, 1, 'Y1');
- setDataAtCell(1, 1, 'Y2');
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('Y1');
- expect(getDataAtCell(1, 1)).toBe('Y2');
- HOT.undo();
- }, 200);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('Y1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.undo();
- }, 400);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.undo();
- }, 600);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('A2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.undo();
- }, 800);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('A1');
- expect(getDataAtCell(1, 0)).toBe('A2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.undo();
- }, 1000);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('A1');
- expect(getDataAtCell(1, 0)).toBe('A2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- done();
- }, 1200);
- });
- it('should undo multiple row creations', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- expect(countRows()).toEqual(2);
- alter('insert_row');
- alter('insert_row');
- alter('insert_row');
- alter('insert_row');
- expect(countRows()).toEqual(6);
- HOT.undo();
- expect(countRows()).toEqual(5);
- HOT.undo();
- expect(countRows()).toEqual(4);
- HOT.undo();
- expect(countRows()).toEqual(3);
- HOT.undo();
- expect(countRows()).toEqual(2);
- HOT.undo();
- expect(countRows()).toEqual(2);
- });
- it('should undo multiple row removals', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 2)
- });
- expect(countRows()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- expect(getDataAtCell(3, 0)).toEqual('A4');
- expect(getDataAtCell(3, 1)).toEqual('B4');
- alter('remove_row');
- alter('remove_row');
- alter('remove_row');
- expect(countRows()).toEqual(1);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- HOT.undo();
- expect(countRows()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- HOT.undo();
- expect(countRows()).toEqual(3);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- HOT.undo();
- expect(countRows()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- expect(getDataAtCell(3, 0)).toEqual('A4');
- expect(getDataAtCell(3, 1)).toEqual('B4');
- HOT.undo();
- expect(countRows()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- expect(getDataAtCell(3, 0)).toEqual('A4');
- expect(getDataAtCell(3, 1)).toEqual('B4');
- });
- it('should undo changes only for table where the change actually took place', function () {
- this.$container2 = $('<div id="' + id + '-2"></div>').appendTo('body');
- var hot1 = handsontable({
- data: [[1], [2], [3]]
- });
- this.$container2.handsontable({
- data: [['A'], ['B'], ['C']]
- });
- var hot2 = this.$container2.handsontable('getInstance');
- hot1.setDataAtCell(0, 0, 4);
- expect(hot1.getDataAtCell(0, 0)).toEqual(4);
- expect(hot2.getDataAtCell(0, 0)).toEqual('A');
- hot2.undo();
- expect(hot2.getDataAtCell(0, 0)).toEqual('A');
- expect(hot1.getDataAtCell(0, 0)).toEqual(4);
- hot1.undo();
- expect(hot2.getDataAtCell(0, 0)).toEqual('A');
- expect(hot1.getDataAtCell(0, 0)).toEqual(1);
- hot2.destroy();
- this.$container2.remove();
- });
- });
- describe('redo', function () {
- it('should redo single change', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var HOT = getInstance();
- setDataAtCell(0, 0, 'new value');
- expect(getDataAtCell(0, 0)).toBe('new value');
- HOT.undo();
- expect(getDataAtCell(0, 0)).toBe('A1');
- HOT.redo();
- expect(getDataAtCell(0, 0)).toBe('new value');
- });
- it('should redo single change in cell with validator', function (done) {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var HOT = getInstance();
- setDataAtCell(0, 0, 'new value');
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('new value');
- HOT.undo();
- }, 200);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('A1');
- HOT.redo();
- }, 400);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('new value');
- done();
- }, 600);
- });
- it('should redo creation of a single row', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- expect(countRows()).toEqual(2);
- alter('insert_row');
- expect(countRows()).toEqual(3);
- HOT.undo();
- expect(countRows()).toEqual(2);
- HOT.redo();
- expect(countRows()).toEqual(3);
- });
- it('should redo creation of multiple rows', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- expect(countRows()).toEqual(2);
- alter('insert_row', 0, 5);
- expect(countRows()).toEqual(7);
- HOT.undo();
- expect(countRows()).toEqual(2);
- HOT.redo();
- expect(countRows()).toEqual(7);
- });
- it('should redo removal of single row', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 2)
- });
- expect(countRows()).toEqual(3);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- alter('remove_row', 1);
- expect(countRows()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A3');
- expect(getDataAtCell(1, 1)).toEqual('B3');
- HOT.undo();
- expect(countRows()).toEqual(3);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- HOT.redo();
- expect(countRows()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A3');
- expect(getDataAtCell(1, 1)).toEqual('B3');
- });
- it('should redo removal of multiple rows', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 2)
- });
- expect(countRows()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- expect(getDataAtCell(3, 0)).toEqual('A4');
- expect(getDataAtCell(3, 1)).toEqual('B4');
- alter('remove_row', 1, 2);
- expect(countRows()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A4');
- expect(getDataAtCell(1, 1)).toEqual('B4');
- HOT.undo();
- expect(countRows()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- expect(getDataAtCell(3, 0)).toEqual('A4');
- expect(getDataAtCell(3, 1)).toEqual('B4');
- HOT.redo();
- expect(countRows()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A4');
- expect(getDataAtCell(1, 1)).toEqual('B4');
- });
- it('should redo creation of a single column', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- expect(countCols()).toEqual(2);
- alter('insert_col');
- expect(countCols()).toEqual(3);
- HOT.undo();
- expect(countCols()).toEqual(2);
- HOT.redo();
- expect(countCols()).toEqual(3);
- });
- it('should redo creation of multiple columns', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- expect(countCols()).toEqual(2);
- alter('insert_col', 1, 5);
- expect(countCols()).toEqual(7);
- HOT.undo();
- expect(countCols()).toEqual(2);
- HOT.redo();
- expect(countCols()).toEqual(7);
- });
- it('should redo removal of single column', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- expect(countCols()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- alter('remove_col');
- expect(countCols()).toEqual(1);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toBeNull();
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toBeNull();
- HOT.undo();
- expect(countCols()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- HOT.redo();
- expect(countCols()).toEqual(1);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toBeNull();
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toBeNull();
- });
- it('should redo removal of multiple columns', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 4)
- });
- expect(countCols()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(0, 2)).toEqual('C1');
- expect(getDataAtCell(0, 3)).toEqual('D1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(1, 2)).toEqual('C2');
- expect(getDataAtCell(1, 3)).toEqual('D2');
- alter('remove_col', 1, 3);
- expect(countCols()).toEqual(1);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toBeNull();
- expect(getDataAtCell(0, 2)).toBeNull();
- expect(getDataAtCell(0, 3)).toBeNull();
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toBeNull();
- expect(getDataAtCell(1, 2)).toBeNull();
- expect(getDataAtCell(1, 3)).toBeNull();
- HOT.undo();
- expect(countCols()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(0, 2)).toEqual('C1');
- expect(getDataAtCell(0, 3)).toEqual('D1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(1, 2)).toEqual('C2');
- expect(getDataAtCell(1, 3)).toEqual('D2');
- HOT.redo();
- expect(countCols()).toEqual(1);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toBeNull();
- expect(getDataAtCell(0, 2)).toBeNull();
- expect(getDataAtCell(0, 3)).toBeNull();
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toBeNull();
- expect(getDataAtCell(1, 2)).toBeNull();
- expect(getDataAtCell(1, 3)).toBeNull();
- });
- it('should redo multiple changes', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var HOT = getInstance();
- setDataAtCell(0, 0, 'X1');
- setDataAtCell(1, 0, 'X2');
- setDataAtCell(0, 1, 'Y1');
- setDataAtCell(1, 1, 'Y2');
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('Y1');
- expect(getDataAtCell(1, 1)).toBe('Y2');
- HOT.undo();
- HOT.undo();
- HOT.undo();
- HOT.undo();
- expect(getDataAtCell(0, 0)).toBe('A1');
- expect(getDataAtCell(1, 0)).toBe('A2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.redo();
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('A2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.redo();
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.redo();
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('Y1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.redo();
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('Y1');
- expect(getDataAtCell(1, 1)).toBe('Y2');
- HOT.redo();
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('Y1');
- expect(getDataAtCell(1, 1)).toBe('Y2');
- });
- it('should redo multiple changes in cell with validator', function (done) {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- setDataAtCell(0, 0, 'X1');
- setDataAtCell(1, 0, 'X2');
- setDataAtCell(0, 1, 'Y1');
- setDataAtCell(1, 1, 'Y2');
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('Y1');
- expect(getDataAtCell(1, 1)).toBe('Y2');
- HOT.undo();
- }, 200);
- setTimeout(function () {
- HOT.undo();
- }, 400);
- setTimeout(function () {
- HOT.undo();
- }, 600);
- setTimeout(function () {
- HOT.undo();
- }, 800);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('A1');
- expect(getDataAtCell(1, 0)).toBe('A2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.redo();
- }, 1000);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('A2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.redo();
- }, 1200);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('B1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.redo();
- }, 1400);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('Y1');
- expect(getDataAtCell(1, 1)).toBe('B2');
- HOT.redo();
- }, 1600);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('Y1');
- expect(getDataAtCell(1, 1)).toBe('Y2');
- HOT.redo();
- }, 1800);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('X1');
- expect(getDataAtCell(1, 0)).toBe('X2');
- expect(getDataAtCell(0, 1)).toBe('Y1');
- expect(getDataAtCell(1, 1)).toBe('Y2');
- done();
- }, 2000);
- });
- it('should redo multiple row creations', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- expect(countRows()).toEqual(2);
- alter('insert_row');
- alter('insert_row');
- alter('insert_row');
- alter('insert_row');
- expect(countRows()).toEqual(6);
- HOT.undo();
- HOT.undo();
- HOT.undo();
- HOT.undo();
- expect(countRows()).toEqual(2);
- HOT.redo();
- expect(countRows()).toEqual(3);
- HOT.redo();
- expect(countRows()).toEqual(4);
- HOT.redo();
- expect(countRows()).toEqual(5);
- HOT.redo();
- expect(countRows()).toEqual(6);
- HOT.redo();
- expect(countRows()).toEqual(6);
- });
- it('should undo multiple row removals', function () {
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 2)
- });
- expect(countRows()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- expect(getDataAtCell(3, 0)).toEqual('A4');
- expect(getDataAtCell(3, 1)).toEqual('B4');
- alter('remove_row');
- alter('remove_row');
- alter('remove_row');
- expect(countRows()).toEqual(1);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- HOT.undo();
- HOT.undo();
- HOT.undo();
- expect(countRows()).toEqual(4);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- expect(getDataAtCell(3, 0)).toEqual('A4');
- expect(getDataAtCell(3, 1)).toEqual('B4');
- HOT.redo();
- expect(countRows()).toEqual(3);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 0)).toEqual('A3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- HOT.redo();
- expect(countRows()).toEqual(2);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- HOT.redo();
- expect(countRows()).toEqual(1);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- HOT.redo();
- expect(countRows()).toEqual(1);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- expect(getDataAtCell(0, 1)).toEqual('B1');
- });
- it('should redo changes only for table where the change actually took place', function () {
- this.$container2 = $('<div id="' + id + '-2"></div>').appendTo('body');
- var hot1 = handsontable({
- data: [[1], [2], [3]]
- });
- this.$container2.handsontable({
- data: [['A'], ['B'], ['C']]
- });
- var hot2 = this.$container2.handsontable('getInstance');
- hot1.setDataAtCell(0, 0, 4);
- expect(hot1.getDataAtCell(0, 0)).toEqual(4);
- expect(hot2.getDataAtCell(0, 0)).toEqual('A');
- hot1.undo();
- expect(hot1.getDataAtCell(0, 0)).toEqual(1);
- expect(hot2.getDataAtCell(0, 0)).toEqual('A');
- hot2.redo();
- expect(hot1.getDataAtCell(0, 0)).toEqual(1);
- expect(hot2.getDataAtCell(0, 0)).toEqual('A');
- hot1.redo();
- expect(hot1.getDataAtCell(0, 0)).toEqual(4);
- expect(hot2.getDataAtCell(0, 0)).toEqual('A');
- hot2.destroy();
- this.$container2.remove();
- });
- });
- });
- describe('Object data', function () {
- function createObjectData() {
- return [{ name: 'Timothy', surname: 'Dalton' }, { name: 'Sean', surname: 'Connery' }, { name: 'Roger', surname: 'Moore' }];
- }
- describe('undo', function () {
- it('should undo single change', function () {
- handsontable({
- data: createObjectData()
- });
- var HOT = getInstance();
- setDataAtRowProp(0, 0, 'Pearce');
- expect(getDataAtRowProp(0, 0)).toBe('Pearce');
- HOT.undo();
- expect(getDataAtCell(0, 0)).toBe('Timothy');
- });
- it('should undo single change in cell with validator', function (done) {
- handsontable({
- data: createObjectData()
- });
- var HOT = getInstance();
- setDataAtRowProp(0, 0, 'Pearce');
- setTimeout(function () {
- expect(getDataAtRowProp(0, 0)).toBe('Pearce');
- HOT.undo();
- }, 200);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('Timothy');
- done();
- }, 400);
- });
- it('should undo creation of a single row', function () {
- var HOT = handsontable({
- data: createObjectData().slice(0, 2)
- });
- expect(countRows()).toEqual(2);
- alter('insert_row');
- expect(countRows()).toEqual(3);
- HOT.undo();
- expect(countRows()).toEqual(2);
- });
- it('should undo creation of multiple rows', function () {
- var HOT = handsontable({
- data: createObjectData().slice(0, 2)
- });
- expect(countRows()).toEqual(2);
- alter('insert_row', 0, 5);
- expect(countRows()).toEqual(7);
- HOT.undo();
- expect(countRows()).toEqual(2);
- });
- it('should undo removal of single row', function () {
- var HOT = handsontable({
- data: createObjectData().slice(0, 2)
- });
- expect(countRows()).toEqual(2);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- alter('remove_row');
- expect(countRows()).toEqual(1);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBeNull();
- expect(getDataAtRowProp(1, 'surname')).toBeNull();
- HOT.undo();
- expect(countRows()).toEqual(2);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- });
- it('should undo removal of multiple rows', function () {
- var HOT = handsontable({
- data: createObjectData()
- });
- expect(countRows()).toEqual(3);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- expect(getDataAtRowProp(2, 'name')).toEqual('Roger');
- expect(getDataAtRowProp(2, 'surname')).toEqual('Moore');
- alter('remove_row', 1, 2);
- expect(countRows()).toEqual(1);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBeNull();
- expect(getDataAtRowProp(1, 'surname')).toBeNull();
- expect(getDataAtRowProp(2, 'name')).toBeNull();
- expect(getDataAtRowProp(2, 'surname')).toBeNull();
- HOT.undo();
- expect(countRows()).toEqual(3);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- expect(getDataAtRowProp(2, 'name')).toEqual('Roger');
- expect(getDataAtRowProp(2, 'surname')).toEqual('Moore');
- });
- it('should undo multiple changes', function () {
- handsontable({
- data: createObjectData().slice(0, 2)
- });
- var HOT = getInstance();
- setDataAtRowProp(0, 'name', 'Pierce');
- setDataAtRowProp(0, 'surname', 'Brosnan');
- setDataAtRowProp(1, 'name', 'Daniel');
- setDataAtRowProp(1, 'surname', 'Craig');
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Daniel');
- expect(getDataAtRowProp(1, 'surname')).toBe('Craig');
- HOT.undo();
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Daniel');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.undo();
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.undo();
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.undo();
- expect(getDataAtRowProp(0, 'name')).toBe('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toBe('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.undo();
- expect(getDataAtRowProp(0, 'name')).toBe('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toBe('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- });
- it('should undo multiple changes in cells with validators', function (done) {
- handsontable({
- data: createObjectData().slice(0, 2)
- });
- var HOT = getInstance();
- setDataAtRowProp(0, 'name', 'Pierce');
- setDataAtRowProp(0, 'surname', 'Brosnan');
- setDataAtRowProp(1, 'name', 'Daniel');
- setDataAtRowProp(1, 'surname', 'Craig');
- setTimeout(function () {
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Daniel');
- expect(getDataAtRowProp(1, 'surname')).toBe('Craig');
- HOT.undo();
- }, 200);
- setTimeout(function () {
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Daniel');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.undo();
- }, 400);
- setTimeout(function () {
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.undo();
- }, 600);
- setTimeout(function () {
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.undo();
- }, 800);
- setTimeout(function () {
- expect(getDataAtRowProp(0, 'name')).toBe('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toBe('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.undo();
- }, 1000);
- setTimeout(function () {
- expect(getDataAtRowProp(0, 'name')).toBe('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toBe('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- done();
- }, 1200);
- });
- it('should undo multiple row creations', function () {
- var HOT = handsontable({
- data: createObjectData().slice(0, 2)
- });
- expect(countRows()).toEqual(2);
- alter('insert_row');
- alter('insert_row');
- alter('insert_row');
- alter('insert_row');
- expect(countRows()).toEqual(6);
- HOT.undo();
- expect(countRows()).toEqual(5);
- HOT.undo();
- expect(countRows()).toEqual(4);
- HOT.undo();
- expect(countRows()).toEqual(3);
- HOT.undo();
- expect(countRows()).toEqual(2);
- HOT.undo();
- expect(countRows()).toEqual(2);
- });
- it('should undo multiple row removals', function () {
- var HOT = handsontable({
- data: createObjectData()
- });
- expect(countRows()).toEqual(3);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- expect(getDataAtRowProp(2, 'name')).toEqual('Roger');
- expect(getDataAtRowProp(2, 'surname')).toEqual('Moore');
- alter('remove_row');
- alter('remove_row');
- expect(countRows()).toEqual(1);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- HOT.undo();
- expect(countRows()).toEqual(2);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- HOT.undo();
- expect(countRows()).toEqual(3);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- expect(getDataAtRowProp(2, 'name')).toEqual('Roger');
- expect(getDataAtRowProp(2, 'surname')).toEqual('Moore');
- HOT.undo();
- expect(countRows()).toEqual(3);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- expect(getDataAtRowProp(2, 'name')).toEqual('Roger');
- expect(getDataAtRowProp(2, 'surname')).toEqual('Moore');
- });
- });
- describe('redo', function () {
- it('should redo single change', function () {
- handsontable({
- data: createObjectData()
- });
- var HOT = getInstance();
- setDataAtRowProp(0, 0, 'Pearce');
- expect(getDataAtRowProp(0, 0)).toBe('Pearce');
- HOT.undo();
- expect(getDataAtCell(0, 0)).toBe('Timothy');
- HOT.redo();
- expect(getDataAtRowProp(0, 0)).toBe('Pearce');
- });
- it('should redo single change in cell with validator', function (done) {
- handsontable({
- data: createObjectData()
- });
- var HOT = getInstance();
- setDataAtRowProp(0, 0, 'Pearce');
- setTimeout(function () {
- expect(getDataAtRowProp(0, 0)).toBe('Pearce');
- HOT.undo();
- }, 200);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toBe('Timothy');
- HOT.redo();
- }, 400);
- setTimeout(function () {
- expect(getDataAtRowProp(0, 0)).toBe('Pearce');
- done();
- }, 600);
- });
- it('should redo creation of a single row', function () {
- var HOT = handsontable({
- data: createObjectData().slice(0, 2)
- });
- expect(countRows()).toEqual(2);
- alter('insert_row');
- expect(countRows()).toEqual(3);
- HOT.undo();
- expect(countRows()).toEqual(2);
- HOT.redo();
- expect(countRows()).toEqual(3);
- });
- it('should redo creation of multiple rows', function () {
- var HOT = handsontable({
- data: createObjectData().slice(0, 2)
- });
- expect(countRows()).toEqual(2);
- alter('insert_row', 0, 5);
- expect(countRows()).toEqual(7);
- HOT.undo();
- expect(countRows()).toEqual(2);
- HOT.redo();
- expect(countRows()).toEqual(7);
- });
- it('should redo removal of single row', function () {
- var HOT = handsontable({
- data: createObjectData().slice(0, 2)
- });
- expect(countRows()).toEqual(2);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- alter('remove_row');
- expect(countRows()).toEqual(1);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBeNull();
- expect(getDataAtRowProp(1, 'surname')).toBeNull();
- HOT.undo();
- expect(countRows()).toEqual(2);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- HOT.redo();
- expect(countRows()).toEqual(1);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBeNull();
- expect(getDataAtRowProp(1, 'surname')).toBeNull();
- });
- it('should redo removal of multiple rows', function () {
- var HOT = handsontable({
- data: createObjectData()
- });
- expect(countRows()).toEqual(3);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- expect(getDataAtRowProp(2, 'name')).toEqual('Roger');
- expect(getDataAtRowProp(2, 'surname')).toEqual('Moore');
- alter('remove_row', 1, 2);
- expect(countRows()).toEqual(1);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBeNull();
- expect(getDataAtRowProp(1, 'surname')).toBeNull();
- expect(getDataAtRowProp(2, 'name')).toBeNull();
- expect(getDataAtRowProp(2, 'surname')).toBeNull();
- HOT.undo();
- expect(countRows()).toEqual(3);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- expect(getDataAtRowProp(2, 'name')).toEqual('Roger');
- expect(getDataAtRowProp(2, 'surname')).toEqual('Moore');
- HOT.redo();
- expect(countRows()).toEqual(1);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBeNull();
- expect(getDataAtRowProp(1, 'surname')).toBeNull();
- expect(getDataAtRowProp(2, 'name')).toBeNull();
- expect(getDataAtRowProp(2, 'surname')).toBeNull();
- });
- it('should redo multiple changes', function () {
- handsontable({
- data: createObjectData().slice(0, 2)
- });
- var HOT = getInstance();
- setDataAtRowProp(0, 'name', 'Pierce');
- setDataAtRowProp(0, 'surname', 'Brosnan');
- setDataAtRowProp(1, 'name', 'Daniel');
- setDataAtRowProp(1, 'surname', 'Craig');
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Daniel');
- expect(getDataAtRowProp(1, 'surname')).toBe('Craig');
- HOT.undo();
- HOT.undo();
- HOT.undo();
- HOT.undo();
- expect(getDataAtRowProp(0, 'name')).toBe('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toBe('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.redo();
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.redo();
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.redo();
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Daniel');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.redo();
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Daniel');
- expect(getDataAtRowProp(1, 'surname')).toBe('Craig');
- HOT.redo();
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Daniel');
- expect(getDataAtRowProp(1, 'surname')).toBe('Craig');
- });
- it('should redo multiple changes in cells with validators', function (done) {
- handsontable({
- data: createObjectData().slice(0, 2)
- });
- var HOT = getInstance();
- setDataAtRowProp(0, 'name', 'Pierce');
- setDataAtRowProp(0, 'surname', 'Brosnan');
- setDataAtRowProp(1, 'name', 'Daniel');
- setDataAtRowProp(1, 'surname', 'Craig');
- setTimeout(function () {
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Daniel');
- expect(getDataAtRowProp(1, 'surname')).toBe('Craig');
- HOT.undo();
- }, 200);
- setTimeout(function () {
- HOT.undo();
- }, 400);
- setTimeout(function () {
- HOT.undo();
- }, 600);
- setTimeout(function () {
- HOT.undo();
- }, 800);
- setTimeout(function () {
- expect(getDataAtRowProp(0, 'name')).toBe('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toBe('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.redo();
- }, 1000);
- setTimeout(function () {
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Dalton');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.redo();
- }, 1200);
- setTimeout(function () {
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Sean');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.redo();
- }, 1400);
- setTimeout(function () {
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Daniel');
- expect(getDataAtRowProp(1, 'surname')).toBe('Connery');
- HOT.redo();
- }, 1600);
- setTimeout(function () {
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Daniel');
- expect(getDataAtRowProp(1, 'surname')).toBe('Craig');
- HOT.redo();
- }, 1800);
- setTimeout(function () {
- expect(getDataAtRowProp(0, 'name')).toBe('Pierce');
- expect(getDataAtRowProp(0, 'surname')).toBe('Brosnan');
- expect(getDataAtRowProp(1, 'name')).toBe('Daniel');
- expect(getDataAtRowProp(1, 'surname')).toBe('Craig');
- done();
- }, 2000);
- });
- it('should redo multiple row creations', function () {
- var HOT = handsontable({
- data: createObjectData().slice(0, 2)
- });
- expect(countRows()).toEqual(2);
- alter('insert_row');
- alter('insert_row');
- alter('insert_row');
- alter('insert_row');
- expect(countRows()).toEqual(6);
- HOT.undo();
- HOT.undo();
- HOT.undo();
- HOT.undo();
- expect(countRows()).toEqual(2);
- HOT.redo();
- expect(countRows()).toEqual(3);
- HOT.redo();
- expect(countRows()).toEqual(4);
- HOT.redo();
- expect(countRows()).toEqual(5);
- HOT.redo();
- expect(countRows()).toEqual(6);
- HOT.redo();
- expect(countRows()).toEqual(6);
- });
- it('should undo multiple row removals', function () {
- var HOT = handsontable({
- data: createObjectData()
- });
- expect(countRows()).toEqual(3);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- expect(getDataAtRowProp(2, 'name')).toEqual('Roger');
- expect(getDataAtRowProp(2, 'surname')).toEqual('Moore');
- alter('remove_row');
- alter('remove_row');
- expect(countRows()).toEqual(1);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- HOT.undo();
- HOT.undo();
- HOT.undo();
- expect(countRows()).toEqual(3);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- expect(getDataAtRowProp(2, 'name')).toEqual('Roger');
- expect(getDataAtRowProp(2, 'surname')).toEqual('Moore');
- HOT.redo();
- expect(countRows()).toEqual(2);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- expect(getDataAtRowProp(1, 'name')).toEqual('Sean');
- expect(getDataAtRowProp(1, 'surname')).toEqual('Connery');
- HOT.redo();
- expect(countRows()).toEqual(1);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- HOT.redo();
- expect(countRows()).toEqual(1);
- expect(getDataAtRowProp(0, 'name')).toEqual('Timothy');
- expect(getDataAtRowProp(0, 'surname')).toEqual('Dalton');
- });
- });
- });
- });
- describe('plugin features', function () {
- describe('cell alignment', function () {
- it('should undo a sequence of aligning cells', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(9, 9),
- contextMenu: true,
- colWidths: [50, 50, 50, 50, 50, 50, 50, 50, 50],
- rowHeights: [50, 50, 50, 50, 50, 50, 50, 50, 50]
- });
- // top 3 rows center
- selectCell(0, 0, 2, 8);
- hot.getPlugin('contextMenu').executeCommand('alignment:center');
- // middle 3 rows unchanged - left
- // bottom 3 rows right
- selectCell(6, 0, 8, 8);
- hot.getPlugin('contextMenu').executeCommand('alignment:right');
- // left 3 columns - middle
- selectCell(0, 0, 8, 2);
- hot.getPlugin('contextMenu').executeCommand('alignment:middle');
- // middle 3 columns unchanged - top
- // right 3 columns - bottom
- selectCell(0, 6, 8, 8);
- hot.getPlugin('contextMenu').executeCommand('alignment:bottom');
- var cellMeta = hot.getCellMeta(0, 0);
- expect(cellMeta.className.indexOf('htCenter')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htMiddle')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(0, 7);
- expect(cellMeta.className.indexOf('htCenter')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htBottom')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(5, 1);
- expect(cellMeta.className.indexOf('htMiddle')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(5, 7);
- expect(cellMeta.className.indexOf('htBottom')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(7, 1);
- expect(cellMeta.className.indexOf('htRight')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htMiddle')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(7, 5);
- expect(cellMeta.className.indexOf('htRight')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(7, 7);
- expect(cellMeta.className.indexOf('htRight')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htBottom')).toBeGreaterThan(-1);
- hot.undo();
- cellMeta = hot.getCellMeta(0, 7);
- expect(cellMeta.className.indexOf('htCenter')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htBottom')).toEqual(-1);
- cellMeta = hot.getCellMeta(5, 7);
- expect(cellMeta.className.indexOf('htBottom')).toEqual(-1);
- cellMeta = hot.getCellMeta(7, 7);
- expect(cellMeta.className.indexOf('htRight')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htBottom')).toEqual(-1);
- hot.undo();
- cellMeta = hot.getCellMeta(0, 0);
- expect(cellMeta.className.indexOf('htCenter')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htMiddle')).toEqual(-1);
- cellMeta = hot.getCellMeta(5, 1);
- expect(cellMeta.className.indexOf('htMiddle')).toEqual(-1);
- cellMeta = hot.getCellMeta(7, 1);
- expect(cellMeta.className.indexOf('htRight')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htMiddle')).toEqual(-1);
- hot.undo();
- cellMeta = hot.getCellMeta(7, 1);
- expect(cellMeta.className.indexOf('htRight')).toEqual(-1);
- expect(cellMeta.className.indexOf('htMiddle')).toEqual(-1);
- cellMeta = hot.getCellMeta(7, 5);
- expect(cellMeta.className.indexOf('htRight')).toEqual(-1);
- cellMeta = hot.getCellMeta(7, 7);
- expect(cellMeta.className.indexOf('htRight')).toEqual(-1);
- expect(cellMeta.className.indexOf('htBottom')).toEqual(-1);
- hot.undo();
- // check if all cells are either non-adjusted or adjusted to the left (as default)
- var finish;
- for (var i = 0; i < 9; i++) {
- for (var j = 0; j < 9; j++) {
- cellMeta = hot.getCellMeta(i, j);
- finish = cellMeta.className === void 0 || cellMeta.className.trim() === '' || cellMeta.className.trim() === 'htLeft';
- expect(finish).toBe(true);
- }
- }
- });
- it('should redo a sequence of aligning cells', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(9, 9),
- contextMenu: true,
- colWidths: [50, 50, 50, 50, 50, 50, 50, 50, 50],
- rowHeights: [50, 50, 50, 50, 50, 50, 50, 50, 50]
- });
- // top 3 rows center
- selectCell(0, 0, 2, 8);
- hot.getPlugin('contextMenu').executeCommand('alignment:center');
- // middle 3 rows unchanged - left
- // bottom 3 rows right
- selectCell(6, 0, 8, 8);
- hot.getPlugin('contextMenu').executeCommand('alignment:right');
- // left 3 columns - middle
- selectCell(0, 0, 8, 2);
- hot.getPlugin('contextMenu').executeCommand('alignment:middle');
- // middle 3 columns unchanged - top
- // right 3 columns - bottom
- selectCell(0, 6, 8, 8);
- hot.getPlugin('contextMenu').executeCommand('alignment:bottom');
- var cellMeta = hot.getCellMeta(0, 0);
- expect(cellMeta.className.indexOf('htCenter')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htMiddle')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(0, 7);
- expect(cellMeta.className.indexOf('htCenter')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htBottom')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(5, 1);
- expect(cellMeta.className.indexOf('htMiddle')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(5, 7);
- expect(cellMeta.className.indexOf('htBottom')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(7, 1);
- expect(cellMeta.className.indexOf('htRight')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htMiddle')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(7, 5);
- expect(cellMeta.className.indexOf('htRight')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(7, 7);
- expect(cellMeta.className.indexOf('htRight')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htBottom')).toBeGreaterThan(-1);
- hot.undo();
- hot.undo();
- hot.undo();
- hot.undo();
- // check if all cells are either non-adjusted or adjusted to the left (as default)
- var finish;
- for (var i = 0; i < 9; i++) {
- for (var j = 0; j < 9; j++) {
- cellMeta = hot.getCellMeta(i, j);
- finish = cellMeta.className === void 0 || cellMeta.className.trim() === '' || cellMeta.className.trim() === 'htLeft';
- expect(finish).toBe(true);
- }
- }
- hot.redo();
- cellMeta = hot.getCellMeta(0, 0);
- expect(cellMeta.className.indexOf('htCenter')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(1, 5);
- expect(cellMeta.className.indexOf('htCenter')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(2, 8);
- expect(cellMeta.className.indexOf('htCenter')).toBeGreaterThan(-1);
- hot.redo();
- cellMeta = hot.getCellMeta(6, 0);
- expect(cellMeta.className.indexOf('htRight')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(7, 5);
- expect(cellMeta.className.indexOf('htRight')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(8, 8);
- expect(cellMeta.className.indexOf('htRight')).toBeGreaterThan(-1);
- hot.redo();
- cellMeta = hot.getCellMeta(0, 0);
- expect(cellMeta.className.indexOf('htMiddle')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htCenter')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(5, 1);
- expect(cellMeta.className.indexOf('htMiddle')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(8, 2);
- expect(cellMeta.className.indexOf('htMiddle')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htRight')).toBeGreaterThan(-1);
- hot.redo();
- cellMeta = hot.getCellMeta(0, 6);
- expect(cellMeta.className.indexOf('htBottom')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htCenter')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(5, 7);
- expect(cellMeta.className.indexOf('htBottom')).toBeGreaterThan(-1);
- cellMeta = hot.getCellMeta(8, 8);
- expect(cellMeta.className.indexOf('htBottom')).toBeGreaterThan(-1);
- expect(cellMeta.className.indexOf('htRight')).toBeGreaterThan(-1);
- });
- });
- it('should exposed new methods when plugin is enabled', function () {
- var hot = handsontable({
- undo: false
- });
- expect(hot.undo).toBeUndefined();
- expect(hot.redo).toBeUndefined();
- expect(hot.isUndoAvailable).toBeUndefined();
- expect(hot.isRedoAvailable).toBeUndefined();
- expect(hot.clearUndo).toBeUndefined();
- updateSettings({
- undo: true
- });
- expect(_typeof(hot.undo)).toEqual('function');
- expect(_typeof(hot.redo)).toEqual('function');
- expect(_typeof(hot.isUndoAvailable)).toEqual('function');
- expect(_typeof(hot.isRedoAvailable)).toEqual('function');
- expect(_typeof(hot.clearUndo)).toEqual('function');
- });
- it('should remove exposed methods when plugin is disbaled', function () {
- var hot = handsontable({
- undo: true
- });
- expect(_typeof(hot.undo)).toEqual('function');
- expect(_typeof(hot.redo)).toEqual('function');
- expect(_typeof(hot.isUndoAvailable)).toEqual('function');
- expect(_typeof(hot.isRedoAvailable)).toEqual('function');
- expect(_typeof(hot.clearUndo)).toEqual('function');
- updateSettings({
- undo: false
- });
- expect(hot.undo).toBeUndefined();
- expect(hot.redo).toBeUndefined();
- expect(hot.isUndoAvailable).toBeUndefined();
- expect(hot.isRedoAvailable).toBeUndefined();
- expect(hot.clearUndo).toBeUndefined();
- });
- describe('Keyboard shortcuts', function () {
- it('should undo single change after hitting CTRL+Z', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var HOT = getInstance();
- selectCell(0, 0);
- setDataAtCell(0, 0, 'new value');
- this.$container.simulate('keydown', { ctrlKey: true, keyCode: 'Z'.charCodeAt(0) });
- expect(getDataAtCell(0, 0)).toBe('A1');
- });
- it('should redo single change after hitting CTRL+Y', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var HOT = getInstance();
- selectCell(0, 0);
- setDataAtCell(0, 0, 'new value');
- expect(getDataAtCell(0, 0)).toBe('new value');
- HOT.undo();
- expect(getDataAtCell(0, 0)).toBe('A1');
- this.$container.simulate('keydown', { ctrlKey: true, keyCode: 'Y'.charCodeAt(0) });
- expect(getDataAtCell(0, 0)).toBe('new value');
- });
- it('should redo single change after hitting CTRL+SHIFT+Z', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var HOT = getInstance();
- selectCell(0, 0);
- setDataAtCell(0, 0, 'new value');
- expect(getDataAtCell(0, 0)).toBe('new value');
- HOT.undo();
- expect(getDataAtCell(0, 0)).toBe('A1');
- this.$container.simulate('keydown', { ctrlKey: true, shiftKey: true, keyCode: 'Z'.charCodeAt(0) });
- expect(getDataAtCell(0, 0)).toBe('new value');
- });
- });
- });
- describe('Hooks', function () {
- it('should fire a `beforeUndo` hook after the undo process begins', function (done) {
- var beforeUndoSpy = jasmine.createSpy('beforeUndo');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var hookData = null;
- hot.addHook('beforeUndo', beforeUndoSpy);
- hot.addHook('beforeUndo', function (data) {
- hookData = data;
- });
- alter('remove_row', 1);
- setTimeout(function () {
- hot.undo();
- }, 10);
- setTimeout(function () {
- expect(beforeUndoSpy.calls.count()).toEqual(1);
- expect(hookData).not.toBe(null);
- expect(hookData.actionType).toEqual('remove_row');
- expect(hookData.data).toEqual([['A2', 'B2']]);
- done();
- }, 100);
- });
- it('should fire a `beforeRedo` hook before the redo process begins', function (done) {
- var beforeRedoSpy = jasmine.createSpy('beforeRedo');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var hookData = null;
- hot.addHook('beforeRedo', beforeRedoSpy);
- hot.addHook('beforeRedo', function (data) {
- hookData = data;
- });
- alter('remove_row', 1);
- setTimeout(function () {
- hot.undo();
- hot.redo();
- }, 10);
- setTimeout(function () {
- expect(beforeRedoSpy.calls.count()).toEqual(1);
- expect(hookData).not.toBe(null);
- expect(hookData.actionType).toEqual('remove_row');
- expect(hookData.data).toEqual([['A2', 'B2']]);
- done();
- }, 100);
- });
- it('should fire a `afterRedo` hook after the redo process begins', function (done) {
- var afterRedoSpy = jasmine.createSpy('afterRedo');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2)
- });
- var hookData = null;
- hot.addHook('beforeRedo', afterRedoSpy);
- hot.addHook('beforeRedo', function (data) {
- hookData = data;
- });
- alter('remove_row', 1);
- setTimeout(function () {
- hot.undo();
- hot.redo();
- }, 10);
- setTimeout(function () {
- expect(afterRedoSpy.calls.count()).toEqual(1);
- expect(hookData).not.toBe(null);
- expect(hookData.actionType).toEqual('remove_row');
- expect(hookData.data).toEqual([['A2', 'B2']]);
- done();
- }, 100);
- });
- });
- });
- /***/ }),
- /* 149 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('ColHeader', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should not show col headers by default', function () {
- var that = this;
- handsontable();
- expect(that.$container.find('thead th').length).toEqual(0);
- });
- it('should show col headers if true', function () {
- var that = this;
- handsontable({
- colHeaders: true
- });
- expect(that.$container.find('thead th').length).toBeGreaterThan(0);
- });
- it('should show default columns headers labelled A-(Z * n)', function () {
- var that = this;
- var startCols = 5;
- handsontable({
- startCols: startCols,
- colHeaders: true
- });
- var ths = getHtCore().find('thead th');
- expect(ths.length).toEqual(startCols);
- expect($.trim(ths.eq(0).text())).toEqual('A');
- expect($.trim(ths.eq(1).text())).toEqual('B');
- expect($.trim(ths.eq(2).text())).toEqual('C');
- expect($.trim(ths.eq(3).text())).toEqual('D');
- expect($.trim(ths.eq(4).text())).toEqual('E');
- });
- it('should show default columns headers labelled A-(Z * n) when columns as an array is present', function () {
- var that = this;
- var startCols = 5;
- handsontable({
- startCols: startCols,
- colHeaders: true,
- columns: [{}, {}, {}, {}, {}]
- });
- var ths = getHtCore().find('thead th');
- expect(ths.length).toEqual(startCols);
- expect($.trim(ths.eq(0).text())).toEqual('A');
- expect($.trim(ths.eq(1).text())).toEqual('B');
- expect($.trim(ths.eq(2).text())).toEqual('C');
- expect($.trim(ths.eq(3).text())).toEqual('D');
- expect($.trim(ths.eq(4).text())).toEqual('E');
- });
- it('should show default columns headers labelled A-(Z * n) when columns as a function is present', function () {
- var that = this;
- var startCols = 5;
- handsontable({
- startCols: startCols,
- colHeaders: true,
- columns: function columns(column) {
- return {};
- }
- });
- var ths = getHtCore().find('thead th');
- expect(ths.length).toEqual(startCols);
- expect($.trim(ths.eq(0).text())).toEqual('A');
- expect($.trim(ths.eq(1).text())).toEqual('B');
- expect($.trim(ths.eq(2).text())).toEqual('C');
- expect($.trim(ths.eq(3).text())).toEqual('D');
- expect($.trim(ths.eq(4).text())).toEqual('E');
- });
- it('should show col headers with custom label', function () {
- var that = this;
- var startCols = 5;
- handsontable({
- startCols: startCols,
- colHeaders: ['First', 'Second', 'Third']
- });
- var ths = getHtCore().find('thead th');
- expect(ths.length).toEqual(startCols);
- expect($.trim(ths.eq(0).text())).toEqual('First');
- expect($.trim(ths.eq(1).text())).toEqual('Second');
- expect($.trim(ths.eq(2).text())).toEqual('Third');
- expect($.trim(ths.eq(3).text())).toEqual('D');
- expect($.trim(ths.eq(4).text())).toEqual('E');
- });
- it('should not show col headers if false', function () {
- var that = this;
- handsontable({
- colHeaders: false
- });
- expect(that.$container.find('th.htColHeader').length).toEqual(0);
- });
- it('should hide columns headers after updateSettings', function () {
- var hot = handsontable({
- startCols: 5,
- colHeaders: true
- });
- expect(getHtCore().find('thead th').length).toEqual(5);
- expect(getTopClone().find('thead th').length).toEqual(5);
- hot.updateSettings({
- colHeaders: false
- });
- expect(getHtCore().find('thead th').length).toEqual(0);
- expect(getTopClone().width()).toEqual(0);
- });
- it('should show/hide columns headers after updateSettings', function () {
- var hot = handsontable({
- startCols: 5,
- colHeaders: true
- });
- expect(getHtCore().find('thead th').length).toEqual(5);
- expect(getTopClone().find('thead th').length).toEqual(5);
- hot.updateSettings({
- colHeaders: false
- });
- expect(getHtCore().find('thead th').length).toEqual(0);
- expect(getTopClone().width()).toEqual(0);
- hot.updateSettings({
- colHeaders: true
- });
- expect(getHtCore().find('thead th').length).toEqual(5);
- expect(getTopClone().width()).toBeGreaterThan(0);
- hot.updateSettings({
- colHeaders: false
- });
- expect(getHtCore().find('thead th').length).toEqual(0);
- expect(getTopClone().width()).toEqual(0);
- });
- it('should show columns headers after updateSettings', function () {
- var hot = handsontable({
- startCols: 5,
- colHeaders: false
- });
- expect(getHtCore().find('thead th').length).toEqual(0);
- expect(getTopClone().find('thead th').length).toEqual(0);
- hot.updateSettings({
- colHeaders: true
- });
- expect(getHtCore().find('thead th').length).toEqual(5);
- expect(getTopClone().find('thead th').length).toEqual(5);
- });
- it('should show new columns headers after updateSettings', function () {
- var hot = handsontable({
- startCols: 3,
- colHeaders: ['A', 'B', 'C']
- });
- var htCore = getHtCore();
- expect(htCore.find('thead th:eq(0)').text()).toEqual('A');
- expect(htCore.find('thead th:eq(1)').text()).toEqual('B');
- expect(htCore.find('thead th:eq(2)').text()).toEqual('C');
- hot.updateSettings({
- colHeaders: ['X', 'Y', 'Z']
- });
- expect(htCore.find('thead th:eq(0)').text()).toEqual('X');
- expect(htCore.find('thead th:eq(1)').text()).toEqual('Y');
- expect(htCore.find('thead th:eq(2)').text()).toEqual('Z');
- });
- it('should be possible to define colHeaders with a function', function () {
- var hot = handsontable({
- startCols: 2,
- colHeaders: function colHeaders(col) {
- switch (col) {
- case 0:
- return 'One';
- case 1:
- return 'Two';
- default:
- break;
- }
- }
- });
- var htCore = getHtCore();
- expect(htCore.find('thead th:eq(0)').text()).toEqual('One');
- expect(htCore.find('thead th:eq(1)').text()).toEqual('Two');
- });
- it('should be possible to set HTML in colHeaders', function () {
- var hot = handsontable({
- startCols: 2,
- colHeaders: ['One <input type="checkbox">', 'Two <input type="checkbox">']
- });
- var htCore = getHtCore();
- expect(htCore.find('thead th:eq(0) input[type=checkbox]').length).toEqual(1);
- expect(htCore.find('thead th:eq(1) input[type=checkbox]').length).toEqual(1);
- });
- it('should be possible to set colHeaders when columns array is present', function () {
- var hot = handsontable({
- startCols: 2,
- colHeaders: ['One', 'Two'],
- columns: [{ type: 'text' }, { type: 'text' }]
- });
- var htCore = getHtCore();
- expect(htCore.find('thead th:eq(0)').text()).toEqual('One');
- expect(htCore.find('thead th:eq(1)').text()).toEqual('Two');
- });
- it('should be possible to set colHeaders when columns function is present', function () {
- var hot = handsontable({
- startCols: 2,
- colHeaders: ['One', 'Two'],
- columns: function columns(column) {
- var colMeta = { type: 'text' };
- if ([0, 1].indexOf(column) < 0) {
- colMeta = null;
- }
- return colMeta;
- }
- });
- var htCore = getHtCore();
- expect(htCore.find('thead th:eq(0)').text()).toEqual('One');
- expect(htCore.find('thead th:eq(1)').text()).toEqual('Two');
- });
- it('should be possible to set colHeaders using columns title property', function () {
- var hot = handsontable({
- startCols: 2,
- colHeaders: ['One', 'Two'],
- columns: [{ type: 'text', title: 'Special title' }, { type: 'text' }]
- });
- var htCore = getHtCore();
- expect(htCore.find('thead th:eq(0)').text()).toEqual('Special title');
- expect(htCore.find('thead th:eq(1)').text()).toEqual('Two');
- });
- it('should be possible to set colHeaders using columns title property when columns is a function', function () {
- var hot = handsontable({
- startCols: 2,
- colHeaders: ['One', 'Two'],
- columns: function columns(column) {
- var colMeta = { type: 'text' };
- if (column === 0) {
- colMeta.title = 'Special title';
- }
- if ([0, 1].indexOf(column) < 0) {
- colMeta = null;
- }
- return colMeta;
- }
- });
- var htCore = getHtCore();
- expect(htCore.find('thead th:eq(0)').text()).toEqual('Special title');
- expect(htCore.find('thead th:eq(1)').text()).toEqual('Two');
- });
- it('should resize all the column headers in the overlays, according to the other overlays\' height', function () {
- var hot = handsontable({
- startCols: 5,
- colHeaders: ['a', 'a', 'a', 'a<BR>a', 'a'],
- fixedColumnsLeft: 2
- });
- var topHeaderExample = $('.ht_clone_top').find('thead tr:first-child th:nth-child(1)'),
- masterHeaderExample = $('.ht_master').find('thead tr:first-child th:nth-child(3)');
- expect(topHeaderExample.height()).toEqual(masterHeaderExample.height());
- });
- it('should allow defining custom column header height using the columnHeaderHeight config option', function () {
- var hot = handsontable({
- startCols: 3,
- colHeaders: true,
- columnHeaderHeight: 40
- });
- hot.render();
- expect(this.$container.find('th').eq(0).height()).toEqual(40);
- });
- it('should allow defining custom column header heights using the columnHeaderHeight config option, when multiple column header levels are defined', function () {
- var hot = handsontable({
- startCols: 3,
- colHeaders: true,
- columnHeaderHeight: [45, 65],
- afterGetColumnHeaderRenderers: function afterGetColumnHeaderRenderers(array) {
- array.push(function (index, TH) {
- TH.innerHTML = '';
- var div = document.createElement('div');
- var span = document.createElement('span');
- div.className = 'relative';
- span.className = 'colHeader';
- span.innerText = index;
- div.appendChild(span);
- TH.appendChild(div);
- });
- return array;
- }
- });
- hot.render();
- expect(this.$container.find('.handsontable.ht_clone_top tr:nth-child(1) th:nth-child(1)').height()).toEqual(45);
- expect(this.$container.find('.handsontable.ht_clone_top tr:nth-child(2) th:nth-child(1)').height()).toEqual(65);
- });
- });
- /***/ }),
- /* 150 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_alter', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfNestedObjects = function arrayOfNestedObjects() {
- return [{ id: 1,
- name: {
- first: 'Ted',
- last: 'Right'
- },
- address: 'Street Name',
- zip: '80410',
- city: 'City Name' }, { id: 2,
- name: {
- first: 'Frank',
- last: 'Honest'
- },
- address: 'Street Name',
- zip: '80410',
- city: 'City Name' }, { id: 3,
- name: {
- first: 'Joan',
- last: 'Well'
- },
- address: 'Street Name',
- zip: '80410',
- city: 'City Name' }];
- };
- var arrayOfArrays = function arrayOfArrays() {
- return [['', 'Kia', 'Nissan', 'Toyota', 'Honda'], ['2008', 10, 11, 12, 13], ['2009', 20, 11, 14, 13], ['2010', 30, 15, 12, 13]];
- };
- describe('remove row', function () {
- it('should remove row', function () {
- handsontable({
- minRows: 5,
- data: arrayOfNestedObjects(),
- columns: [{ data: 'id' }, { data: 'name.first' }]
- });
- alter('remove_row', 1);
- expect(getDataAtCell(1, 1)).toEqual('Joan'); // Joan should be moved up
- expect(getData().length).toEqual(5); // new row should be added by keepEmptyRows
- });
- it('should fire beforeRemoveRow event before removing row', function () {
- var onBeforeRemoveRow = jasmine.createSpy('onBeforeRemoveRow');
- var hot = handsontable({
- data: arrayOfNestedObjects(),
- columns: [{ data: 'id' }, { data: 'name.first' }],
- beforeRemoveRow: onBeforeRemoveRow
- });
- alter('remove_row', 2, 1, 'customSource');
- expect(onBeforeRemoveRow).toHaveBeenCalledWith(countRows(), 1, [2], 'customSource', undefined, undefined);
- });
- it('should not remove row if removing has been canceled by beforeRemoveRow event handler', function () {
- var onBeforeRemoveRow = jasmine.createSpy('onBeforeRemoveRow');
- onBeforeRemoveRow.and.callFake(function () {
- return false;
- });
- var hot = handsontable({
- data: arrayOfNestedObjects(),
- columns: [{ data: 'id' }, { data: 'name.first' }],
- beforeRemoveRow: onBeforeRemoveRow
- });
- expect(countRows()).toEqual(3);
- alter('remove_row');
- expect(countRows()).toEqual(3);
- });
- it('should not remove rows below minRows', function () {
- handsontable({
- startRows: 5,
- minRows: 4
- });
- alter('remove_row', 1);
- alter('remove_row', 1);
- alter('remove_row', 1);
- expect(countRows()).toEqual(4);
- });
- it('should not remove cols below minCols', function () {
- handsontable({
- startCols: 5,
- minCols: 4
- });
- alter('remove_col', 1);
- alter('remove_col', 1);
- alter('remove_col', 1);
- expect(countCols()).toEqual(4);
- });
- it('should remove one row if amount parameter is empty', function () {
- handsontable({
- data: [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3'], ['d1', 'd2', 'd3'], ['e1', 'e2', 'e3']]
- });
- alter('remove_row', 1);
- expect(countRows()).toEqual(4);
- expect(this.$container.find('tr:eq(0) td:eq(0)').html()).toEqual('a1');
- expect(this.$container.find('tr:eq(1) td:eq(1)').html()).toEqual('c2');
- });
- it('should remove as many rows as given in the amount parameter', function () {
- handsontable({
- data: [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3'], ['d1', 'd2', 'd3'], ['e1', 'e2', 'e3']]
- });
- alter('remove_row', 1, 3);
- expect(countRows()).toEqual(2);
- expect(this.$container.find('tr:eq(0) td:eq(0)').html()).toEqual('a1');
- expect(this.$container.find('tr:eq(1) td:eq(1)').html()).toEqual('e2');
- });
- it('should not remove more rows that exist', function () {
- handsontable({
- data: [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3'], ['d1', 'd2', 'd3'], ['e1', 'e2', 'e3']]
- });
- alter('remove_row', 1, 10);
- expect(countRows()).toEqual(1);
- expect(getHtCore().find('tr:last td:last').html()).toEqual('a3');
- });
- it('should remove one row from end if no parameters are given', function () {
- handsontable({
- data: [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3'], ['d1', 'd2', 'd3'], ['e1', 'e2', 'e3']]
- });
- alter('remove_row');
- expect(countRows()).toEqual(4);
- expect(getHtCore().find('tr:last td:eq(0)').html()).toEqual('d1');
- });
- it('should remove amount of rows from end if index parameter is not given', function () {
- handsontable({
- data: [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3'], ['d1', 'd2', 'd3'], ['e1', 'e2', 'e3']]
- });
- alter('remove_row', null, 3);
- expect(countRows()).toEqual(2);
- expect(getHtCore().find('tr:last td:eq(0)').html()).toEqual('b1');
- });
- it('should remove rows from table with fixedRows', function () {
- handsontable({
- data: [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']],
- fixedRowsTop: 1,
- minSpareRows: 0
- });
- alter('remove_row', 1);
- expect(countRows()).toEqual(1);
- });
- it('should remove all rows from table with fixedRows', function () {
- handsontable({
- data: [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3']],
- fixedRowsTop: 1,
- minSpareRows: 0
- });
- alter('remove_row', 1);
- alter('remove_row', 1);
- expect(countRows()).toEqual(0);
- });
- it('should remove row\'s cellProperties', function () {
- handsontable({
- startCols: 1,
- startRows: 3
- });
- getCellMeta(0, 0).someValue = [0, 0];
- getCellMeta(1, 0).someValue = [1, 0];
- getCellMeta(2, 0).someValue = [2, 0];
- alter('remove_row', 0);
- expect(getCellMeta(0, 0).someValue).toEqual([1, 0]);
- expect(getCellMeta(1, 0).someValue).toEqual([2, 0]);
- });
- it('should fire callback on remove row', function () {
- var outputBefore;
- var outputAfter;
- handsontable({
- minRows: 5,
- data: arrayOfNestedObjects(),
- columns: [{ data: 'id' }, { data: 'name.first' }],
- beforeRemoveRow: function beforeRemoveRow(index, amount, removedRows, source) {
- outputBefore = [index, amount, removedRows, source];
- },
- afterRemoveRow: function afterRemoveRow(index, amount, removedRows, source) {
- outputAfter = [index, amount, removedRows, source];
- }
- });
- alter('remove_row', 1, 2, 'customSource');
- expect(outputBefore).toEqual([1, 2, [1, 2], 'customSource']);
- expect(outputAfter).toEqual([1, 2, [1, 2], 'customSource']);
- });
- it('should decrement the number of fixed rows, if a fix row is removed', function () {
- var hot = handsontable({
- startCols: 1,
- startRows: 3,
- fixedRowsTop: 4
- });
- alter('remove_row', 1, 1);
- expect(hot.getSettings().fixedRowsTop).toEqual(3);
- alter('remove_row', 1, 2);
- expect(hot.getSettings().fixedRowsTop).toEqual(1);
- });
- it('should shift the cell meta according to the new row layout', function () {
- var hot = handsontable({
- startCols: 3,
- startRows: 4
- });
- setCellMeta(2, 1, 'className', 'test');
- alter('remove_row', 1, 1);
- expect(getCellMeta(1, 1).className).toEqual('test');
- });
- it('should shift the cell meta according to the new rows (>1) layout', function () {
- var hot = handsontable({
- startCols: 3,
- startRows: 4
- });
- setCellMeta(2, 1, 'className', 'test');
- alter('remove_row', 0, 2);
- expect(getCellMeta(0, 1).className).toEqual('test');
- });
- });
- describe('remove column', function () {
- it('should remove one column if amount parameter is empty', function () {
- handsontable({
- data: [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']]
- });
- alter('remove_col', 1);
- expect(countCols()).toEqual(7);
- expect(this.$container.find('tr:eq(0) td:eq(0)').html()).toEqual('a');
- expect(this.$container.find('tr:eq(1) td:eq(1)').html()).toEqual('c');
- });
- it('should remove as many columns as given in the amount parameter', function () {
- handsontable({
- data: [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']]
- });
- alter('remove_col', 1, 3);
- expect(countCols()).toEqual(5);
- expect(this.$container.find('tr:eq(0) td:eq(0)').html()).toEqual('a');
- expect(this.$container.find('tr:eq(1) td:eq(1)').html()).toEqual('e');
- });
- it('should not remove more columns that exist', function () {
- handsontable({
- data: [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']]
- });
- alter('remove_col', 6, 3);
- expect(countCols()).toEqual(6);
- expect(this.$container.find('tr:eq(1) td:last').html()).toEqual('f');
- });
- it('should remove one column from end if no parameters are given', function () {
- handsontable({
- data: [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']]
- });
- alter('remove_col');
- expect(countCols()).toEqual(7);
- expect(this.$container.find('tr:eq(1) td:last').html()).toEqual('g');
- });
- it('should remove amount of columns from end if index parameter is not given', function () {
- handsontable({
- data: [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']]
- });
- alter('remove_col', null, 3);
- expect(countCols()).toEqual(5);
- expect(this.$container.find('tr:eq(1) td:last').html()).toEqual('e');
- });
- it('should fire beforeRemoveCol event before removing col', function () {
- var onBeforeRemoveCol = jasmine.createSpy('onBeforeRemoveCol');
- var hot = handsontable({
- beforeRemoveCol: onBeforeRemoveCol
- });
- alter('remove_col');
- expect(onBeforeRemoveCol).toHaveBeenCalledWith(countCols(), 1, [4], undefined, undefined, undefined);
- });
- it('should not remove column if removing has been canceled by beforeRemoveCol event handler', function () {
- var onBeforeRemoveCol = jasmine.createSpy('onBeforeRemoveCol');
- onBeforeRemoveCol.and.callFake(function () {
- return false;
- });
- var hot = handsontable({
- beforeRemoveCol: onBeforeRemoveCol
- });
- expect(countCols()).toEqual(5);
- alter('remove_col');
- expect(countCols()).toEqual(5);
- });
- it('should fire callback on remove col', function () {
- var outputBefore;
- var outputAfter;
- handsontable({
- minRows: 5,
- data: arrayOfArrays(),
- beforeRemoveCol: function beforeRemoveCol(index, amount, removedCols, source) {
- outputBefore = [index, amount, removedCols, source];
- },
- afterRemoveCol: function afterRemoveCol(index, amount, removedCols, source) {
- outputAfter = [index, amount, removedCols, source];
- }
- });
- alter('remove_col', 1, 2, 'customSource');
- expect(outputBefore).toEqual([1, 2, [1, 2], 'customSource']);
- expect(outputAfter).toEqual([1, 2, [1, 2], 'customSource']);
- });
- it('should remove column\'s properties', function () {
- handsontable({
- startCols: 3,
- startRows: 1
- });
- getCellMeta(0, 0).someValue = [0, 0];
- getCellMeta(0, 1).someValue = [0, 1];
- getCellMeta(0, 2).someValue = [0, 2];
- alter('remove_col', 0);
- expect(getCellMeta(0, 0).someValue).toEqual([0, 1]);
- expect(getCellMeta(0, 1).someValue).toEqual([0, 2]);
- });
- it('should remove column when not all rows are visible in the viewport', function () {
- this.$container.css({
- height: '100',
- overflow: 'auto'
- });
- handsontable({
- startCols: 3,
- startRows: 20
- });
- expect(getHtCore().find('tbody tr').length).toBeLessThan(20);
- expect(countCols()).toEqual(3);
- alter('remove_col', 0);
- expect(countCols()).toEqual(2);
- });
- it('should not remove column header together with the column, if headers were NOT specified explicitly', function () {
- handsontable({
- startCols: 3,
- startRows: 2,
- colHeaders: true
- });
- expect(getColHeader()).toEqual(['A', 'B', 'C']);
- expect(countCols()).toEqual(3);
- alter('remove_col', 1);
- expect(countCols()).toEqual(2);
- expect(getColHeader()).toEqual(['A', 'B']);
- });
- it('should remove column header together with the column, if headers were specified explicitly', function () {
- handsontable({
- startCols: 3,
- startRows: 2,
- colHeaders: ['Header0', 'Header1', 'Header2']
- });
- expect(getColHeader()).toEqual(['Header0', 'Header1', 'Header2']);
- expect(countCols()).toEqual(3);
- alter('remove_col', 1);
- expect(countCols()).toEqual(2);
- expect(getColHeader()).toEqual(['Header0', 'Header2']);
- });
- it('should decrement the number of fixed columns, if a fix column is removed', function () {
- var hot = handsontable({
- startCols: 1,
- startRows: 3,
- fixedColumnsLeft: 4
- });
- alter('remove_col', 1, 1);
- expect(hot.getSettings().fixedColumnsLeft).toEqual(3);
- alter('remove_col', 1, 2);
- expect(hot.getSettings().fixedColumnsLeft).toEqual(1);
- });
- it('should shift the cell meta according to the new column layout', function () {
- var hot = handsontable({
- startCols: 4,
- startRows: 3
- });
- setCellMeta(1, 2, 'className', 'test');
- alter('remove_col', 1, 1);
- expect(getCellMeta(1, 1).className).toEqual('test');
- });
- it('should shift the cell meta according to the new columns (>1) layout', function () {
- var hot = handsontable({
- startCols: 4,
- startRows: 3
- });
- setCellMeta(1, 2, 'className', 'test');
- alter('remove_col', 0, 2);
- expect(getCellMeta(1, 0).className).toEqual('test');
- });
- });
- describe('insert row', function () {
- it('should insert row at given index', function () {
- handsontable({
- data: [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3'], ['d1', 'd2', 'd3'], ['e1', 'e2', 'e3']]
- });
- alter('insert_row', 1);
- expect(countRows()).toEqual(6);
- expect(this.$container.find('tr:eq(2) td:eq(0)').html()).toEqual('b1');
- });
- it('should insert row at the end if index is not given', function () {
- handsontable({
- data: [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3'], ['d1', 'd2', 'd3'], ['e1', 'e2', 'e3']]
- });
- alter('insert_row');
- expect(countRows()).toEqual(6);
- expect(getHtCore().find('tr:eq(4) td:eq(0)').html()).toEqual('e1');
- expect(getHtCore().find('tr:last td:eq(0)').html()).toEqual('');
- });
- it('should not change cellMeta after executing `insert row` without parameters (#3581, #3989, #2114)', function () {
- var greenRenderer = function greenRenderer(instance, td, row, col, prop, value, cellProperties) {
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- td.style.backgroundColor = 'green';
- };
- handsontable({
- data: [[0, 'a', true], [1, 'b', false], [2, 'c', true], [3, 'd', true]],
- cell: [{ row: 0, col: 0, renderer: greenRenderer, type: 'text', readOnly: true }],
- columns: [{ type: 'numeric' }, { type: 'text' }, { type: 'checkbox' }]
- });
- alter('insert_row');
- expect(getCellMeta(1, 0).renderer).not.toBe(greenRenderer);
- expect(getCellMeta(1, 0).readOnly).toBe(false);
- expect(getCellMeta(4, 0).renderer).not.toBe(greenRenderer);
- expect(getCellMeta(4, 0).readOnly).toBe(false);
- });
- it('should add new row which respect defined type of cells after executing `insert_row`', function () {
- handsontable({
- data: [[0, 'a', true], [1, 'b', false], [2, 'c', true], [3, 'd', true]],
- cell: [{ row: 0, col: 0, type: 'text' }],
- columns: [{ type: 'numeric' }, { type: 'text' }, { type: 'checkbox' }]
- });
- alter('insert_row');
- // added row
- expect(getCellMeta(4, 0).type).toEqual('numeric');
- expect(getDataAtCell(4, 0)).toEqual(null);
- expect(getCellMeta(4, 2).type).toEqual('checkbox');
- expect(getDataAtCell(4, 2)).toEqual(null);
- });
- it('should insert the amount of rows at given index', function () {
- handsontable({
- data: [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3'], ['d1', 'd2', 'd3'], ['e1', 'e2', 'e3']]
- });
- alter('insert_row', 1, 3);
- expect(countRows()).toEqual(8);
- expect(this.$container.find('tr:eq(1) td:eq(0)').html()).toEqual('');
- expect(this.$container.find('tr:eq(4) td:eq(0)').html()).toEqual('b1');
- });
- it('should insert the amount of rows at the end if index is not given', function () {
- handsontable({
- data: [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3'], ['d1', 'd2', 'd3'], ['e1', 'e2', 'e3']]
- });
- alter('insert_row', null, 3);
- expect(countRows()).toEqual(8);
- expect(getHtCore().find('tr:eq(4) td:eq(0)').html()).toEqual('e1');
- expect(getHtCore().find('tr:eq(5) td:eq(0)').html()).toEqual('');
- expect(getHtCore().find('tr:eq(6) td:eq(0)').html()).toEqual('');
- expect(getHtCore().find('tr:eq(7) td:eq(0)').html()).toEqual('');
- });
- it('should insert not more rows than maxRows', function () {
- handsontable({
- startRows: 5,
- maxRows: 7
- });
- alter('insert_row', 1);
- alter('insert_row', 1);
- alter('insert_row', 1);
- expect(countRows()).toEqual(7);
- });
- it('when amount parameter is used, should not insert more rows than allowed by maxRows', function () {
- handsontable({
- data: [['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3'], ['d1', 'd2', 'd3'], ['e1', 'e2', 'e3']],
- maxRows: 10
- });
- alter('insert_row', 1, 10);
- expect(countRows()).toEqual(10);
- expect(this.$container.find('tr:eq(6) td:eq(0)').html()).toEqual('b1');
- });
- it('should not add more source rows than defined in maxRows when trimming rows using the modifyRow hook', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 4),
- modifyRow: function modifyRow(row) {
- return [8, 9].indexOf(row) > -1 ? null : row;
- },
- maxRows: 10
- });
- expect(hot.countRows()).toEqual(8);
- hot.populateFromArray(7, 0, [['a'], ['b'], ['c']]);
- expect(hot.countSourceRows()).toEqual(10);
- expect(hot.getDataAtCell(7, 0)).toEqual('a');
- });
- it('should fire callback on create row', function () {
- var outputBefore;
- var outputAfter;
- handsontable({
- minRows: 5,
- data: arrayOfNestedObjects(),
- columns: [{ data: 'id' }, { data: 'name.first' }],
- beforeCreateRow: function beforeCreateRow(index, amount, source) {
- outputBefore = [index, amount, source];
- },
- afterCreateRow: function afterCreateRow(index, amount, source) {
- outputAfter = [index, amount, source];
- }
- });
- alter('insert_row', 3, 1, 'customSource');
- expect(outputBefore).toEqual([3, 1, 'customSource']);
- expect(outputAfter).toEqual([3, 1, 'customSource']);
- });
- it('should keep the single-cell selection in the same position as before inserting the row', function () {
- handsontable({
- minRows: 5,
- data: [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']]
- });
- selectCell(2, 2);
- alter('insert_row', 2);
- var selected = getSelected();
- expect(selected[0]).toEqual(3);
- expect(selected[2]).toEqual(3);
- });
- it('should shift the cell meta according to the new row layout', function () {
- var hot = handsontable({
- startCols: 4,
- startRows: 3
- });
- setCellMeta(2, 1, 'className', 'test');
- alter('insert_row', 1, 1);
- expect(getCellMeta(3, 1).className).toEqual('test');
- });
- it('should shift the cell meta according to the new rows (>1) layout', function () {
- var hot = handsontable({
- startCols: 4,
- startRows: 3
- });
- setCellMeta(2, 1, 'className', 'test');
- alter('insert_row', 0, 3);
- expect(getCellMeta(5, 1).className).toEqual('test');
- });
- });
- describe('insert column', function () {
- it('should insert column at given index', function () {
- handsontable({
- data: [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']]
- });
- alter('insert_col', 1);
- expect(countCols()).toEqual(9);
- expect(this.$container.find('tr:eq(1) td:eq(2)').html()).toEqual('b');
- });
- it('should insert column at the end if index is not given', function () {
- handsontable({
- data: [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']]
- });
- alter('insert_col');
- expect(countCols()).toEqual(9);
- expect(this.$container.find('tr:eq(1) td:eq(7)').html()).toEqual('h');
- });
- it('should insert the amount of columns at given index', function () {
- handsontable({
- data: [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']]
- });
- alter('insert_col', 1, 3);
- expect(countCols()).toEqual(11);
- expect(this.$container.find('tr:eq(1) td:eq(4)').html()).toEqual('b');
- });
- it('should insert the amount of columns at the end if index is not given', function () {
- handsontable({
- data: [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']]
- });
- alter('insert_col', null, 3);
- expect(countCols()).toEqual(11);
- expect(this.$container.find('tr:eq(1) td:eq(7)').html()).toEqual('h');
- expect(this.$container.find('tr:eq(1) td:eq(8)').html()).toEqual('');
- expect(this.$container.find('tr:eq(1) td:eq(9)').html()).toEqual('');
- expect(this.$container.find('tr:eq(1) td:eq(10)').html()).toEqual('');
- });
- it('should insert not more cols than maxCols', function () {
- handsontable({
- startCols: 5,
- maxCols: 7
- });
- alter('insert_col', 1);
- alter('insert_col', 1);
- alter('insert_col', 1);
- expect(countCols()).toEqual(7);
- });
- it('should not insert more columns than allowed by maxCols, when amount parameter is used', function () {
- handsontable({
- data: [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']],
- maxCols: 10
- });
- alter('insert_col', 1, 10);
- expect(countCols()).toEqual(10);
- expect(this.$container.find('tr:eq(1) td:eq(1)').html()).toEqual('');
- expect(this.$container.find('tr:eq(1) td:eq(2)').html()).toEqual('');
- expect(this.$container.find('tr:eq(1) td:eq(3)').html()).toEqual('b');
- });
- it('should fire callback on create col', function () {
- var outputBefore;
- var outputAfter;
- handsontable({
- minRows: 5,
- data: arrayOfArrays(),
- beforeCreateCol: function beforeCreateCol(index, amount, source) {
- outputBefore = [index, amount, source];
- },
- afterCreateCol: function afterCreateCol(index, amount, source) {
- outputAfter = [index, amount, source];
- }
- });
- alter('insert_col', 2, 1, 'customSource');
- expect(outputBefore).toEqual([2, 1, 'customSource']);
- expect(outputAfter).toEqual([2, 1, 'customSource']);
- });
- it('should not create column header together with the column, if headers were NOT specified explicitly', function () {
- handsontable({
- startCols: 3,
- startRows: 2,
- colHeaders: true
- });
- expect(getColHeader()).toEqual(['A', 'B', 'C']);
- expect(countCols()).toEqual(3);
- alter('insert_col', 1);
- expect(countCols()).toEqual(4);
- expect(getColHeader()).toEqual(['A', 'B', 'C', 'D']);
- });
- it('should create column header together with the column, if headers were specified explicitly', function () {
- handsontable({
- startCols: 3,
- startRows: 2,
- colHeaders: ['Header0', 'Header1', 'Header2']
- });
- expect(getColHeader()).toEqual(['Header0', 'Header1', 'Header2']);
- expect(countCols()).toEqual(3);
- alter('insert_col', 1);
- expect(countCols()).toEqual(4);
- expect(getColHeader()).toEqual(['Header0', 'B', 'Header1', 'Header2']);
- });
- it('should stretch the table after adding another column (if stretching is set to \'all\')', function () {
- this.$container.css({
- width: 500
- });
- var hot = handsontable({
- startCols: 5,
- startRows: 10,
- stretchH: 'all'
- });
- expect(Handsontable.dom.outerWidth(hot.view.TBODY)).toEqual(500);
- alter('insert_col', null, 1);
- expect(Handsontable.dom.outerWidth(hot.view.TBODY)).toEqual(500);
- alter('insert_col', null, 1);
- expect(Handsontable.dom.outerWidth(hot.view.TBODY)).toEqual(500);
- });
- it('should shift the cell meta according to the new column layout', function () {
- var hot = handsontable({
- startCols: 4,
- startRows: 3
- });
- setCellMeta(1, 2, 'className', 'test');
- alter('insert_col', 1, 1);
- expect(getCellMeta(1, 3).className).toEqual('test');
- });
- it('should shift the cell meta according to the new columns (>1) layout', function () {
- var hot = handsontable({
- startCols: 4,
- startRows: 3
- });
- setCellMeta(1, 2, 'className', 'test');
- alter('insert_col', 0, 3);
- expect(getCellMeta(1, 5).className).toEqual('test');
- });
- });
- });
- /***/ }),
- /* 151 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_beforeKeyDown', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should run beforeKeyDown hook', function () {
- var called = false;
- handsontable({
- data: [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],
- beforeKeyDown: function beforeKeyDown(event) {
- called = true;
- }
- });
- selectCell(0, 0);
- keyDown('arrow_right');
- expect(called).toEqual(true);
- });
- it('should run afterDocumentKeyDown and beforeKeyDown hook', function () {
- var called = [];
- handsontable({
- data: [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],
- afterDocumentKeyDown: function afterDocumentKeyDown() {
- called.push('afterDocumentKeyDown');
- },
- beforeKeyDown: function beforeKeyDown() {
- called.push('beforeKeyDown');
- }
- });
- selectCell(0, 0);
- keyDown('arrow_right');
- expect(called).toEqual(['afterDocumentKeyDown', 'beforeKeyDown']);
- });
- it('should prevent hook from running default action', function () {
- var called = false;
- handsontable({
- data: [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],
- beforeKeyDown: function beforeKeyDown(event) {
- event = serveImmediatePropagation(event);
- event.stopImmediatePropagation();
- called = true;
- }
- });
- selectCell(0, 0);
- keyDown('arrow_right');
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- expect(getSelected()).not.toEqual([0, 1, 0, 1]);
- });
- it('should overwrite default behavior of delete key, but not this of right arrow', function () {
- var called = 0;
- handsontable({
- data: [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],
- beforeKeyDown: function beforeKeyDown(event) {
- if (event.keyCode === 8) {
- event.stopImmediatePropagation();
- getInstance().alter('insert_row', 1, 1);
- }
- called++;
- }
- });
- selectCell(0, 0);
- keyDown('backspace');
- keyDown('arrow_right');
- expect(getData().length).toEqual(3);
- expect(getSelected()).toEqual([0, 1, 0, 1]);
- });
- it('should run beforeKeyDown hook in cell editor handler', function () {
- var called = 0;
- handsontable({
- data: [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],
- beforeKeyDown: function beforeKeyDown(event) {
- called++;
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- keyDown('enter');
- expect(called).toEqual(2);
- });
- });
- /***/ }),
- /* 152 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_beforechange', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('this.rootElement should point to handsontable rootElement', function () {
- var output = null;
- handsontable({
- beforeChange: function beforeChange() {
- output = this.rootElement;
- }
- });
- setDataAtCell(0, 0, 'test');
- expect(output).toEqual(this.$container[0]);
- });
- it('should remove change from stack', function () {
- var output = null;
- handsontable({
- data: [['a', 'b'], ['c', 'd']],
- beforeChange: function beforeChange(changes) {
- changes[1] = null;
- },
- afterChange: function afterChange(changes) {
- output = changes;
- }
- });
- setDataAtCell([[0, 0, 'test'], [1, 0, 'test'], [1, 1, 'test']]);
- expect(getDataAtCell(0, 0)).toEqual('test');
- expect(getDataAtCell(1, 0)).toEqual('c');
- expect(getDataAtCell(1, 1)).toEqual('test');
- expect(output).toEqual([[0, 0, 'a', 'test'], [1, 1, 'd', 'test']]);
- });
- it('should drop all changes when beforeChange return false', function () {
- var fired = false;
- handsontable({
- data: [['a', 'b'], ['c', 'd']],
- beforeChange: function beforeChange(changes) {
- fired = true;
- return false;
- }
- });
- setDataAtCell([[0, 0, 'test'], [1, 0, 'test'], [1, 1, 'test']]);
- expect(getDataAtCell(0, 0)).toEqual('a');
- expect(getDataAtCell(1, 0)).toEqual('c');
- expect(getDataAtCell(1, 1)).toEqual('d');
- });
- function beforechangeOnKeyFactory(keyCode) {
- return function () {
- var called = false;
- handsontable({
- beforeChange: function beforeChange(changes) {
- if (changes[0][2] === 'test' && changes[0][3] === '') {
- called = true;
- }
- }
- });
- setDataAtCell(0, 0, 'test');
- selectCell(0, 0);
- keyDown(keyCode);
- expect(called).toEqual(true);
- };
- }
- it('should be called on Delete key', beforechangeOnKeyFactory(46)); // 46 = Delete key
- it('should be called on Backspace key', beforechangeOnKeyFactory(8)); // 8 = Backspace key
- });
- /***/ }),
- /* 153 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
- describe('Core_copy', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfArrays = function arrayOfArrays() {
- return [['', 'Kia', 'Nissan', 'Toyota', 'Honda'], ['2008', 10, 11, 12, 13], ['2009', 20, 11, 14, 13], ['2010', 30, 15, 12, 13]];
- };
- it('should set copyable text until copyRowsLimit is reached', function () {
- handsontable({
- data: arrayOfArrays(),
- copyRowsLimit: 2
- });
- selectCell(0, 0, countRows() - 1, countCols() - 1); // selectAll
- keyDownUp('ctrl');
- // should prepare 2 rows for copying
- expect($('textarea.copyPaste').val()).toEqual('\tKia\tNissan\tToyota\tHonda\n2008\t10\t11\t12\t13');
- });
- it('should set copyable text until copyColsLimit is reached', function () {
- handsontable({
- data: arrayOfArrays(),
- copyColsLimit: 2
- });
- selectCell(0, 0, countRows() - 1, countCols() - 1); // selectAll
- keyDownUp('ctrl');
- // should prepare 2 columns for copying
- expect($('textarea.copyPaste').val()).toEqual('\tKia\n2008\t10\n2009\t20\n2010\t30');
- });
- it('should call onCopyLimit callback when copy limit was reached', function () {
- var result;
- handsontable({
- data: arrayOfArrays(),
- copyRowsLimit: 2,
- copyColsLimit: 2,
- afterCopyLimit: function afterCopyLimit(selectedRowsCount, selectedColsCount, copyRowsLimit, copyColsLimit) {
- result = [selectedRowsCount, selectedColsCount, copyRowsLimit, copyColsLimit];
- }
- });
- selectCell(0, 0, countRows() - 1, countCols() - 1); // selectAll
- keyDownUp('ctrl');
- expect(result).toEqual([4, 5, 2, 2]);
- });
- it('ctrl+x should cut selected data', _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
- var hot;
- return regeneratorRuntime.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- hot = handsontable({
- data: arrayOfArrays()
- });
- selectCell(0, 0, countRows() - 1, countCols() - 1); // selectAll
- keyDownUp('ctrl+x');
- _context.next = 5;
- return sleep(300);
- case 5:
- expect(hot.getDataAtCell(0, 0)).toEqual('');
- expect(hot.getDataAtCell(1, 1)).toEqual('');
- expect(hot.getDataAtCell(2, 2)).toEqual('');
- case 8:
- case 'end':
- return _context.stop();
- }
- }
- }, _callee, undefined);
- })));
- it('ctrl+v should paste copied data to selected range', _asyncToGenerator(regeneratorRuntime.mark(function _callee2() {
- var hot;
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- hot = handsontable({
- data: arrayOfArrays()
- });
- $('textarea.copyPaste').val('\tKia\tNissan\tToyota\tHonda\n2008\t10\t11\t12\t13');
- selectCell(0, 0, countRows() - 1, countCols() - 1); // selectAll
- keyDownUp('ctrl+v');
- _context2.next = 6;
- return sleep(200);
- case 6:
- expect(hot.getDataAtCell(0, 0)).toEqual('');
- expect(hot.getDataAtCell(0, 1)).toEqual('Kia');
- expect(hot.getDataAtCell(0, 2)).toEqual('Nissan');
- expect(hot.getDataAtCell(0, 3)).toEqual('Toyota');
- expect(hot.getDataAtCell(1, 0)).toEqual('2008');
- expect(hot.getDataAtCell(1, 1)).toEqual('10');
- expect(hot.getDataAtCell(1, 2)).toEqual('11');
- expect(hot.getDataAtCell(1, 3)).toEqual('12');
- case 14:
- case 'end':
- return _context2.stop();
- }
- }
- }, _callee2, undefined);
- })));
- });
- /***/ }),
- /* 154 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_count', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- destroy();
- this.$container.remove();
- });
- describe('countVisibleRows', function () {
- it('should return number of visible rows', function () {
- var instance = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- height: 100,
- width: 600
- });
- expect(instance.countVisibleRows()).toEqual(4);
- });
- it('should return -1 if table is not rendered', function () {
- this.$container.remove();
- var instance = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- width: 100
- });
- expect(instance.countVisibleRows()).toEqual(-1);
- });
- });
- describe('countRenderedRows', function () {
- it('should return number of rendered rows', function () {
- var instance = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- height: 100,
- viewportRowRenderingOffset: 0
- });
- expect(instance.countRenderedRows()).toEqual(5);
- });
- it('should return number of rendered rows, including rows rendered becausee of viewportRowRenderingOffset', function () {
- var instance = handsontable({
- data: Handsontable.helper.createSpreadsheetData(50, 10),
- height: 100,
- viewportRowRenderingOffset: 20
- });
- expect(instance.countRenderedRows()).toEqual(25);
- });
- it('should return -1 if table is not rendered', function () {
- this.$container.remove();
- var instance = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- width: 100
- });
- expect(instance.countRenderedRows()).toEqual(-1);
- });
- });
- describe('countVisibleCols', function () {
- it('should return number of visible columns', function () {
- var instance = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- width: 100
- });
- expect(instance.countVisibleCols()).toEqual(10);
- });
- it('should return -1 if table is not rendered', function () {
- this.$container.remove();
- var instance = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- width: 100
- });
- expect(instance.countVisibleCols()).toEqual(-1);
- });
- });
- });
- /***/ }),
- /* 155 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_dataSchema', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should be equal to `hot.getSchema()` when dataSchema is defined in settings (as object)', function () {
- var schema = { id: null, name: { first: null, last: null }, cars: [{ brand: null }] },
- hot = handsontable({
- data: [],
- dataSchema: schema,
- minRows: 5,
- minCols: 4,
- colHeaders: ['ID', 'First Name', 'Last Name'],
- columns: [{ data: 'id' }, { data: 'name.first' }, { data: 'name.last' }],
- minSpareRows: 1
- });
- expect(JSON.stringify(hot.getSchema())).toEqual(JSON.stringify(schema));
- });
- it('should be equal to `hot.getSchema()` when dataSchema is defined in settings (as object) when columns is a function', function () {
- var schema = { id: null, name: { first: null, last: null }, cars: [{ brand: null }] },
- hot = handsontable({
- data: [],
- dataSchema: schema,
- minRows: 5,
- minCols: 4,
- colHeaders: ['ID', 'First Name', 'Last Name'],
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = 'id';
- } else if (column === 1) {
- colMeta.data = 'name.first';
- } else if (column === 2) {
- colMeta.data = 'name.last';
- } else {
- colMeta = null;
- }
- return colMeta;
- },
- minSpareRows: 1
- });
- expect(JSON.stringify(hot.getSchema())).toEqual(JSON.stringify(schema));
- });
- it('should be equal to `hot.getSchema()` when dataSchema is defined in settings (as function)', function () {
- var schema = { id: null, name: { first: null, last: null }, cars: [{ brand: null }] },
- hot = handsontable({
- data: [],
- dataSchema: function dataSchema() {
- return schema;
- },
- minRows: 5,
- minCols: 4,
- colHeaders: ['ID', 'First Name', 'Last Name'],
- columns: [{ data: 'id' }, { data: 'name.first' }, { data: 'name.last' }],
- minSpareRows: 1
- });
- expect(JSON.stringify(hot.getSchema())).toEqual(JSON.stringify(schema));
- });
- it('should be equal to `hot.getSchema()` when dataSchema is defined in settings (as function) when columns is a function', function () {
- var schema = { id: null, name: { first: null, last: null }, cars: [{ brand: null }] },
- hot = handsontable({
- data: [],
- dataSchema: function dataSchema() {
- return schema;
- },
- minRows: 5,
- minCols: 4,
- colHeaders: ['ID', 'First Name', 'Last Name'],
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = 'id';
- } else if (column === 1) {
- colMeta.data = 'name.first';
- } else if (column === 2) {
- colMeta.data = 'name.last';
- } else {
- colMeta = null;
- }
- return colMeta;
- },
- minSpareRows: 1
- });
- expect(JSON.stringify(hot.getSchema())).toEqual(JSON.stringify(schema));
- });
- it('should be equal to `hot.getSchema()` when dataSchema is generated based on data structure', function () {
- var hot = handsontable({
- data: [{ id: 1, name: { first: 'Alan', last: 'Pakoli' }, cars: [{ brand: 'Ford' }] }],
- minRows: 5,
- minCols: 4,
- colHeaders: ['ID', 'First Name', 'Last Name'],
- columns: [{ data: 'id' }, { data: 'name.first' }, { data: 'name.last' }],
- minSpareRows: 1
- });
- expect(JSON.stringify(hot.getSchema())).toEqual(JSON.stringify({ id: null, name: { first: null, last: null }, cars: [{ brand: null }] }));
- });
- it('should be equal to `hot.getSchema()` when dataSchema is generated based on data structure when columns is a function', function () {
- var hot = handsontable({
- data: [{ id: 1, name: { first: 'Alan', last: 'Pakoli' }, cars: [{ brand: 'Ford' }] }],
- minRows: 5,
- minCols: 4,
- colHeaders: ['ID', 'First Name', 'Last Name'],
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = 'id';
- } else if (column === 1) {
- colMeta.data = 'name.first';
- } else if (column === 2) {
- colMeta.data = 'name.last';
- } else {
- colMeta = null;
- }
- return colMeta;
- },
- minSpareRows: 1
- });
- expect(JSON.stringify(hot.getSchema())).toEqual(JSON.stringify({ id: null, name: { first: null, last: null }, cars: [{ brand: null }] }));
- });
- it('should create new row from dataSchema', function () {
- handsontable({
- data: [],
- dataSchema: { id: null, name: { first: null, last: null }, address: null },
- minRows: 5,
- minCols: 4,
- colHeaders: ['ID', 'First Name', 'Last Name', 'Address'],
- columns: [{ data: 'id' }, { data: 'name.first' }, { data: 'name.last' }, { data: 'address' }],
- minSpareRows: 1
- });
- selectCell(0, 1);
- keyDownUp('enter');
- keyProxy().val('Ted');
- keyDownUp('enter');
- expect(getData()[0][1]).toEqual('Ted');
- expect(getSourceData()[0].name.first).toEqual('Ted');
- });
- it('should create new row from dataSchema when columns is a function', function () {
- handsontable({
- data: [],
- dataSchema: { id: null, name: { first: null, last: null }, address: null },
- minRows: 5,
- minCols: 4,
- colHeaders: ['ID', 'First Name', 'Last Name', 'Address'],
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = 'id';
- } else if (column === 1) {
- colMeta.data = 'name.first';
- } else if (column === 2) {
- colMeta.data = 'name.last';
- } else if (column === 3) {
- colMeta.data = 'address';
- } else {
- colMeta = null;
- }
- return colMeta;
- },
- minSpareRows: 1
- });
- selectCell(0, 1);
- keyDownUp('enter');
- keyProxy().val('Ted');
- keyDownUp('enter');
- expect(getData()[0][1]).toEqual('Ted');
- expect(getSourceData()[0].name.first).toEqual('Ted');
- });
- it('should create new row from dataSchema (functional)', function () {
- handsontable({
- data: [],
- dataSchema: function dataSchema(index) {
- return { id: 1000 + index, name: { first: null, last: null }, address: null };
- },
- isEmptyRow: function isEmptyRow(r) {
- var row = this.getSourceData()[r];
- return (row.name.first === null || row.name.first === '') && (row.name.last === null || row.name.last === '') && (row.address === null || row.address === '');
- },
- minRows: 5,
- minCols: 4,
- colHeaders: ['ID', 'First Name', 'Last Name', 'Address'],
- columns: [{ data: 'id' }, { data: 'name.first' }, { data: 'name.last' }, { data: 'address' }],
- minSpareRows: 1
- });
- selectCell(4, 1);
- expect(countRows()).toEqual(5);
- keyDownUp('enter');
- keyProxy().val('Ted');
- // need it in next frame as long as HT is rendered in async
- keyDownUp('enter');
- // need it in next frame as long as HT is rendered in async
- keyDownUp('enter');
- expect(getSourceData()[4].name.first).toEqual('Ted');
- expect(getSourceData()[4].id).toEqual(1004);
- expect(getData()[4][1]).toEqual('Ted');
- expect(getData()[4][0]).toEqual(1004);
- expect(countRows()).toEqual(6); // row should be added by keepEmptyRows
- });
- it('should create new row from dataSchema (functional) when columns is a function', function () {
- handsontable({
- data: [],
- dataSchema: function dataSchema(index) {
- return { id: 1000 + index, name: { first: null, last: null }, address: null };
- },
- isEmptyRow: function isEmptyRow(r) {
- var row = this.getSourceData()[r];
- return (row.name.first === null || row.name.first === '') && (row.name.last === null || row.name.last === '') && (row.address === null || row.address === '');
- },
- minRows: 5,
- minCols: 4,
- colHeaders: ['ID', 'First Name', 'Last Name', 'Address'],
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = 'id';
- } else if (column === 1) {
- colMeta.data = 'name.first';
- } else if (column === 2) {
- colMeta.data = 'name.last';
- } else if (column === 3) {
- colMeta.data = 'address';
- } else {
- colMeta = null;
- }
- return colMeta;
- },
- minSpareRows: 1
- });
- selectCell(4, 1);
- expect(countRows()).toEqual(5);
- keyDownUp('enter');
- keyProxy().val('Ted');
- // need it in next frame as long as HT is rendered in async
- keyDownUp('enter');
- // need it in next frame as long as HT is rendered in async
- keyDownUp('enter');
- expect(getSourceData()[4].name.first).toEqual('Ted');
- expect(getSourceData()[4].id).toEqual(1004);
- expect(getData()[4][1]).toEqual('Ted');
- expect(getData()[4][0]).toEqual(1004);
- expect(countRows()).toEqual(6); // row should be added by keepEmptyRows
- });
- it('should translate prop to col, when prop is a function', function () {
- var idAccessor = createAccessorForProperty('id');
- var nameAccessor = createAccessorForProperty('name');
- hot = handsontable({
- data: [Model({
- id: 1,
- name: 'Tom'
- }), Model({
- id: 2,
- name: 'Hanna'
- }), Model({
- id: 3,
- name: 'Jerry'
- })],
- dataSchema: Model,
- columns: [{
- data: idAccessor
- }, {
- data: nameAccessor
- }]
- });
- expect(hot.propToCol(idAccessor)).toEqual(0);
- expect(hot.propToCol(nameAccessor)).toEqual(1);
- });
- it('should translate prop to col, when prop and columns is a function', function () {
- var idAccessor = createAccessorForProperty('id');
- var nameAccessor = createAccessorForProperty('name');
- hot = handsontable({
- data: [Model({
- id: 1,
- name: 'Tom'
- }), Model({
- id: 2,
- name: 'Hanna'
- }), Model({
- id: 3,
- name: 'Jerry'
- })],
- dataSchema: Model,
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = idAccessor;
- } else if (column === 1) {
- colMeta.data = nameAccessor;
- } else {
- colMeta = null;
- }
- return colMeta;
- }
- });
- expect(hot.propToCol(idAccessor)).toEqual(0);
- expect(hot.propToCol(nameAccessor)).toEqual(1);
- });
- it('should create new row data matched to dataSchema (data type as `array`)', function () {
- var spy = jasmine.createSpy();
- var hot = handsontable({
- data: [[{ id: 1 }]],
- dataSchema: [{ id: null }],
- columns: [{ data: '0', renderer: spy }],
- autoColumnSize: false,
- autoRowSize: false
- });
- expect(spy.calls.count()).toBe(1);
- expect(spy.calls.argsFor(0)[5]).toEqual({ id: 1 });
- spy.calls.reset();
- hot.alter('insert_row', 0);
- expect(spy.calls.count()).toBe(2);
- expect(spy.calls.argsFor(0)[5]).toEqual({ id: null });
- expect(spy.calls.argsFor(1)[5]).toEqual({ id: 1 });
- });
- it('should create new row data matched to dataSchema (data type as `array`) when columns is a function', function () {
- var spy = jasmine.createSpy();
- var hot = handsontable({
- data: [[{ id: 1 }]],
- dataSchema: [{ id: null }],
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = '0';
- colMeta.renderer = spy;
- } else {
- colMeta = null;
- }
- return colMeta;
- },
- autoColumnSize: false,
- autoRowSize: false
- });
- expect(spy.calls.count()).toBe(1);
- expect(spy.calls.argsFor(0)[5]).toEqual({ id: 1 });
- spy.calls.reset();
- hot.alter('insert_row', 0);
- expect(spy.calls.count()).toBe(2);
- expect(spy.calls.argsFor(0)[5]).toEqual({ id: null });
- expect(spy.calls.argsFor(1)[5]).toEqual({ id: 1 });
- });
- it('should create an array of objects as the source structure, when dataSchema is defined (as an object) but no data is provided', function () {
- var hot = handsontable({
- startCols: 2,
- minSpareRows: 4,
- dataSchema: { id: null, name: null, surname: null }
- });
- var dataAtRow = hot.getSourceDataAtRow(0);
- expect(Array.isArray(dataAtRow)).toBe(false);
- expect(dataAtRow.id).toEqual(null);
- expect(dataAtRow.name).toEqual(null);
- expect(dataAtRow.surname).toEqual(null);
- });
- it('should create an array of objects as the source structure, when dataSchema is defined (as a function) but no data is provided', function () {
- var hot = handsontable({
- startCols: 2,
- minSpareRows: 4,
- dataSchema: function dataSchema() {
- return { id: null, name: null, surname: null };
- }
- });
- var dataAtRow = hot.getSourceDataAtRow(0);
- expect(Array.isArray(dataAtRow)).toBe(false);
- expect(dataAtRow.id).toEqual(null);
- expect(dataAtRow.name).toEqual(null);
- expect(dataAtRow.surname).toEqual(null);
- });
- it('should create an array of objects as the source structure, when dataSchema is defined (as an array with an object) but no data is provided', function () {
- var hot = handsontable({
- startCols: 2,
- minSpareRows: 4,
- dataSchema: [{ id: null, name: null, surname: null }]
- });
- var dataAtRow = hot.getSourceDataAtRow(0);
- expect(Array.isArray(dataAtRow)).toBe(false);
- expect(dataAtRow.id).toEqual(null);
- expect(dataAtRow.name).toEqual(null);
- expect(dataAtRow.surname).toEqual(null);
- });
- });
- /***/ }),
- /* 156 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_datachange', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should call onChange callback', function () {
- var output = null;
- handsontable({
- afterChange: function afterChange(changes) {
- output = changes;
- }
- });
- setDataAtCell(1, 2, 'test');
- expect(output[0][0]).toEqual(1);
- expect(output[0][1]).toEqual(2);
- expect(output[0][2]).toEqual(null);
- expect(output[0][3]).toEqual('test');
- });
- it('should use custom source for datachange', function () {
- var output = null,
- src = null;
- handsontable({
- afterChange: function afterChange(changes, source) {
- output = changes;
- src = source;
- }
- });
- setDataAtCell(1, 2, 'abc', 'test');
- expect(output[0][3]).toEqual('abc');
- expect(src).toEqual('test');
- });
- it('should use custom source for datachange with array', function () {
- var output = null,
- src = null;
- handsontable({
- afterChange: function afterChange(changes, source) {
- output = changes;
- src = source;
- }
- });
- setDataAtCell([[1, 2, 'abc']], 'test');
- expect(output[0][3]).toEqual('abc');
- expect(src).toEqual('test');
- });
- it('should trigger datachange event', function () {
- var output = null;
- handsontable();
- Handsontable.hooks.add('afterChange', function (changes) {
- output = changes;
- });
- setDataAtCell(1, 2, 'test');
- expect(output[0][0]).toEqual(1);
- expect(output[0][1]).toEqual(2);
- expect(output[0][2]).toEqual(null);
- expect(output[0][3]).toEqual('test');
- });
- it('this.rootElement should point to handsontable rootElement', function () {
- var output = null;
- var $container = this.$container;
- handsontable({
- afterChange: function afterChange() {
- output = this.rootElement;
- }
- });
- setDataAtCell(0, 0, 'test');
- expect(output).toEqual($container[0]);
- });
- it('onChange should be triggered after data is rendered to DOM (init)', function () {
- var output = null;
- var $container = this.$container;
- handsontable({
- data: [['Joe Red']],
- afterChange: function afterChange(changes, source) {
- if (source === 'loadData') {
- output = $container.find('table.htCore tbody td:first').html();
- }
- }
- });
- expect(output).toEqual('Joe Red');
- });
- it('onChange should be triggered after data is rendered to DOM (setDataAtCell)', function () {
- var output = null;
- var $container = this.$container;
- handsontable({
- data: [['Joe Red']],
- afterChange: function afterChange(changes, source) {
- if (source === 'edit') {
- output = $container.find('table.htCore tbody td:first').html();
- }
- }
- });
- setDataAtCell(0, 0, 'Alice Red');
- expect(output).toEqual('Alice Red');
- });
- it('onChange event object should contain documented keys and values when triggered by edit', function () {
- var sampleData = [{
- col1: 'a',
- col2: 'b',
- col3: 'c'
- }];
- var event = null;
- handsontable({
- data: sampleData,
- afterChange: function afterChange(changes, source) {
- if (source === 'edit') {
- event = changes.shift();
- }
- }
- });
- setDataAtCell(0, 0, 'test');
- expect(event[0]).toEqual(0);
- expect(event[1]).toEqual('col1');
- expect(event[2]).toEqual('a');
- expect(event[3]).toEqual('test');
- });
- it('source parameter should be `edit` when cell value is changed through editor', function () {
- var sources = [];
- handsontable({
- data: [['Joe Red']],
- afterChange: function afterChange(changes, source) {
- sources.push(source);
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'Ted';
- keyDown('enter');
- expect(sources).toEqual(['loadData', 'edit']); // loadData is always the first source
- });
- });
- /***/ }),
- /* 157 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_destroy', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should remove table from the root element', function () {
- handsontable();
- destroy();
- expect(this.$container.html()).toEqual('');
- });
- it('should remove events from the root element, document element and window', function () {
- var x = handsontable();
- expect(x.eventListeners.length > 0).toBeTruthy();
- destroy();
- expect(x.eventListeners).toBeNull();
- $(document.documentElement).off('.copypaste'); // remove copypaste.js listeners, which are not removed by destroy (because copypaste is a singleton for whole page)
- });
- it('should NOT remove events from document element and window for other Handsontable instances on the page', function () {
- // test based on Core_selectionSpec.js (should deselect currently selected cell)
- handsontable();
- var $tmp = $('<div id="tmp"></div>').appendTo(document.body);
- $tmp.handsontable();
- $tmp.handsontable('destroy');
- $tmp.remove();
- selectCell(0, 0);
- $('html').simulate('mousedown');
- expect(getSelected()).toBeUndefined();
- });
- });
- /***/ }),
- /* 158 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_destroyEditor', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('editor should not be visible', function () {
- handsontable();
- selectCell(1, 1);
- keyDownUp('enter');
- destroyEditor();
- expect(isEditorVisible()).toEqual(false);
- });
- it('value should be saved', function () {
- handsontable();
- selectCell(1, 1);
- keyDownUp('enter');
- keyProxy().val('Ted');
- destroyEditor();
- expect(getDataAtCell(1, 1)).toEqual('Ted');
- });
- it('cell should be selected', function () {
- handsontable();
- selectCell(1, 1);
- keyDownUp('enter');
- destroyEditor();
- expect(getSelected()).toEqual([1, 1, 1, 1]);
- });
- it('should revert original value when param set to true', function () {
- handsontable();
- selectCell(1, 1);
- keyDownUp('enter');
- keyProxy().val('Ted');
- destroyEditor(true);
- expect(getDataAtCell(1, 1)).toEqual(null);
- });
- it('should not destroy editor on scroll', function () {
- this.$container.css({
- width: 200,
- height: 100
- });
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(20, 10)
- });
- selectCell(0, 0);
- keyDown('enter');
- var editor = $('.handsontableInputHolder');
- expect(editor.is(':visible')).toBe(true);
- this.$container.scroll();
- expect(editor.is(':visible')).toBe(true);
- });
- });
- /***/ }),
- /* 159 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_getCellMeta', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should not allow manual editing of a read only cell', function () {
- var allCellsReadOnly = false;
- handsontable({
- cells: function cells() {
- return { readOnly: allCellsReadOnly };
- }
- });
- allCellsReadOnly = true;
- selectCell(2, 2);
- keyDown('enter');
- expect(isEditorVisible()).toEqual(false);
- });
- it('should allow manual editing of cell that is no longer read only', function () {
- var allCellsReadOnly = true;
- handsontable({
- cells: function cells() {
- return { readOnly: allCellsReadOnly };
- }
- });
- allCellsReadOnly = false;
- selectCell(2, 2);
- keyDown('enter');
- expect(isEditorVisible()).toEqual(true);
- });
- it('should move the selection to the cell below, when hitting the ENTER key on a read-only cell', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 3),
- cells: function cells() {
- return { readOnly: true };
- }
- });
- selectCell(0, 0);
- expect(getCellMeta(0, 0).readOnly).toBe(true);
- keyDown('enter');
- expect(getSelected()).toEqual([1, 0, 1, 0]);
- });
- it('should use default cell editor for a cell that has declared only cell renderer', function () {
- handsontable({
- cells: function cells() {
- return {
- renderer: function renderer(instance, td, row, col, prop, value, cellProperties) {
- // taken from demo/renderers.html
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- $(td).css({
- background: 'yellow'
- });
- }
- };
- }
- });
- selectCell(2, 2);
- keyDown('enter');
- document.activeElement.value = 'new value';
- destroyEditor();
- expect(getDataAtCell(2, 2)).toEqual('new value');
- });
- it('should allow to use type and renderer in `flat` notation', function () {
- handsontable({
- data: [[1, 2, 3, 4], [5, 6, 7, 8], [0, 9, 8, 7]],
- cells: function cells(row, col) {
- if (row === 2 && col === 2) {
- return {
- type: 'checkbox',
- renderer: function renderer(instance, td, row, col, prop, value, cellProperties) {
- // taken from demo/renderers.html
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- td.style.backgroundColor = 'yellow';
- }
- };
- }
- }
- });
- expect(getCell(2, 2).style.backgroundColor).toEqual('yellow');
- expect(getCell(1, 1).style.backgroundColor).toEqual('');
- });
- it('this in cells should point to cellProperties', function () {
- var called = 0,
- _row,
- _this;
- handsontable({
- cells: function cells(row, col, prop) {
- called++;
- _row = row;
- _this = this;
- }
- });
- var HOT = getInstance();
- expect(called).toBeGreaterThan(0);
- expect(_this.row).toEqual(_row);
- expect(_this.instance).toBe(HOT);
- });
- it('should get proper cellProperties when order of displayed rows is different than order of stored data', function () {
- var hot = handsontable({
- data: [['C'], ['A'], ['B']],
- minSpareRows: 1,
- cells: function cells(row, col, prop) {
- var cellProperties = {};
- if (getSourceData()[row][col] === 'A') {
- cellProperties.readOnly = true;
- }
- return cellProperties;
- }
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('C');
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').hasClass('htDimmed')).toBe(false);
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('A');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').hasClass('htDimmed')).toBe(true);
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('B');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').hasClass('htDimmed')).toBe(false);
- // Column sorting changes the order of displayed rows while keeping table data unchanged
- updateSettings({
- columnSorting: {
- column: 0,
- sortOrder: true
- }
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A');
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').hasClass('htDimmed')).toBe(true);
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('B');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').hasClass('htDimmed')).toBe(false);
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('C');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').hasClass('htDimmed')).toBe(false);
- });
- });
- /***/ }),
- /* 160 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.getColHeader', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('when not configured, should return undefined', function () {
- handsontable();
- expect(getColHeader(1)).toBe(null);
- });
- it('when configured as true, should return the Excel-style column title', function () {
- handsontable({
- colHeaders: true
- });
- expect(getColHeader(30)).toEqual('AE');
- });
- it('when configured as array, should return value at index', function () {
- handsontable({
- colHeaders: ['One', 'Two', 'Three', 'Four', 'Five']
- });
- expect(getColHeader(1)).toEqual('Two');
- });
- it('when configured as function, should return function output', function () {
- handsontable({
- colHeaders: function colHeaders(index) {
- return 'col' + index;
- }
- });
- expect(getColHeader(1)).toEqual('col1');
- });
- it('when configured as static value, should return the value', function () {
- handsontable({
- colHeaders: 'static'
- });
- expect(getColHeader(1)).toEqual('static');
- });
- it('when configured as HTML value, should render that as HTML', function () {
- handsontable({
- colHeaders: function colHeaders(index) {
- return '<b>col' + index + '</b>';
- }
- });
- expect(getColHeader(1)).toEqual('<b>col1</b>');
- });
- it('when no argument given, should return as much column headers as there are columns', function () {
- handsontable({
- colHeaders: true,
- startCols: 3
- });
- expect(getColHeader()).toEqual(['A', 'B', 'C']);
- });
- });
- /***/ }),
- /* 161 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_getDataAt*', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfArrays = function arrayOfArrays() {
- return [['', 'Kia', 'Nissan', 'Toyota', 'Honda'], ['2008', 10, 11, 12, 13], ['2009', 20, 11, 14, 13], ['2010', 30, 15, 12, 13]];
- };
- var arrayOfObjects = function arrayOfObjects() {
- return [{
- 'id.a.b.c': 1,
- id: 1,
- name: 'Nannie Patel',
- address: 'Jenkin ville',
- details: {
- city: 'Chicago'
- }
- }, {
- 'id.a.b.c': 2,
- id: 2,
- name: 'Łucja Grożny and Środeńczak',
- address: 'Gardiner',
- details: {
- city: 'New York'
- }
- }];
- };
- it('should return data at specified row', function () {
- handsontable({
- data: arrayOfArrays()
- });
- expect(getDataAtRow(0)).toEqual(['', 'Kia', 'Nissan', 'Toyota', 'Honda']);
- });
- it('should return data at specified col', function () {
- handsontable({
- data: arrayOfArrays()
- });
- expect(getDataAtCol(1)).toEqual(['Kia', 10, 20, 30]);
- });
- describe('Core_getDataAtRowProp', function () {
- it('should return data at specified column', function () {
- handsontable({
- data: arrayOfObjects()
- });
- expect(getDataAtRowProp(1, 'id.a.b.c')).toBe(2);
- expect(getDataAtRowProp(1, 'id')).toBe(2);
- expect(getDataAtRowProp(1, 'id')).toBe(2);
- expect(getDataAtRowProp(1, 'details.city')).toBe('New York');
- });
- });
- describe('`modifyData` hook', function () {
- it('should be fired with specified arguments on every `set`, `get` operation (array of arrays)', function () {
- var spy = jasmine.createSpy();
- handsontable({
- data: arrayOfArrays(),
- autoColumnSize: false,
- modifyData: spy
- });
- expect(spy.calls.count()).toBe(20); // call for all cells
- expect(spy.calls.argsFor(1)[0]).toBe(0);
- expect(spy.calls.argsFor(1)[1]).toBe(1);
- expect(spy.calls.argsFor(1)[2].value).toBe('Kia');
- expect(spy.calls.argsFor(1)[3]).toBe('get');
- spy.calls.reset();
- setDataAtCell(2, 3, 'foo');
- expect(spy.calls.count()).toBe(21); // call for all cells + 1 from setDataAtCell
- expect(spy.calls.argsFor(0)[0]).toBe(2);
- expect(spy.calls.argsFor(0)[1]).toBe(3);
- expect(spy.calls.argsFor(0)[2].value).toBe('foo');
- expect(spy.calls.argsFor(0)[3]).toBe('set');
- });
- it('should be fired with specified arguments on every `set`, `get` operation (array of objects)', function () {
- var spy = jasmine.createSpy();
- handsontable({
- data: arrayOfObjects(),
- autoColumnSize: false,
- modifyData: spy
- });
- expect(spy.calls.count()).toBe(10); // call for all cells
- expect(spy.calls.argsFor(2)[0]).toBe(0);
- expect(spy.calls.argsFor(2)[1]).toBe(2);
- expect(spy.calls.argsFor(2)[2].value).toBe('Nannie Patel');
- expect(spy.calls.argsFor(2)[3]).toBe('get');
- spy.calls.reset();
- setDataAtRowProp(2, 'name', 'foo');
- expect(spy.calls.count()).toBe(16);
- expect(spy.calls.argsFor(0)[0]).toBe(2);
- expect(spy.calls.argsFor(0)[1]).toBe(2);
- expect(spy.calls.argsFor(0)[2].value).toBe('foo');
- expect(spy.calls.argsFor(0)[3]).toBe('set');
- });
- it('should overwrite value while loading data', function () {
- handsontable({
- data: arrayOfArrays(),
- modifyData: function modifyData(row, column, valueHolder, ioMode) {
- if (ioMode === 'get' && row === 1 && column === 2) {
- valueHolder.value = 'foo';
- }
- }
- });
- expect(getDataAtCell(1, 2)).toBe('foo');
- expect(getSourceDataAtCell(1, 2)).toBe(11);
- });
- it('should overwrite value while saving data', function () {
- handsontable({
- data: arrayOfArrays(),
- modifyData: function modifyData(row, column, valueHolder, ioMode) {
- if (ioMode === 'set' && row === 1 && column === 2) {
- valueHolder.value = 'foo';
- }
- }
- });
- setDataAtCell(1, 2, 'bar');
- expect(getDataAtCell(1, 2)).toBe('foo');
- expect(getSourceDataAtCell(1, 2)).toBe('foo');
- });
- });
- });
- /***/ }),
- /* 162 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_getDataType', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfArrays = function arrayOfArrays() {
- return [['', 'Kia', 'Nissan', 'Toyota', 'Honda'], ['2008', 10, 11, 12, 13], ['2009', 20, 11, 14, 13], ['2010', 30, 15, 12, 13]];
- };
- it('should return data type at specyfied range (default type)', function () {
- handsontable({
- data: arrayOfArrays()
- });
- expect(getDataType(0, 0)).toEqual('text');
- expect(getDataType(0, 0, 1, 1)).toEqual('text');
- });
- it('should return data type at specyfied range (type defined in columns)', function () {
- handsontable({
- data: arrayOfArrays(),
- columns: [{ type: 'numeric' }, { type: 'text' }, { type: 'date' }, { type: 'autocomplete' }, { type: 'dropdown' }]
- });
- expect(getDataType(0, 0)).toEqual('numeric');
- expect(getDataType(0, 0, 1, 1)).toEqual('mixed');
- expect(getDataType(0, 1, 1, 1)).toEqual('text');
- expect(getDataType(0, 2, 1, 2)).toEqual('date');
- expect(getDataType(3, 3, 3, 3)).toEqual('autocomplete');
- expect(getDataType(3, 4, 3, 4)).toEqual('dropdown');
- });
- it('should return data type at specyfied range (type defined in columns) when columns is a function', function () {
- handsontable({
- data: arrayOfArrays(),
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.type = 'numeric';
- } else if (column === 1) {
- colMeta.type = 'text';
- } else if (column === 2) {
- colMeta.type = 'date';
- } else if (column === 3) {
- colMeta.type = 'autocomplete';
- } else if (column === 4) {
- colMeta.type = 'dropdown';
- } else {
- colMeta = null;
- }
- return colMeta;
- }
- });
- expect(getDataType(0, 0)).toEqual('numeric');
- expect(getDataType(0, 0, 1, 1)).toEqual('mixed');
- expect(getDataType(0, 1, 1, 1)).toEqual('text');
- expect(getDataType(0, 2, 1, 2)).toEqual('date');
- expect(getDataType(3, 3, 3, 3)).toEqual('autocomplete');
- expect(getDataType(3, 4, 3, 4)).toEqual('dropdown');
- });
- it('should return data type at specyfied range (type defined in cells)', function () {
- handsontable({
- data: arrayOfArrays(),
- cells: function cells(row, column) {
- var cellMeta = {};
- if (row === 1 && column === 1) {
- cellMeta.type = 'date';
- }
- if (column === 2) {
- cellMeta.type = 'checkbox';
- }
- return cellMeta;
- }
- });
- expect(getDataType(0, 0)).toEqual('text');
- expect(getDataType(1, 1)).toEqual('date');
- expect(getDataType(1, 2)).toEqual('checkbox');
- expect(getDataType(0, 0, 1, 1)).toEqual('mixed');
- });
- });
- /***/ }),
- /* 163 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.getRowHeader', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('when not configured, should return undefined', function () {
- handsontable();
- expect(getRowHeader(1)).toEqual(void 0);
- });
- it('when configured as true, should return the index incremented by 1', function () {
- handsontable({
- rowHeaders: true
- });
- expect(getRowHeader(1)).toEqual(2);
- });
- it('when configured as array, should return value at index', function () {
- handsontable({
- rowHeaders: ['One', 'Two', 'Three', 'Four', 'Five']
- });
- expect(getRowHeader(1)).toEqual('Two');
- });
- it('when configured as function, should return function output', function () {
- handsontable({
- rowHeaders: function rowHeaders(index) {
- return 'row' + index;
- }
- });
- expect(getRowHeader(1)).toEqual('row1');
- });
- it('when configured as static value, should return the value', function () {
- handsontable({
- rowHeaders: 'static'
- });
- expect(getRowHeader(1)).toEqual('static');
- });
- it('when configured as HTML value, should render that as HTML', function () {
- handsontable({
- rowHeaders: function rowHeaders(index) {
- return '<b>row' + index + '</b>';
- }
- });
- expect(getRowHeader(1)).toEqual('<b>row1</b>');
- });
- it('when no argument given, should return as much row headers as there are rows', function () {
- handsontable({
- rowHeaders: true,
- startRows: 3
- });
- expect(getRowHeader()).toEqual([1, 2, 3]);
- });
- });
- /***/ }),
- /* 164 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_init', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should respect startRows and startCols when no data is provided', function () {
- this.$container.remove();
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- handsontable();
- expect(countRows()).toEqual(5); // as given in README.md
- expect(countCols()).toEqual(5); // as given in README.md
- });
- it('should respect width provided in inline style', function () {
- this.$container.css({
- overflow: 'auto',
- width: '200px'
- });
- handsontable({
- data: [['ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC']]
- });
- expect(this.$container.width()).toEqual(200);
- });
- it('should respect width provided in CSS class', function () {
- $('<style>.myTable {overflow: auto; width: 200px}</style>').appendTo('head');
- this.$container.addClass('myTable');
- handsontable({
- data: [['ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC', 'ABC']]
- });
- expect(this.$container.width()).toEqual(200);
- });
- it('should construct when container is not appended to document', function () {
- this.$container.remove();
- handsontable();
- expect(getData()).toBeTruthy();
- });
- it('Handsontable.Dom should be available as a helper to the plugins', function () {
- // all public methods of Handsontable.Dom should be exposed here
- expect(Handsontable.dom.closest).toBeDefined();
- expect(Handsontable.dom.isChildOf).toBeDefined();
- expect(Handsontable.dom.index).toBeDefined();
- expect(Handsontable.dom.hasClass).toBeDefined();
- expect(Handsontable.dom.addClass).toBeDefined();
- expect(Handsontable.dom.removeClass).toBeDefined();
- expect(Handsontable.dom.removeTextNodes).toBeDefined();
- expect(Handsontable.dom.empty).toBeDefined();
- expect(Handsontable.dom.fastInnerHTML).toBeDefined();
- expect(Handsontable.dom.fastInnerText).toBeDefined();
- expect(Handsontable.dom.isVisible).toBeDefined();
- expect(Handsontable.dom.offset).toBeDefined();
- expect(Handsontable.dom.getComputedStyle).toBeDefined();
- expect(Handsontable.dom.outerWidth).toBeDefined();
- expect(Handsontable.dom.outerHeight).toBeDefined();
- expect(Handsontable.dom.getCaretPosition).toBeDefined();
- expect(Handsontable.dom.setCaretPosition).toBeDefined();
- });
- });
- /***/ }),
- /* 165 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.isEmpty*', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('isEmptyRow', function () {
- it('should be empty row', function () {
- handsontable();
- var hot = getInstance();
- expect(hot.isEmptyRow(0)).toEqual(true);
- });
- it('should not be empty row', function () {
- handsontable();
- setDataAtCell(0, 0, 'test');
- var hot = getInstance();
- expect(hot.isEmptyRow(0)).toEqual(false);
- });
- it('should bind this to instance', function () {
- handsontable();
- var hot = getInstance();
- var check = hot.isEmptyRow;
- expect(check(0)).toEqual(true); // this may be change in future when we switch to define isEmptyCol in prototype
- });
- });
- describe('isEmptyCol', function () {
- it('should be empty row', function () {
- handsontable();
- var hot = getInstance();
- expect(hot.isEmptyCol(0)).toEqual(true);
- });
- it('should not be empty row', function () {
- handsontable();
- setDataAtCell(0, 0, 'test');
- var hot = getInstance();
- expect(hot.isEmptyCol(0)).toEqual(false);
- });
- it('should bind this to instance', function () {
- handsontable();
- var hot = getInstance();
- var check = hot.isEmptyCol;
- expect(check(0)).toEqual(true); // this may be change in future when we switch to define isEmptyCol in prototype
- });
- });
- });
- /***/ }),
- /* 166 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_keepEmptyRows', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfNestedObjects = function arrayOfNestedObjects() {
- return [{ id: 1,
- name: {
- first: 'Ted',
- last: 'Right'
- },
- address: 'Street Name',
- zip: '80410',
- city: 'City Name' }, { id: 2,
- name: {
- first: 'Frank',
- last: 'Honest'
- },
- address: 'Street Name',
- zip: '80410',
- city: 'City Name' }, { id: 3,
- name: {
- first: 'Joan',
- last: 'Well'
- },
- address: 'Street Name',
- zip: '80410',
- city: 'City Name' }];
- };
- it('should remove columns if needed', function () {
- handsontable({
- data: arrayOfNestedObjects(),
- columns: [{ data: 'id' }, { data: 'name.first' }]
- });
- expect(this.$container.find('tbody tr:first td').length).toEqual(2);
- });
- it('should remove columns if needed when columns is a function', function () {
- handsontable({
- data: arrayOfNestedObjects(),
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = 'id';
- } else if (column === 1) {
- colMeta.data = 'name.first';
- } else {
- colMeta = null;
- }
- return colMeta;
- }
- });
- expect(this.$container.find('tbody tr:first td').length).toEqual(2);
- });
- it('should create columns if needed', function () {
- handsontable({
- data: arrayOfNestedObjects(),
- columns: [{ data: 'id' }, { data: 'name.first' }, { data: 'name.last' }, { data: 'address' }, { data: 'zip' }, { data: 'city' }]
- });
- expect(this.$container.find('tbody tr:first td').length).toEqual(6);
- });
- it('should create columns if needed when columns is a function', function () {
- handsontable({
- data: arrayOfNestedObjects(),
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = 'id';
- } else if (column === 1) {
- colMeta.data = 'name.first';
- } else if (column === 2) {
- colMeta.data = 'name.last';
- } else if (column === 3) {
- colMeta.data = 'address';
- } else if (column === 4) {
- colMeta.data = 'zip';
- } else if (column === 5) {
- colMeta.data = 'city';
- } else {
- colMeta = null;
- }
- return colMeta;
- }
- });
- expect(this.$container.find('tbody tr:first td').length).toEqual(6);
- });
- it('should create spare cols and rows on init (array data source)', function () {
- handsontable({
- data: [['one', 'two'], ['three', 'four']],
- minCols: 4,
- minRows: 4,
- minSpareRows: 4,
- minSpareCols: 4
- });
- expect(countCells()).toEqual(36);
- });
- it('should create spare cols and rows on init (object data source)', function () {
- handsontable({
- data: arrayOfNestedObjects(),
- minRows: 4,
- minSpareRows: 1
- });
- expect(countRows()).toEqual(4);
- expect(countCols()).toEqual(6); // because arrayOfNestedObjects has 6 nested properites and they should be figured out if dataSchema/columns is not given
- expect(this.$container.find('tbody tr:first td:last').text()).toEqual('City Name');
- });
- it('should create new row when last cell in last row is edited', function () {
- var data = [['one', 'two'], ['three', 'four']];
- handsontable({
- data: data,
- minRows: 4,
- minCols: 4,
- minSpareRows: 1
- });
- setDataAtCell(3, 3, 'test');
- expect(data.length).toEqual(5);
- });
- it('should create new col when last cell in last row is edited', function () {
- var data = [['one', 'two'], ['three', 'four']];
- handsontable({
- data: data,
- minRows: 4,
- minCols: 4,
- minSpareCols: 1
- });
- setDataAtCell(3, 3, 'test');
- expect(countCols()).toEqual(5);
- });
- it('should create new row when last cell in last row is edited by autocomplete', function (done) {
- var data = [{ id: 1, color: 'orange' }];
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(['red', 'dark-yellow', 'yellow', 'light-yellow', 'black']);
- });
- handsontable({
- data: data,
- startRows: 5,
- colHeaders: true,
- minSpareRows: 1,
- columns: [{ data: 'id', type: 'text' }, {
- data: 'color',
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(1, 1);
- keyDownUp('enter');
- setTimeout(function () {
- keyDown('arrow_down');
- keyDownUp('enter');
- expect(data.length).toEqual(3);
- done();
- }, 200);
- });
- it('should create new row when last cell in last row is edited by autocomplete when columns is a function', function (done) {
- var data = [{ id: 1, color: 'orange' }];
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(['red', 'dark-yellow', 'yellow', 'light-yellow', 'black']);
- });
- handsontable({
- data: data,
- startRows: 5,
- colHeaders: true,
- minSpareRows: 1,
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = 'id';
- colMeta.type = 'text';
- } else if (column === 1) {
- colMeta.data = 'color';
- colMeta.editor = 'autocomplete';
- colMeta.source = syncSources;
- } else {
- colMeta = null;
- }
- return colMeta;
- }
- });
- selectCell(1, 1);
- keyDownUp('enter');
- setTimeout(function () {
- keyDown('arrow_down');
- keyDownUp('enter');
- expect(data.length).toEqual(3);
- done();
- }, 200);
- });
- it('should not create more rows that maxRows', function () {
- handsontable({
- startRows: 4,
- maxRows: 6,
- minSpareRows: 1
- });
- setDataAtCell(3, 0, 'test');
- setDataAtCell(4, 0, 'test');
- setDataAtCell(5, 0, 'test');
- expect(countRows()).toEqual(6);
- });
- it('should not create more cols that maxCols', function () {
- handsontable({
- startCols: 4,
- maxCols: 6,
- minSpareCols: 1
- });
- setDataAtCell(0, 3, 'test');
- setDataAtCell(0, 4, 'test');
- setDataAtCell(0, 5, 'test');
- expect(countCols()).toEqual(6);
- });
- it('should ignore minCols if columns is set', function () {
- handsontable({
- startCols: 1,
- minCols: 6,
- columns: [{}, {}]
- });
- expect(countCols()).toEqual(2);
- });
- it('should ignore minCols if columns is set when columns is a function', function () {
- handsontable({
- startCols: 1,
- minCols: 6,
- columns: function columns(column) {
- var colMeta = {};
- if ([0, 1].indexOf(column) < 0) {
- colMeta = null;
- }
- return colMeta;
- }
- });
- expect(countCols()).toEqual(1);
- });
- it('columns should have priority over startCols', function () {
- handsontable({
- startCols: 3,
- minCols: 6,
- columns: [{}, {}]
- });
- expect(countCols()).toEqual(2);
- });
- it('columns should have priority over startCols when columns is a function', function () {
- handsontable({
- startCols: 3,
- minCols: 6,
- columns: function columns(column) {
- var colMeta = {};
- if ([0, 1].indexOf(column) < 0) {
- colMeta = null;
- }
- return colMeta;
- }
- });
- expect(countCols()).toEqual(2);
- });
- });
- /***/ }),
- /* 167 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_listen', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should listen to changes when cell is selected', function () {
- var hot = handsontable();
- hot.selectCell(0, 0);
- expect(hot.isListening()).toEqual(true);
- });
- it('should\'t listen to changes when cell is selected via `selectCell` when `changeListener` argument is `false`', function () {
- var hot = handsontable();
- hot.unlisten();
- expect(hot.isListening()).toEqual(false);
- hot.selectCell(0, 0, undefined, undefined, true, false);
- expect(hot.isListening()).toEqual(false);
- });
- it('should unlisten changes', function () {
- var hot = handsontable();
- hot.selectCell(0, 0);
- expect(hot.isListening()).toEqual(true);
- hot.unlisten();
- expect(hot.isListening()).toEqual(false);
- });
- it('should listen to changes, when called after unlisten', function () {
- var hot = handsontable();
- hot.selectCell(0, 0);
- hot.unlisten();
- hot.listen();
- expect(hot.isListening()).toEqual(true);
- });
- it('when second instance is created, first should unlisten automatically', function () {
- var $container1 = $('<div id="hot1"></div>').appendTo('body').handsontable();
- $container1.handsontable('selectCell', 0, 0);
- var $container2 = $('<div id="hot2"></div>').appendTo('body').handsontable();
- $container2.handsontable('selectCell', 0, 0);
- expect($container1.handsontable('isListening')).toEqual(false);
- expect($container2.handsontable('isListening')).toEqual(true);
- $container1.handsontable('destroy');
- $container1.remove();
- $container2.handsontable('destroy');
- $container2.remove();
- });
- it('when listen is called on first instance, second should unlisten automatically', function () {
- var $container1 = $('<div id="hot1"></div>').appendTo('body').handsontable();
- $container1.handsontable('selectCell', 0, 0);
- var $container2 = $('<div id="hot2"></div>').appendTo('body').handsontable();
- $container2.handsontable('selectCell', 0, 0);
- $container1.handsontable('listen');
- expect($container1.handsontable('isListening')).toEqual(true);
- expect($container2.handsontable('isListening')).toEqual(false);
- $container1.handsontable('destroy');
- $container1.remove();
- $container2.handsontable('destroy');
- $container2.remove();
- });
- });
- /***/ }),
- /* 168 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_loadData', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfArrays = function arrayOfArrays() {
- return [['', 'Kia', 'Nissan', 'Toyota', 'Honda'], ['2008', 10, 11, 12, 13], ['2009', 20, 11, 14, 13], ['2010', 30, 15, 12, 13]];
- };
- var arrayOfObjects = function arrayOfObjects() {
- return [{ id: 1, name: 'Ted', lastName: 'Right' }, { id: 2, name: 'Frank', lastName: 'Honest' }, { id: 3, name: 'Joan', lastName: 'Well' }, { id: 4, name: 'Sid', lastName: 'Strong' }, { id: 5, name: 'Jane', lastName: 'Neat' }, { id: 6, name: 'Chuck', lastName: 'Jackson' }, { id: 7, name: 'Meg', lastName: 'Jansen' }, { id: 8, name: 'Rob', lastName: 'Norris' }, { id: 9, name: 'Sean', lastName: 'O\'Hara' }, { id: 10, name: 'Eve', lastName: 'Branson' }];
- };
- var arrayOfNestedObjects = function arrayOfNestedObjects() {
- return [{
- id: 1,
- name: {
- first: 'Ted',
- last: 'Right'
- },
- 'full.street': 'Street I'
- }, {
- id: 2,
- name: {
- first: 'Frank',
- last: 'Honest'
- },
- 'full.street': 'Street II'
- }, {
- id: 3,
- name: {
- first: 'Joan',
- last: 'Well'
- },
- 'full.street': 'Street III'
- }];
- };
- var htmlData = [['<b>H&M</b>']];
- it('should allow array of arrays', function () {
- handsontable();
- loadData(arrayOfArrays());
- expect(getDataAtCell(0, 2)).toEqual('Nissan');
- });
- it('should allow array of objects', function () {
- handsontable({
- columns: [{ data: 'id' }, { data: 'lastName' }, { data: 'name' }]
- });
- loadData(arrayOfObjects());
- expect(getDataAtCell(0, 2)).toEqual('Ted');
- });
- it('should allow array of objects when columns as a function', function () {
- handsontable({
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = 'id';
- } else if (column === 1) {
- colMeta.data = 'lastName';
- } else if (column === 2) {
- colMeta.data = 'name';
- } else {
- colMeta = null;
- }
- return colMeta;
- }
- });
- loadData(arrayOfObjects());
- expect(getDataAtCell(0, 2)).toEqual('Ted');
- });
- it('should allow array of nested objects', function () {
- handsontable({
- data: arrayOfNestedObjects(),
- colHeaders: true,
- columns: [{ data: 'id' }, { data: 'name.last' }, { data: 'name.first' }, { data: 'full.street' }]
- });
- expect(getDataAtCell(0, 2)).toEqual('Ted');
- expect(getDataAtCell(1, 3)).toEqual('Street II');
- expect(getDataAtRowProp(2, 'full.street')).toEqual('Street III');
- });
- it('should allow array of nested objects when columns as a function', function () {
- handsontable({
- data: arrayOfNestedObjects(),
- colHeaders: true,
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = 'id';
- } else if (column === 1) {
- colMeta.data = 'name.last';
- } else if (column === 2) {
- colMeta.data = 'name.first';
- } else if (column === 3) {
- colMeta.data = 'full.street';
- } else {
- colMeta = null;
- }
- return colMeta;
- }
- });
- expect(getDataAtCell(0, 2)).toEqual('Ted');
- expect(getDataAtCell(1, 3)).toEqual('Street II');
- expect(getDataAtRowProp(2, 'full.street')).toEqual('Street III');
- });
- it('should figure out default column names for array of nested objects', function () {
- handsontable({
- data: arrayOfNestedObjects(),
- colHeaders: true
- });
- expect(getDataAtCell(0, 2)).toEqual('Right');
- });
- it('should trigger onChange callback when loaded array of arrays', function () {
- var called = false;
- handsontable({
- afterChange: function afterChange(changes, source) {
- if (source === 'loadData') {
- called = true;
- }
- }
- });
- loadData(arrayOfArrays());
- expect(called).toEqual(true);
- });
- it('should trigger onChange callback when loaded array of objects', function () {
- var called = false;
- handsontable({
- afterChange: function afterChange(changes, source) {
- if (source === 'loadData') {
- called = true;
- }
- }
- });
- loadData(arrayOfObjects());
- expect(called).toEqual(true);
- });
- it('should trigger onChange callback when loaded array of nested objects', function () {
- var called = false;
- handsontable({
- afterChange: function afterChange(changes, source) {
- if (source === 'loadData') {
- called = true;
- }
- }
- });
- loadData(arrayOfNestedObjects());
- expect(called).toEqual(true);
- });
- it('should create new rows for array of arrays (and respect minRows)', function () {
- handsontable({
- minRows: 20, // minRows should be respected
- data: arrayOfArrays()
- });
- expect(countRows()).toEqual(20); // TODO why this must be checked after render?
- });
- it('should create new rows for array of nested objects (and respect minRows)', function () {
- handsontable({
- minRows: 20, // minRows should be respected
- data: arrayOfNestedObjects()
- });
- expect(countRows()).toEqual(20); // TODO why this must be checked after render?
- });
- it('HTML special chars should be escaped by default', function () {
- handsontable();
- loadData(htmlData);
- expect(getCell(0, 0).innerHTML).toEqual('<b>H&M</b>');
- });
- it('should create as many rows as needed by array of objects', function () {
- handsontable({
- minRows: 6,
- data: arrayOfObjects()
- });
- expect(getCell(9, 1).innerHTML).toEqual('Eve');
- });
- // https://github.com/handsontable/handsontable/pull/233
- it('should not invoke the cells callback multiple times with the same row/col (without overlays)', function () {
- var cellsSpy = jasmine.createSpy('cellsSpy');
- handsontable({
- data: arrayOfNestedObjects(),
- colWidths: [90, 90, 90, 90],
- rowHeights: [23, 23, 23, 23],
- cells: cellsSpy
- });
- //
- expect(cellsSpy.calls.count()).toEqual(43);
- });
- it('should not invoke the cells callback multiple times with the same row/col (with overlays)', function () {
- var cellsSpy = jasmine.createSpy('cellsSpy');
- handsontable({
- data: arrayOfNestedObjects(),
- colHeaders: true,
- rowHeaders: true,
- colWidths: [90, 90, 90, 90],
- rowHeights: [90, 90, 90, 90],
- cells: cellsSpy
- });
- expect(cellsSpy.calls.count()).toEqual(56);
- });
- it('should remove grid rows if new data source has less of them', function () {
- var data1 = [['a'], ['b'], ['c'], ['d'], ['e'], ['f'], ['g'], ['h']];
- var data2 = [['a'], ['b'], ['c'], ['d'], ['e']];
- handsontable({
- data: data1,
- rowHeaders: true,
- colHeaders: true
- });
- selectCell(7, 0);
- loadData(data2);
- expect(countRows()).toBe(data2.length);
- expect(getSelected()).toEqual([4, 0, 4, 0]);
- });
- it('should remove grid rows if new data source has less of them (with minSpareRows)', function () {
- var data1 = [['a'], ['b'], ['c'], ['d'], ['e'], ['f'], ['g'], ['h']];
- var data2 = [['a'], ['b'], ['c'], ['d'], ['e']];
- handsontable({
- data: data1,
- minSpareCols: 1,
- minSpareRows: 1,
- rowHeaders: true,
- colHeaders: true
- });
- selectCell(8, 0);
- loadData(data2);
- expect(countRows()).toBe(6); // +1 because of minSpareRows
- expect(getSelected()).toEqual([5, 0, 5, 0]);
- });
- it('loading empty data should remove all rows', function () {
- var data1 = [['a'], ['b'], ['c'], ['d'], ['e'], ['f'], ['g'], ['h']];
- var data2 = [];
- handsontable({
- data: data1,
- rowHeaders: true,
- colHeaders: true
- });
- selectCell(7, 0);
- loadData(data2);
- expect(countRows()).toBe(0);
- expect(getSelected()).toBe(void 0);
- });
- it('should only have as many columns as in settings', function () {
- var data1 = arrayOfArrays();
- handsontable({
- data: data1,
- columns: [{ data: 1 }, { data: 3 }]
- });
- expect(countCols()).toBe(2);
- });
- it('should only have as many columns as in settings when columns is a function', function () {
- var data1 = arrayOfArrays();
- handsontable({
- data: data1,
- columns: function columns(column) {
- var colMeta = {
- data: column
- };
- if ([1, 3].indexOf(column) < 0) {
- colMeta = null;
- }
- return colMeta;
- }
- });
- expect(countCols()).toBe(2);
- });
- it('should throw error when trying to load a string (constructor)', function () {
- var errors = 0;
- try {
- handsontable({
- data: 'string'
- });
- } catch (e) {
- errors++;
- }
- expect(errors).toBe(1);
- });
- it('should throw error when trying to load a string (loadData)', function () {
- var errors = 0;
- try {
- handsontable();
- loadData('string');
- } catch (e) {
- errors++;
- }
- expect(errors).toBe(1);
- });
- it('should load Backbone Collection as data source', function () {
- // code borrowed from demo/backbone.js
- var CarModel = Backbone.Model.extend({});
- var CarCollection = Backbone.Collection.extend({
- model: CarModel,
- // Backbone.Collection doesn't support `splice`, yet! Easy to add.
- splice: hackedSplice
- });
- var cars = new CarCollection();
- cars.add([{ make: 'Dodge', model: 'Ram', year: 2012, weight: 6811 }, { make: 'Toyota', model: 'Camry', year: 2012, weight: 3190 }, { make: 'Smart', model: 'Fortwo', year: 2012, weight: 1808 }]);
- handsontable({
- data: cars,
- columns: [attr('make'), attr('model'), attr('year')]
- });
- // use the "good" Collection methods to emulate Array.splice
- function hackedSplice(index, howMany /* model1, ... modelN */) {
- var args = _.toArray(arguments).slice(2).concat({ at: index }),
- removed = this.models.slice(index, index + howMany);
- this.remove(removed).add.apply(this, args);
- return removed;
- }
- // normally, you'd get these from the server with .fetch()
- function attr(attr) {
- // this lets us remember `attr` for when when it is get/set
- return {
- data: function data(car, value) {
- if (_.isUndefined(value)) {
- return car.get(attr);
- }
- car.set(attr, value);
- }
- };
- }
- expect(countRows()).toBe(3);
- });
- it('should load Backbone Collection as data source when columns is a function', function () {
- // code borrowed from demo/backbone.js
- var CarModel = Backbone.Model.extend({});
- var CarCollection = Backbone.Collection.extend({
- model: CarModel,
- // Backbone.Collection doesn't support `splice`, yet! Easy to add.
- splice: hackedSplice
- });
- var cars = new CarCollection();
- cars.add([{ make: 'Dodge', model: 'Ram', year: 2012, weight: 6811 }, { make: 'Toyota', model: 'Camry', year: 2012, weight: 3190 }, { make: 'Smart', model: 'Fortwo', year: 2012, weight: 1808 }]);
- handsontable({
- data: cars,
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = attr('make');
- } else if (column === 1) {
- colMeta = attr('model');
- } else if (column === 2) {
- colMeta = attr('year');
- }
- return colMeta;
- }
- });
- // use the "good" Collection methods to emulate Array.splice
- function hackedSplice(index, howMany /* model1, ... modelN */) {
- var args = _.toArray(arguments).slice(2).concat({ at: index }),
- removed = this.models.slice(index, index + howMany);
- this.remove(removed).add.apply(this, args);
- return removed;
- }
- // normally, you'd get these from the server with .fetch()
- function attr(attr) {
- // this lets us remember `attr` for when when it is get/set
- return {
- data: function data(car, value) {
- if (_.isUndefined(value)) {
- return car.get(attr);
- }
- car.set(attr, value);
- }
- };
- }
- expect(countRows()).toBe(3);
- });
- it('should clear cell properties after loadData', function () {
- handsontable();
- loadData(arrayOfArrays());
- getCellMeta(0, 0).foo = 'bar';
- expect(getCellMeta(0, 0).foo).toEqual('bar');
- loadData(arrayOfArrays());
- expect(getCellMeta(0, 0).foo).toBeUndefined();
- });
- it('should clear cell properties after loadData, but before rendering new data', function () {
- handsontable();
- loadData(arrayOfArrays());
- getCellMeta(0, 0).valid = false;
- render();
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').hasClass('htInvalid')).toEqual(true);
- loadData(arrayOfArrays());
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').hasClass('htInvalid')).toEqual(false);
- });
- // https://github.com/handsontable/handsontable/issues/1700
- // can't edit anything after starting editing cell with no nested object
- it('should correct behave with cell with no nested object data source corresponding to column mapping', function () {
- var objectData = [{ id: 1, user: { name: { first: 'Ted', last: 'Right' } } }, { id: 2, user: { name: {} } }, { id: 3 }];
- handsontable({
- data: objectData,
- columns: [{ data: 'id' }, { data: 'user.name.first' }, { data: 'user.name.last' }]
- });
- mouseDoubleClick(getCell(1, 1));
- document.activeElement.value = 'Harry';
- deselectCell();
- expect(objectData[1].user.name.first).toEqual('Harry');
- mouseDoubleClick(getCell(2, 1));
- document.activeElement.value = 'Barry';
- deselectCell();
- expect(objectData[2].user.name.first).toEqual('Barry');
- });
- it('should correct behave with cell with no nested object data source corresponding to column mapping when columns is a function', function () {
- var objectData = [{ id: 1, user: { name: { first: 'Ted', last: 'Right' } } }, { id: 2, user: { name: {} } }, { id: 3 }];
- handsontable({
- data: objectData,
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = { data: 'id' };
- } else if (column === 1) {
- colMeta = { data: 'user.name.first' };
- } else if (column === 2) {
- colMeta = { data: 'user.name.last' };
- }
- return colMeta;
- }
- });
- mouseDoubleClick(getCell(1, 1));
- document.activeElement.value = 'Harry';
- deselectCell();
- expect(objectData[1].user.name.first).toEqual('Harry');
- mouseDoubleClick(getCell(2, 1));
- document.activeElement.value = 'Barry';
- deselectCell();
- expect(objectData[2].user.name.first).toEqual('Barry');
- });
- });
- /***/ }),
- /* 169 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_navigation', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should move to the next cell', function () {
- handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(0, 0);
- keyDown('arrow_right');
- expect(getSelected()).toEqual([0, 1, 0, 1]);
- });
- it('should move to the previous cell', function () {
- handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(1, 2);
- keyDown('arrow_left');
- expect(getSelected()).toEqual([1, 1, 1, 1]);
- });
- it('should move to the cell above', function () {
- handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(1, 2);
- keyDown('arrow_up');
- expect(getSelected()).toEqual([0, 2, 0, 2]);
- });
- it('should move to the cell below', function () {
- handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(1, 2);
- keyDown('arrow_down');
- expect(getSelected()).toEqual([2, 2, 2, 2]);
- });
- describe('autoWrap disabled', function () {
- it('should NOT move to the next cell, if already at the last cell in row', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapRow: false
- });
- selectCell(0, 4);
- keyDown('arrow_right');
- expect(getSelected()).toEqual([0, 4, 0, 4]);
- });
- it('should NOT move to the previous cell, if already at the first cell in row', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapRow: false
- });
- selectCell(1, 0);
- keyDown('arrow_left');
- expect(getSelected()).toEqual([1, 0, 1, 0]);
- });
- it('should NOT move to the cell below, if already at the last cell in column', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapCol: false
- });
- selectCell(4, 0);
- keyDown('arrow_down');
- expect(getSelected()).toEqual([4, 0, 4, 0]);
- });
- it('should NOT move to the cell above, if already at the first cell in column', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapCol: false
- });
- selectCell(0, 1);
- keyDown('arrow_up');
- expect(getSelected()).toEqual([0, 1, 0, 1]);
- });
- });
- describe('autoWrap enabled', function () {
- it('should move to the first cell of the next row, if already at the last cell in row', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapRow: true
- });
- selectCell(0, 4);
- keyDown('arrow_right');
- expect(getSelected()).toEqual([1, 0, 1, 0]);
- });
- it('should move to the first cell of the previous row, if already at the first cell in row', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapRow: true
- });
- selectCell(1, 0);
- keyDown('arrow_left');
- expect(getSelected()).toEqual([0, 4, 0, 4]);
- });
- it('should move to the first cell of the next column, if already at the last cell in column', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapCol: true
- });
- selectCell(4, 1);
- keyDown('arrow_down');
- expect(getSelected()).toEqual([0, 2, 0, 2]);
- });
- it('should move to the last cell of the previous column, if already at the first cell in column', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapCol: true
- });
- selectCell(0, 1);
- keyDown('arrow_up');
- expect(getSelected()).toEqual([4, 0, 4, 0]);
- });
- it('should move to the first cell of the first row, after trying to get to the next cell in row, being already at the last cell in table', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapRow: true
- });
- selectCell(4, 4);
- keyDown('arrow_right');
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should move to the first cell of the first row, after trying to get to the next cell in column, being already at the last cell in table', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapCol: true
- });
- selectCell(4, 4);
- keyDown('arrow_down');
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should move to the last cell of the last row, after trying to get to the previous cell in row, being already at the first cell in table', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapRow: true
- });
- selectCell(0, 0);
- keyDown('arrow_left');
- expect(getSelected()).toEqual([4, 4, 4, 4]);
- });
- it('should move to the last cell of the last row, after trying to get to the previous cell in column, being already at the first cell in table', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapCol: true
- });
- selectCell(0, 0);
- keyDown('arrow_up');
- expect(getSelected()).toEqual([4, 4, 4, 4]);
- });
- it('should traverse whole table by constantly selecting next cell in row', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapRow: true
- });
- selectCell(0, 0);
- for (var row = 0, rlen = countRows(); row < rlen; row++) {
- for (var col = 0, clen = countCols(); col < clen; col++) {
- expect(getSelected()).toEqual([row, col, row, col]);
- keyDown('arrow_right');
- }
- }
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should traverse whole table by constantly selecting previous cell in row', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapRow: true
- });
- selectCell(4, 4);
- for (var row = countRows() - 1; row >= 0; row--) {
- for (var col = countCols() - 1; col >= 0; col--) {
- expect(getSelected()).toEqual([row, col, row, col]);
- keyDown('arrow_left');
- }
- }
- expect(getSelected()).toEqual([4, 4, 4, 4]);
- });
- it('should traverse whole table by constantly selecting next cell in column', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapCol: true
- });
- selectCell(0, 0);
- for (var col = 0, clen = countCols(); col < clen; col++) {
- for (var row = 0, rlen = countRows(); row < rlen; row++) {
- expect(getSelected()).toEqual([row, col, row, col]);
- keyDown('arrow_down');
- }
- }
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should traverse whole table by constantly selecting previous cell in column', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- autoWrapCol: true
- });
- selectCell(4, 4);
- for (var col = countCols() - 1; col >= 0; col--) {
- for (var row = countRows() - 1; row >= 0; row--) {
- expect(getSelected()).toEqual([row, col, row, col]);
- keyDown('arrow_up');
- }
- }
- expect(getSelected()).toEqual([4, 4, 4, 4]);
- });
- });
- });
- /***/ }),
- /* 170 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_onKeyDown', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should advance to next cell when TAB is pressed', function () {
- // https://github.com/handsontable/handsontable/issues/151
- handsontable();
- selectCell(0, 0);
- keyDownUp('tab');
- expect(getSelected()).toEqual([0, 1, 0, 1]);
- });
- it('should advance to previous cell when shift+TAB is pressed', function () {
- handsontable();
- selectCell(1, 1);
- keyDownUp('shift+tab');
- expect(getSelected()).toEqual([1, 0, 1, 0]);
- });
- describe('while editing (quick edit mode)', function () {
- it('should finish editing and advance to next cell when TAB is pressed', function () {
- // https://github.com/handsontable/handsontable/issues/215
- handsontable();
- selectCell(1, 1);
- keyDownUp('x'); // value to cell trigger quick edit mode
- keyProxy().val('Ted');
- keyDownUp('tab');
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([1, 2, 1, 2]);
- });
- it('should finish editing and advance to lower cell when enter is pressed', function () {
- // https://github.com/handsontable/handsontable/issues/215
- handsontable();
- selectCell(1, 1);
- keyDownUp('x'); // value to cell trigger quick edit mode
- keyProxy().val('Ted');
- keyDownUp('enter');
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([2, 1, 2, 1]);
- });
- it('should finish editing and advance to higher cell when shift+enter is pressed', function () {
- // https://github.com/handsontable/handsontable/issues/215
- handsontable();
- selectCell(1, 1);
- keyDownUp('x'); // trigger quick edit mode
- keyProxy().val('Ted');
- keyDownUp('shift+enter');
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([0, 1, 0, 1]);
- });
- it('should finish editing and advance to lower cell when down arrow is pressed', function () {
- handsontable();
- selectCell(1, 1);
- keyDownUp('x');
- keyProxy().val('Ted');
- keyDownUp('arrow_down');
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([2, 1, 2, 1]);
- });
- it('should finish editing and advance to higher cell when up arrow is pressed', function () {
- handsontable();
- selectCell(1, 1);
- keyDownUp('x');
- keyProxy().val('Ted');
- keyDownUp('arrow_up');
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([0, 1, 0, 1]);
- });
- it('should finish editing and advance to right cell when right arrow is pressed', function () {
- handsontable();
- selectCell(1, 1);
- keyDownUp('x');
- keyProxy().val('Ted');
- keyDownUp('arrow_right');
- keyDownUp('arrow_right');
- keyDownUp('arrow_right');
- keyDownUp('arrow_right');
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([1, 4, 1, 4]);
- });
- it('should finish editing and advance to left cell when left arrow is pressed', function () {
- handsontable();
- selectCell(1, 1);
- keyDownUp('x');
- keyProxy().val('Ted');
- Handsontable.dom.setCaretPosition(keyProxy()[0], 0, 0);
- keyDownUp('arrow_left');
- keyDownUp('arrow_left');
- keyDownUp('arrow_left');
- keyDownUp('arrow_left');
- keyDownUp('arrow_left');
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([1, 0, 1, 0]);
- });
- it('should finish editing and advance to lower cell when enter is pressed (with sync validator)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- validator: function validator(val, cb) {
- cb(true);
- },
- afterValidate: onAfterValidate
- });
- selectCell(1, 1);
- keyDownUp('x');
- keyProxy().val('Ted');
- onAfterValidate.calls.reset();
- keyDownUp('enter');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalled();
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([2, 1, 2, 1]);
- done();
- }, 200);
- });
- it('should finish editing and advance to lower cell when enter is pressed (with async validator)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- validator: function validator(val, cb) {
- setTimeout(function () {
- cb(true);
- }, 10);
- },
- afterValidate: onAfterValidate
- });
- selectCell(1, 1);
- keyDownUp('x');
- keyProxy().val('Ted');
- onAfterValidate.calls.reset();
- keyDownUp('enter');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalled();
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([2, 1, 2, 1]);
- done();
- }, 200);
- });
- });
- describe('while editing (full edit mode)', function () {
- it('should finish editing and advance to next cell when TAB is pressed', function () {
- // https://github.com/handsontable/handsontable/issues/215
- handsontable();
- selectCell(1, 1);
- keyDownUp('enter');
- keyProxy().val('Ted');
- keyDownUp('tab');
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([1, 2, 1, 2]);
- });
- it('should finish editing and advance to lower cell when enter is pressed', function () {
- // https://github.com/handsontable/handsontable/issues/215
- handsontable();
- selectCell(1, 1);
- keyDownUp('enter');
- keyProxy().val('Ted');
- keyDownUp('enter');
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([2, 1, 2, 1]);
- });
- it('should finish editing and advance to higher cell when shift+enter is pressed', function () {
- // https://github.com/handsontable/handsontable/issues/215
- handsontable();
- selectCell(1, 1);
- keyDownUp('enter');
- keyProxy().val('Ted');
- keyDownUp('shift+enter');
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([0, 1, 0, 1]);
- });
- it('shouldn\'t finish editing and advance to lower cell when down arrow is pressed', function () {
- handsontable();
- selectCell(1, 1);
- keyDownUp('enter');
- keyProxy().val('Ted');
- keyDownUp('arrow_down');
- expect(getData()[1][1]).toEqual(null);
- expect(getSelected()).toEqual([1, 1, 1, 1]);
- });
- it('shouldn\'t finish editing and advance to higher cell when up arrow is pressed', function () {
- handsontable();
- selectCell(1, 1);
- keyDownUp('enter');
- keyProxy().val('Ted');
- keyDownUp('arrow_up');
- expect(getData()[1][1]).toEqual(null);
- expect(getSelected()).toEqual([1, 1, 1, 1]);
- });
- it('shouldn\'t finish editing and advance to right cell when right arrow is pressed', function () {
- handsontable();
- selectCell(1, 1);
- keyDownUp('enter');
- keyProxy().val('Ted');
- keyDownUp('arrow_right');
- keyDownUp('arrow_right');
- keyDownUp('arrow_right');
- keyDownUp('arrow_right');
- expect(getData()[1][1]).toEqual(null);
- expect(getSelected()).toEqual([1, 1, 1, 1]);
- });
- it('shouldn\'t finish editing and advance to left cell when left arrow is pressed', function () {
- handsontable();
- selectCell(1, 1);
- keyDownUp('enter');
- keyProxy().val('Ted');
- keyDownUp('arrow_left');
- keyDownUp('arrow_left');
- keyDownUp('arrow_left');
- keyDownUp('arrow_left');
- expect(getData()[1][1]).toEqual(null);
- expect(getSelected()).toEqual([1, 1, 1, 1]);
- });
- it('should finish editing and advance to lower cell when enter is pressed (with sync validator)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- validator: function validator(val, cb) {
- cb(true);
- },
- afterValidate: onAfterValidate
- });
- selectCell(1, 1);
- keyDownUp('enter');
- keyProxy().val('Ted');
- onAfterValidate.calls.reset();
- keyDownUp('enter');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalled();
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([2, 1, 2, 1]);
- done();
- }, 200);
- });
- it('should finish editing and advance to lower cell when enter is pressed (with async validator)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- validator: function validator(val, cb) {
- setTimeout(function () {
- cb(true);
- }, 10);
- },
- afterValidate: onAfterValidate
- });
- selectCell(1, 1);
- keyDownUp('enter');
- keyProxy().val('Ted');
- onAfterValidate.calls.reset();
- keyDownUp('enter');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalled();
- expect(getData()[1][1]).toEqual('Ted');
- expect(getSelected()).toEqual([2, 1, 2, 1]);
- done();
- }, 200);
- });
- });
- });
- /***/ }),
- /* 171 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_paste', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfArrays = function arrayOfArrays() {
- return [['', 'Kia', 'Nissan', 'Toyota', 'Honda'], ['2008', 10, 11, 12, 13], ['2009', 20, 11, 14, 13], ['2010', 30, 15, 12, 13]];
- };
- it('should not create new rows or columns when allowInsertRow and allowInsertColumn equal false', function (done) {
- handsontable({
- data: arrayOfArrays(),
- pasteMode: 'shift_down',
- allowInsertRow: false,
- allowInsertColumn: false
- });
- selectCell(3, 4); // selectAll
- triggerPaste('Kia\tNissan\tToyota');
- setTimeout(function () {
- var expected = arrayOfArrays();
- expected[3][4] = 'Kia';
- expect(getData()).toEqual(expected);
- done();
- }, 60);
- });
- it('should shift data down instead of overwrite when paste (when allowInsertRow = false)', function (done) {
- handsontable({
- data: arrayOfArrays(),
- pasteMode: 'shift_down',
- allowInsertRow: false
- });
- selectCell(1, 0); // selectAll
- triggerPaste('Kia\tNissan\tToyota');
- setTimeout(function () {
- expect(getData().length).toEqual(4);
- expect(getData(0, 0, 2, 4)).toEqual([['', 'Kia', 'Nissan', 'Toyota', 'Honda'], ['Kia', 'Nissan', 'Toyota', 12, 13], ['2008', 10, 11, 14, 13]]);
- done();
- }, 60);
- });
- it('should shift data down instead of overwrite when paste (minSpareRows > 0)', function (done) {
- handsontable({
- data: arrayOfArrays(),
- pasteMode: 'shift_down',
- minSpareRows: 1
- });
- selectCell(1, 0); // selectAll
- triggerPaste('Kia\tNissan\tToyota');
- setTimeout(function () {
- expect(getData().length).toEqual(6);
- expect(getData(0, 0, 2, 4)).toEqual([['', 'Kia', 'Nissan', 'Toyota', 'Honda'], ['Kia', 'Nissan', 'Toyota', 12, 13], ['2008', 10, 11, 14, 13]]);
- done();
- }, 60);
- });
- it('should shift right insert instead of overwrite when paste', function (done) {
- handsontable({
- data: arrayOfArrays(),
- pasteMode: 'shift_right',
- allowInsertColumn: false
- });
- selectCell(1, 0); // selectAll
- triggerPaste('Kia\tNissan\tToyota');
- setTimeout(function () {
- expect(getData()[0].length).toEqual(5);
- expect(getDataAtRow(1)).toEqual(['Kia', 'Nissan', 'Toyota', '2008', 10]);
- done();
- }, 60);
- });
- it('should shift right insert instead of overwrite when paste (minSpareCols > 0)', function (done) {
- handsontable({
- data: arrayOfArrays(),
- pasteMode: 'shift_right',
- minSpareCols: 1
- });
- selectCell(1, 0); // selectAll
- triggerPaste('Kia\tNissan\tToyota');
- setTimeout(function () {
- expect(getData()[0].length).toEqual(9);
- expect(getDataAtRow(1)).toEqual(['Kia', 'Nissan', 'Toyota', '2008', 10, 11, 12, 13, null]);
- done();
- }, 60);
- });
- it('should not throw an error when changes are null in `once` hook', function (done) {
- var errors = 0;
- try {
- handsontable({
- data: arrayOfArrays(),
- afterChange: function afterChange(changes, source) {
- if (source === 'loadData') {
- return;
- }
- loadData(arrayOfArrays());
- }
- });
- selectCell(1, 0); // selectAll
- triggerPaste('Kia\tNissan\tToyota');
- } catch (e) {
- errors++;
- }
- setTimeout(function () {
- expect(errors).toEqual(0);
- done();
- }, 60);
- });
- it('should not paste any data, if no cell is selected', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 1)
- });
- var copiedData1 = 'foo';
- var copiedData2 = 'bar';
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('A2');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('A3');
- expect(getSelected()).toBeUndefined();
- hot.copyPaste.triggerPaste($.Event(), copiedData1);
- setTimeout(function () {
- expect(spec().$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(spec().$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('A2');
- expect(spec().$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('A3');
- }, 100);
- setTimeout(function () {
- selectCell(1, 0, 2, 0);
- hot.copyPaste.triggerPaste($.Event(), copiedData2);
- }, 200);
- setTimeout(function () {
- expect(spec().$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(spec().$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual(copiedData2);
- expect(spec().$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual(copiedData2);
- done();
- }, 300);
- });
- it('should not paste any data, if no cell is selected (select/deselect cell using mouse)', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 1)
- });
- var copiedData = 'foo';
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(this.$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('A2');
- expect(this.$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('A3');
- this.$container.find('tbody tr:eq(1) td:eq(0)').simulate('mousedown');
- this.$container.find('tbody tr:eq(1) td:eq(0)').simulate('mouseup');
- expect(getSelected()).toEqual([1, 0, 1, 0]);
- $('html').simulate('mousedown');
- expect(getSelected()).toBeUndefined();
- hot.copyPaste.triggerPaste($.Event(), copiedData);
- setTimeout(function () {
- expect(spec().$container.find('tbody tr:eq(0) td:eq(0)').text()).toEqual('A1');
- expect(spec().$container.find('tbody tr:eq(1) td:eq(0)').text()).toEqual('A2');
- expect(spec().$container.find('tbody tr:eq(2) td:eq(0)').text()).toEqual('A3');
- done();
- }, 100);
- });
- });
- /***/ }),
- /* 172 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_populateFromArray', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfArrays = function arrayOfArrays() {
- return [['', 'Kia', 'Nissan', 'Toyota', 'Honda', 'Mix'], ['2008', 10, 11, 12, 13, { a: 1, b: 2 }], ['2009', 20, 11, 14, 13, { a: 1, b: 2 }], ['2010', 30, 15, 12, 13, { a: 1, b: 2 }]];
- };
- it('should call onChange callback', function () {
- var output = null;
- handsontable({
- data: arrayOfArrays(),
- afterChange: function afterChange(changes) {
- output = changes;
- }
- });
- populateFromArray(0, 0, [['test', 'test'], ['test', 'test']], 1, 1);
- expect(output).toEqual([[0, 0, '', 'test'], [0, 1, 'Kia', 'test'], [1, 0, '2008', 'test'], [1, 1, 10, 'test']]);
- });
- it('should populate single value for whole selection', function () {
- var output = null;
- handsontable({
- data: arrayOfArrays(),
- afterChange: function afterChange(changes) {
- output = changes;
- }
- });
- populateFromArray(0, 0, [['test']], 3, 0);
- expect(output).toEqual([[0, 0, '', 'test'], [1, 0, '2008', 'test'], [2, 0, '2009', 'test'], [3, 0, '2010', 'test']]);
- });
- it('should populate value for whole selection only if populated data isn\'t an array', function () {
- var output = null;
- handsontable({
- data: arrayOfArrays(),
- afterChange: function afterChange(changes) {
- output = changes;
- }
- });
- populateFromArray(0, 0, [['test'], [[1, 2, 3]]], 3, 0);
- expect(output).toEqual([[0, 0, '', 'test'], [2, 0, '2009', 'test']]);
- });
- it('should populate value for whole selection only if populated data isn\'t an object', function () {
- var output = null;
- handsontable({
- data: arrayOfArrays(),
- afterChange: function afterChange(changes) {
- output = changes;
- }
- });
- populateFromArray(0, 0, [['test'], [{ test: 1 }]], 3, 0);
- expect(output).toEqual([[0, 0, '', 'test'], [2, 0, '2009', 'test']]);
- });
- it('shouldn\'t populate value if original value doesn\'t have the same data structure', function () {
- var output = null;
- handsontable({
- data: arrayOfArrays(),
- afterChange: function afterChange(changes) {
- output = changes;
- }
- });
- populateFromArray(1, 3, [['test']], 1, 5);
- expect(output).toEqual([[1, 3, 12, 'test'], [1, 4, 13, 'test']]);
- });
- it('should shift values down', function () {
- var output = null;
- handsontable({
- data: arrayOfArrays(),
- afterChange: function afterChange(changes) {
- output = changes;
- },
- minSpareRows: 1
- });
- populateFromArray(0, 0, [['test', 'test2'], ['test3', 'test4']], 2, 2, null, 'shift_down');
- expect(getData()).toEqual([['test', 'test2', 'test', 'Toyota', 'Honda', 'Mix'], ['test3', 'test4', 'test3', 12, 13, { a: 1, b: 2 }], ['test', 'test2', 'test', 14, 13, { a: 1, b: 2 }], ['', 'Kia', 'Nissan', 12, 13, { a: 1, b: 2 }], ['2008', 10, 11, null, null, null], ['2009', 20, 11, null, null, null], ['2010', 30, 15, null, null, null], [null, null, null, null, null, null]]);
- });
- it('should shift values right', function () {
- var output = null;
- handsontable({
- data: arrayOfArrays(),
- afterChange: function afterChange(changes) {
- output = changes;
- },
- minSpareCols: 1
- });
- populateFromArray(0, 0, [['test', 'test2'], ['test3', 'test4']], 2, 2, null, 'shift_right');
- expect(getData()).toEqual([['test', 'test2', 'test', '', 'Kia', 'Nissan', 'Toyota', 'Honda', 'Mix', null], ['test3', 'test4', 'test3', '2008', 10, { a: 1, b: 2 }, 12, 13, null, null], ['test', 'test2', 'test', '2009', 20, { a: 1, b: 2 }, 14, 13, null, null], ['2010', 30, 15, 12, 13, { a: 1, b: 2 }, null, null, null, null]]);
- });
- it('should run beforeAutofillInsidePopulate hook for each inserted value', function () {
- var called = 0;
- var hot = handsontable({
- data: arrayOfArrays()
- });
- hot.addHook('beforeAutofillInsidePopulate', function (index) {
- called++;
- });
- populateFromArray(0, 0, [['test', 'test2'], ['test3', 'test4']], 1, 1, 'Autofill.fill', 'overwrite');
- expect(called).toEqual(4);
- });
- it('should run beforeAutofillInsidePopulate hook and could change cell data before insert if returned object with value property', function () {
- var hot = handsontable({
- data: arrayOfArrays()
- });
- hot.addHook('beforeAutofillInsidePopulate', function (index) {
- return {
- value: 'my_test'
- };
- });
- populateFromArray(0, 0, [['test', 'test2'], ['test3', 'test4']], 1, 1, 'Autofill.fill', 'overwrite');
- expect(getDataAtCell(0, 0)).toEqual('my_test');
- });
- it('should populate 1 row from 2 selected rows', function () {
- var hot = handsontable({
- data: arrayOfArrays()
- });
- populateFromArray(2, 0, [['A1'], ['A2']], 2, 0, 'autofill', null, 'down', [[0]]);
- expect(getDataAtCell(2, 0)).toEqual('A1');
- expect(getDataAtCell(3, 0)).toEqual('2010');
- });
- it('should populate 1 column from 2 selected columns`', function () {
- var hot = handsontable({
- data: arrayOfArrays()
- });
- populateFromArray(0, 2, [['A1', 'A2']], 0, 2, 'autofill', null, 'right', [[0]]);
- expect(getDataAtCell(0, 2)).toEqual('A1');
- expect(getDataAtCell(0, 3)).toEqual('Toyota');
- });
- });
- /***/ }),
- /* 173 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_reCreate', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should correctly re-render corner header when there is multiline content', function () {
- var settings = {
- rowHeaders: true,
- colHeaders: function colHeaders(col) {
- return 'Column<br>' + col;
- }
- };
- handsontable(settings);
- destroy();
- handsontable(settings);
- expect(getTopLeftClone().width()).toBe(54);
- expect(getTopLeftClone().height()).toBe(51);
- });
- });
- /***/ }),
- /* 174 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_removeCellMeta', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should remove meta for cell', function () {
- handsontable({
- data: [[1, 2, 3, 4], [5, 6, 7, 8], [0, 9, 8, 7]]
- });
- var border = {
- top: {},
- left: {}
- };
- setCellMeta(0, 0, 'borders', border);
- expect(getCellMeta(0, 0).borders).toEqual(border);
- removeCellMeta(0, 0, 'borders');
- expect(getCellMeta(0, 0).borders).toBeUndefined();
- });
- });
- /***/ }),
- /* 175 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_render', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('all cells should get green background', function () {
- function greenCell(instance, td, row, col, prop, value, cellProperties) {
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- td.style.backgroundColor = 'green';
- }
- handsontable({
- data: [['a', 'b'], ['c', 'd']],
- minRows: 4,
- minCols: 4,
- minSpareRows: 4,
- minSpareCols: 4,
- cells: function cells() {
- return {
- renderer: greenCell
- };
- }
- });
- var $tds = this.$container.find('.htCore tbody td');
- $tds.each(function () {
- expect(this.style.backgroundColor).toEqual('green');
- });
- });
- it('render should update border dimensions', function () {
- var data = [['a', 'b'], ['c', 'd']];
- handsontable({
- data: data,
- minRows: 4,
- minCols: 4,
- minSpareRows: 4,
- minSpareCols: 4
- });
- selectCell(1, 1);
- data[1][1] = 'dddddddddddddddddddd';
- render();
- var $td = this.$container.find('.htCore tbody tr:eq(1) td:eq(1)');
- expect(this.$container.find('.wtBorder.current').width()).toBeGreaterThan($td.width());
- });
- it('should not render table twice', function () {
- var counter = 0;
- handsontable({
- data: [['Joe Red']],
- afterRender: function afterRender() {
- counter++;
- }
- });
- populateFromArray(0, 0, [['t', 'e', 's', 't']]);
- expect(counter).toEqual(2); // 1 from load and 1 from populateFromArray
- });
- it('should run afterRenderer hook', function () {
- var lastCellProperties;
- handsontable({
- data: [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],
- afterRenderer: function afterRenderer(td, row, col, prop, value, cellProperties) {
- td.innerHTML = 'Changed by plugin';
- if (!cellProperties) {
- throw new Error();
- }
- lastCellProperties = cellProperties;
- }
- });
- expect(this.$container.find('td:eq(0)')[0].innerHTML).toEqual('Changed by plugin');
- expect(lastCellProperties.row).toEqual(1);
- expect(lastCellProperties.col).toEqual(4);
- });
- it('should run beforeRenderer hook', function () {
- var lastCellProperties;
- handsontable({
- data: [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],
- beforeRenderer: function beforeRenderer(td, row, col, prop, value, cellProperties) {
- td.innerHTML = 'Changed by plugin';
- lastCellProperties = cellProperties;
- }
- });
- // Value is overwritten by text renderer
- expect(this.$container.find('td:eq(0)')[0].innerHTML).toEqual('1');
- expect(lastCellProperties.row).toEqual(1);
- expect(lastCellProperties.col).toEqual(4);
- });
- it('should reflect changes applied in beforeRenderer into afterRenderer', function () {
- var afterRenderer = jasmine.createSpy();
- handsontable({
- data: [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],
- beforeRenderer: function beforeRenderer(td, row, col, prop, value, cellProperties) {
- cellProperties.foo = 'bar';
- },
- afterRenderer: afterRenderer
- });
- expect(afterRenderer.calls.count()).toBe(10);
- expect(afterRenderer.calls.argsFor(0)[0] instanceof HTMLTableCellElement).toBe(true);
- expect(afterRenderer.calls.argsFor(0)[1]).toBe(0);
- expect(afterRenderer.calls.argsFor(0)[2]).toBe(0);
- expect(afterRenderer.calls.argsFor(0)[3]).toBe(0);
- expect(afterRenderer.calls.argsFor(0)[4]).toBe(1);
- expect(afterRenderer.calls.argsFor(0)[5].foo).toBe('bar');
- });
- });
- /***/ }),
- /* 176 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_selection', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should call onSelection callback', function () {
- var output = null;
- handsontable({
- afterSelection: function afterSelection(r, c) {
- output = [r, c];
- }
- });
- selectCell(1, 2);
- expect(output[0]).toEqual(1);
- expect(output[1]).toEqual(2);
- });
- it('should trigger selection event', function () {
- var output = null;
- handsontable();
- Handsontable.hooks.add('afterSelection', function (r, c) {
- output = [r, c];
- });
- selectCell(1, 2);
- expect(output[0]).toEqual(1);
- expect(output[1]).toEqual(2);
- });
- it('this.rootElement should point to handsontable rootElement (onSelection)', function () {
- var output = null;
- handsontable({
- afterSelection: function afterSelection() {
- output = this.rootElement;
- }
- });
- selectCell(0, 0);
- expect(output).toEqual(this.$container[0]);
- });
- it('this.rootElement should point to handsontable rootElement (onSelectionByProp)', function () {
- var output = null;
- handsontable({
- afterSelectionByProp: function afterSelectionByProp() {
- output = this.rootElement;
- }
- });
- selectCell(0, 0);
- expect(output).toEqual(this.$container[0]);
- });
- it('should focus external textarea when clicked during editing', function () {
- var textarea = $('<input type="text">').prependTo($('body'));
- handsontable();
- selectCell(0, 0);
- keyDown('enter');
- // $("html").triggerHandler('mouseup');
- $('html').simulate('mouseup');
- textarea.focus();
- expect(document.activeElement).toBe(textarea[0]);
- textarea.remove();
- });
- it('should deselect currently selected cell', function () {
- handsontable();
- selectCell(0, 0);
- $('html').simulate('mousedown');
- expect(getSelected()).toBeUndefined();
- });
- it('should not deselect the currently selected cell after clicking on a scrollbar', function () {
- var hot = handsontable({
- outsideClickDeselects: false,
- minRows: 20,
- minCols: 2,
- width: 400,
- height: 100
- });
- selectCell(0, 0);
- var holderBoundingBox = hot.view.wt.wtTable.holder.getBoundingClientRect(),
- verticalScrollbarCoords = {
- x: holderBoundingBox.left + holderBoundingBox.width - 3,
- y: holderBoundingBox.top + holderBoundingBox.height / 2
- },
- horizontalScrollbarCoords = {
- x: holderBoundingBox.left + holderBoundingBox.width / 2,
- y: holderBoundingBox.top + holderBoundingBox.height - 3
- };
- $(hot.view.wt.wtTable.holder).simulate('mousedown', {
- clientX: verticalScrollbarCoords.x,
- clientY: verticalScrollbarCoords.y
- });
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- $(hot.view.wt.wtTable.holder).simulate('mousedown', {
- clientX: horizontalScrollbarCoords.x,
- clientY: horizontalScrollbarCoords.y
- });
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should not deselect currently selected cell', function () {
- handsontable({
- outsideClickDeselects: false
- });
- selectCell(0, 0);
- $('html').simulate('mousedown');
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should allow to focus on external input and hold current selection informations', function () {
- var textarea = $('<input id="test_textarea" type="text">').prependTo($('body'));
- handsontable({
- outsideClickDeselects: false
- });
- selectCell(0, 0);
- textarea.simulate('mousedown');
- textarea.focus();
- expect(document.activeElement.id).toEqual('test_textarea');
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- textarea.remove();
- });
- it('should allow to type in external input while holding current selection information', function () {
- var textarea = $('<textarea id="test_textarea"></textarea>').prependTo($('body'));
- var keyPressed;
- handsontable({
- outsideClickDeselects: false
- });
- selectCell(0, 0);
- textarea.focus();
- textarea.simulate('mousedown');
- textarea.simulate('mouseup');
- textarea.on('keydown', function (event) {
- keyPressed = event.keyCode;
- });
- var LETTER_A_KEY = 97;
- $(document.activeElement).simulate('keydown', {
- keyCode: LETTER_A_KEY
- });
- // textarea should receive the event and be an active element
- expect(keyPressed).toEqual(LETTER_A_KEY);
- expect(document.activeElement).toBe(document.getElementById('test_textarea'));
- // should preserve selection, close editor and save changes
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- expect(getDataAtCell(0, 0)).toBeNull();
- textarea.remove();
- });
- it('should allow to type in external input after opening cell editor', function () {
- var textarea = $('<textarea id="test_textarea"></textarea>').prependTo($('body'));
- var keyPressed;
- handsontable({
- outsideClickDeselects: false
- });
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'Foo';
- textarea.focus();
- textarea.simulate('mousedown');
- textarea.simulate('mouseup');
- textarea.on('keydown', function (event) {
- keyPressed = event.keyCode;
- });
- var LETTER_A_KEY = 97;
- $(document.activeElement).simulate('keydown', {
- keyCode: LETTER_A_KEY
- });
- // textarea should receive the event and be an active element
- expect(keyPressed).toEqual(LETTER_A_KEY);
- expect(document.activeElement).toBe(document.getElementById('test_textarea'));
- // should preserve selection, close editor and save changes
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- expect(getDataAtCell(0, 0)).toEqual('Foo');
- textarea.remove();
- });
- it('should deselect on outside click if outsideClickDeselects is a function that returns true', function () {
- var textarea = $('<textarea id="test_textarea"></textarea>').prependTo($('body'));
- var keyPressed;
- handsontable({
- outsideClickDeselects: function outsideClickDeselects() {
- return true;
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'Foo';
- textarea.focus();
- textarea.simulate('mousedown');
- textarea.simulate('mouseup');
- textarea.on('keydown', function (event) {
- keyPressed = event.keyCode;
- });
- var LETTER_A_KEY = 97;
- $(document.activeElement).simulate('keydown', {
- keyCode: LETTER_A_KEY
- });
- // textarea should receive the event and be an active element
- expect(keyPressed).toEqual(LETTER_A_KEY);
- expect(document.activeElement).toBe(document.getElementById('test_textarea'));
- // should NOT preserve selection
- expect(getSelected()).toEqual(undefined);
- expect(getDataAtCell(0, 0)).toEqual('Foo');
- textarea.remove();
- });
- it('should not deselect on outside click if outsideClickDeselects is a function that returns false', function () {
- var textarea = $('<textarea id="test_textarea"></textarea>').prependTo($('body'));
- var keyPressed;
- handsontable({
- outsideClickDeselects: function outsideClickDeselects() {
- return false;
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'Foo';
- textarea.focus();
- textarea.simulate('mousedown');
- textarea.simulate('mouseup');
- textarea.on('keydown', function (event) {
- keyPressed = event.keyCode;
- });
- var LETTER_A_KEY = 97;
- $(document.activeElement).simulate('keydown', {
- keyCode: LETTER_A_KEY
- });
- // textarea should receive the event and be an active element
- expect(keyPressed).toEqual(LETTER_A_KEY);
- expect(document.activeElement).toBe(document.getElementById('test_textarea'));
- // should preserve selection, close editor and save changes
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- expect(getDataAtCell(0, 0)).toEqual('Foo');
- textarea.remove();
- });
- it('should fix start range if provided is out of bounds (to the left)', function () {
- handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(0, 0);
- keyDownUp('arrow_left');
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should fix start range if provided is out of bounds (to the top)', function () {
- handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(0, 0);
- keyDownUp('arrow_up');
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should fix start range if provided is out of bounds (to the right)', function () {
- handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(0, 4);
- keyDownUp('arrow_right');
- expect(getSelected()).toEqual([0, 4, 0, 4]);
- });
- it('should fix start range if provided is out of bounds (to the bottom)', function () {
- handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(4, 0);
- keyDownUp('arrow_down');
- expect(getSelected()).toEqual([4, 0, 4, 0]);
- });
- it('should fix end range if provided is out of bounds (to the left)', function () {
- handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(0, 1);
- keyDownUp('shift+arrow_left');
- keyDownUp('shift+arrow_left');
- expect(getSelected()).toEqual([0, 1, 0, 0]);
- });
- it('should fix end range if provided is out of bounds (to the top)', function () {
- handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(1, 0);
- keyDownUp('shift+arrow_up');
- keyDownUp('shift+arrow_up');
- expect(getSelected()).toEqual([1, 0, 0, 0]);
- });
- it('should fix end range if provided is out of bounds (to the right)', function () {
- handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(0, 3);
- keyDownUp('shift+arrow_right');
- keyDownUp('shift+arrow_right');
- expect(getSelected()).toEqual([0, 3, 0, 4]);
- });
- it('should fix end range if provided is out of bounds (to the bottom)', function () {
- handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(3, 0);
- keyDownUp('shift+arrow_down');
- keyDownUp('shift+arrow_down');
- keyDownUp('shift+arrow_down');
- expect(getSelected()).toEqual([3, 0, 4, 0]);
- });
- it('should select multiple cells', function () {
- handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(3, 0, 4, 1);
- expect(getSelected()).toEqual([3, 0, 4, 1]);
- });
- it('should call onSelectionEnd as many times as onSelection when `selectCell` is called', function () {
- var tick = 0,
- tickEnd = 0;
- handsontable({
- startRows: 5,
- startCols: 5,
- afterSelection: function afterSelection() {
- tick++;
- },
- afterSelectionEnd: function afterSelectionEnd() {
- tickEnd++;
- }
- });
- selectCell(3, 0);
- selectCell(1, 1);
- expect(tick).toEqual(2);
- expect(tickEnd).toEqual(2);
- });
- it('should call onSelectionEnd when user finishes selection by releasing SHIFT key (3 times)', function () {
- var tick = 0;
- handsontable({
- startRows: 5,
- startCols: 5,
- afterSelectionEnd: function afterSelectionEnd() {
- tick++;
- }
- });
- selectCell(3, 0); // makes tick++
- keyDownUp('shift+arrow_down'); // makes tick++
- keyDownUp('shift+arrow_down'); // makes tick++
- keyDownUp('shift+arrow_down'); // makes tick++
- expect(getSelected()).toEqual([3, 0, 4, 0]);
- expect(tick).toEqual(4);
- });
- it('should call onSelectionEnd when user finishes selection by releasing SHIFT key (1 time)', function () {
- var tick = 0;
- handsontable({
- startRows: 5,
- startCols: 5,
- afterSelectionEnd: function afterSelectionEnd() {
- tick++;
- }
- });
- selectCell(3, 0); // makes tick++
- keyDown('shift+arrow_down');
- keyDown('shift+arrow_down');
- keyDownUp('shift+arrow_down'); // makes tick++
- expect(getSelected()).toEqual([3, 0, 4, 0]);
- expect(tick).toEqual(2);
- });
- it('should select columns by click on header with SHIFT key', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- colHeaders: true
- });
- this.$container.find('.ht_clone_top tr:eq(0) th:eq(1)').simulate('mousedown');
- this.$container.find('.ht_clone_top tr:eq(0) th:eq(1)').simulate('mouseup');
- this.$container.find('.ht_clone_top tr:eq(0) th:eq(4)').simulate('mousedown', { shiftKey: true });
- this.$container.find('.ht_clone_top tr:eq(0) th:eq(4)').simulate('mouseup');
- expect(getSelected()).toEqual([0, 1, 4, 4]);
- });
- it('should select rows by click on header with SHIFT key', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- rowHeaders: true
- });
- this.$container.find('.ht_clone_left tr:eq(1) th:eq(0)').simulate('mousedown');
- this.$container.find('.ht_clone_left tr:eq(1) th:eq(0)').simulate('mouseup');
- this.$container.find('.ht_clone_left tr:eq(4) th:eq(0)').simulate('mousedown', { shiftKey: true });
- this.$container.find('.ht_clone_left tr:eq(4) th:eq(0)').simulate('mouseup');
- expect(getSelected()).toEqual([1, 0, 4, 4]);
- });
- it('should select columns by click on header with SHIFT key', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- colHeaders: true
- });
- this.$container.find('.ht_clone_top tr:eq(0) th:eq(1)').simulate('mousedown');
- this.$container.find('.ht_clone_top tr:eq(0) th:eq(1)').simulate('mouseup');
- this.$container.find('.ht_clone_top tr:eq(0) th:eq(4)').simulate('mousedown', { shiftKey: true });
- this.$container.find('.ht_clone_top tr:eq(0) th:eq(4)').simulate('mouseup');
- expect(getSelected()).toEqual([0, 1, 4, 4]);
- });
- it('should change selection after click on row header with SHIFT key', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- rowHeaders: true
- });
- selectCell(1, 1, 3, 3);
- this.$container.find('.ht_clone_left tr:eq(4) th:eq(0)').simulate('mousedown', { shiftKey: true });
- this.$container.find('.ht_clone_left tr:eq(4) th:eq(0)').simulate('mouseup');
- expect(getSelected()).toEqual([1, 0, 4, 4]);
- });
- it('should change selection after click on column header with SHIFT key', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- colHeaders: true
- });
- selectCell(1, 1, 3, 3);
- this.$container.find('.ht_clone_top tr:eq(0) th:eq(4)').simulate('mousedown', { shiftKey: true });
- this.$container.find('.ht_clone_top tr:eq(0) th:eq(4)').simulate('mouseup');
- expect(getSelected()).toEqual([0, 1, 4, 4]);
- });
- it('should call onSelection while user selects cells with mouse; onSelectionEnd when user finishes selection', function () {
- var tick = 0,
- tickEnd = 0;
- handsontable({
- startRows: 5,
- startCols: 5,
- afterSelection: function afterSelection() {
- tick++;
- },
- afterSelectionEnd: function afterSelectionEnd() {
- tickEnd++;
- }
- });
- this.$container.find('tr:eq(0) td:eq(0)').simulate('mousedown');
- this.$container.find('tr:eq(0) td:eq(1)').simulate('mouseover');
- this.$container.find('tr:eq(1) td:eq(3)').simulate('mouseover');
- this.$container.find('tr:eq(1) td:eq(3)').simulate('mouseup');
- expect(getSelected()).toEqual([0, 0, 1, 3]);
- expect(tick).toEqual(3);
- expect(tickEnd).toEqual(1);
- });
- it('should properly select columns, when the user moves the cursor over column headers across two overlays', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- colHeaders: true,
- fixedColumnsLeft: 2
- });
- this.$container.find('.ht_clone_left tr:eq(0) th:eq(1)').simulate('mousedown');
- this.$container.find('.ht_clone_left tr:eq(0) th:eq(1)').simulate('mouseover');
- this.$container.find('.ht_clone_top tr:eq(0) th:eq(2)').simulate('mouseover');
- this.$container.find('.ht_clone_left tr:eq(0) th:eq(1)').simulate('mouseover');
- this.$container.find('.ht_clone_left tr:eq(0) th:eq(1)').simulate('mouseup');
- expect(getSelected()).toEqual([0, 1, 4, 1]);
- });
- it('should move focus to selected cell', function () {
- var $input = $('<input>').appendTo(document.body);
- handsontable({
- startRows: 5,
- startCols: 5
- });
- $input[0].focus();
- selectCell(0, 0);
- keyDownUp('enter');
- expect(isEditorVisible()).toEqual(true);
- $input.remove();
- });
- // This test should cover the #893 case, but it always passes. It seems like the keydown event (with CTRL key pressed) isn't delivered.
- it('should not move focus from outside elements on CTRL keydown event, when no cell is selected', function () {
- var $input = $('<input type="text"/>');
- $('body').append($input);
- handsontable();
- selectCell(0, 0);
- expect(document.activeElement.nodeName).toBeInArray(['BODY', 'HTML']);
- $input.focus();
- expect(document.activeElement.nodeName).toBe('INPUT');
- // var keyDownEvent = $.Event('keydown', {ctrlKey: true, metaKey: true});
- // $input.trigger(keyDownEvent);
- $input.simulate('keydown', { ctrlKey: true, metaKey: true });
- expect(document.activeElement.nodeName).toBe('INPUT');
- $input.remove();
- });
- it('should select the entire column after column header is clicked', function () {
- var hot = handsontable({
- width: 200,
- height: 100,
- startRows: 50,
- startCols: 5,
- colHeaders: true
- });
- this.$container.find('thead th:eq(0)').simulate('mousedown');
- expect(getSelected()).toEqual([0, 0, 49, 0]);
- expect(hot.selection.selectedHeader.rows).toBe(false);
- expect(hot.selection.selectedHeader.cols).toBe(true);
- expect(hot.selection.selectedHeader.corner).toBe(false);
- });
- it('should add classname after select column', function () {
- var hot = handsontable({
- width: 200,
- height: 100,
- startRows: 50,
- startCols: 5,
- colHeaders: true
- });
- this.$container.find('thead th:eq(0)').simulate('mousedown');
- expect(this.$container.hasClass('ht__selection--columns')).toBeTruthy();
- });
- it('should select the entire column after column header is clicked (in fixed rows/cols corner)', function () {
- var hot = handsontable({
- width: 200,
- height: 100,
- startRows: 50,
- startCols: 5,
- colHeaders: true,
- rowHeaders: true,
- fixedRowsTop: 2,
- fixedColumnsLeft: 2
- });
- this.$container.find('.ht_master thead th:eq(1)').simulate('mousedown');
- expect(getSelected()).toEqual([0, 0, 49, 0]);
- expect(hot.selection.selectedHeader.rows).toBe(false);
- expect(hot.selection.selectedHeader.cols).toBe(true);
- expect(hot.selection.selectedHeader.corner).toBe(false);
- });
- it('should select the entire fixed column after column header is clicked, after scroll horizontally', function () {
- var hot = handsontable({
- width: 200,
- height: 100,
- startRows: 50,
- startCols: 50,
- colHeaders: true,
- rowHeaders: true,
- fixedColumnsLeft: 2
- });
- hot.render();
- hot.view.wt.scrollHorizontal(20);
- this.$container.find('.ht_master thead th:eq(2)').simulate('mousedown');
- this.$container.find('.ht_master thead th:eq(2)').simulate('mouseup');
- expect(getSelected()).toEqual([0, 1, 49, 1]);
- expect(hot.selection.selectedHeader.rows).toBe(false);
- expect(hot.selection.selectedHeader.cols).toBe(true);
- expect(hot.selection.selectedHeader.corner).toBe(false);
- });
- it('should set the selection end to the first visible row, when dragging the selection from a cell to a column header', function (done) {
- var hot = handsontable({
- width: 200,
- height: 200,
- startRows: 20,
- startCols: 20,
- colHeaders: true,
- rowHeaders: true
- });
- hot.view.wt.scrollVertical(10);
- hot.view.wt.scrollHorizontal(10);
- hot.render();
- setTimeout(function () {
- $(getCell(12, 11)).simulate('mousedown');
- spec().$container.find('.ht_clone_top thead th:eq(2)').simulate('mouseover');
- }, 30);
- setTimeout(function () {
- expect(getSelected()).toEqual([12, 11, 10, 11]);
- done();
- }, 60);
- });
- it('should set the selection end to the first visible column, when dragging the selection from a cell to a row header', function (done) {
- var hot = handsontable({
- width: 200,
- height: 200,
- startRows: 20,
- startCols: 20,
- colHeaders: true,
- rowHeaders: true
- });
- hot.view.wt.scrollVertical(10);
- hot.view.wt.scrollHorizontal(10);
- hot.render();
- setTimeout(function () {
- $(getCell(12, 11)).simulate('mousedown');
- spec().$container.find('.ht_clone_left tbody th:eq(12)').simulate('mouseover');
- }, 30);
- setTimeout(function () {
- expect(getSelected()).toEqual([12, 11, 12, 10]);
- done();
- }, 60);
- });
- it('should allow to scroll the table when a whole column is selected and table is longer than it\'s container', function (done) {
- var errCount = 0;
- $(window).on('error.selectionTest', function () {
- errCount++;
- });
- var onAfterScrollVertically = jasmine.createSpy('onAfterScrollVertically');
- var hot = handsontable({
- height: 100,
- width: 300,
- startRows: 100,
- startCols: 5,
- colHeaders: true,
- rowHeaders: true,
- afterScrollVertically: onAfterScrollVertically
- });
- var mainHolder = hot.view.wt.wtTable.holder;
- mainHolder.scrollTop = 0;
- this.$container.find('thead tr:eq(0) th:eq(2)').simulate('mousedown');
- this.$container.find('thead tr:eq(0) th:eq(2)').simulate('mouseup');
- mainHolder.scrollTop = 120;
- setTimeout(function () {
- expect(errCount).toEqual(0); // expect no errors to be thrown
- $(window).off('error.selectionTest');
- done();
- }, 100);
- });
- it('should scroll to the end of the selection, when selecting cells using the keyboard', function () {
- var hot = handsontable({
- height: 300,
- width: 300,
- startRows: 50,
- startCols: 50,
- colHeaders: true,
- rowHeaders: true,
- fixedRowsTop: 2,
- fixedColumnsLeft: 2
- });
- var mainHolder = hot.view.wt.wtTable.holder;
- mainHolder.scrollTop = 100;
- selectCell(1, 3);
- keyDownUp('arrow_down');
- expect(mainHolder.scrollTop).toEqual(0);
- mainHolder.scrollTop = 100;
- selectCell(1, 3);
- keyDownUp('shift+arrow_down');
- expect(mainHolder.scrollTop).toEqual(0);
- mainHolder.scrollLeft = 100;
- selectCell(3, 1);
- keyDownUp('arrow_right');
- expect(mainHolder.scrollLeft).toEqual(0);
- mainHolder.scrollLeft = 100;
- selectCell(3, 1);
- keyDownUp('shift+arrow_right');
- expect(mainHolder.scrollLeft).toEqual(0);
- var lastVisibleColumn = hot.view.wt.wtTable.getLastVisibleColumn();
- selectCell(3, lastVisibleColumn);
- keyDownUp('arrow_right');
- expect(hot.view.wt.wtTable.getLastVisibleColumn()).toEqual(lastVisibleColumn + 1);
- keyDownUp('arrow_right');
- expect(hot.view.wt.wtTable.getLastVisibleColumn()).toEqual(lastVisibleColumn + 2);
- keyDownUp('shift+arrow_right');
- expect(hot.view.wt.wtTable.getLastVisibleColumn()).toEqual(lastVisibleColumn + 3);
- var lastVisibleRow = hot.view.wt.wtTable.getLastVisibleRow();
- selectCell(lastVisibleRow, 3);
- keyDownUp('arrow_down');
- expect(hot.view.wt.wtTable.getLastVisibleRow()).toEqual(lastVisibleRow + 1);
- keyDownUp('arrow_down');
- expect(hot.view.wt.wtTable.getLastVisibleRow()).toEqual(lastVisibleRow + 2);
- keyDownUp('shift+arrow_down');
- expect(hot.view.wt.wtTable.getLastVisibleRow()).toEqual(lastVisibleRow + 3);
- });
- it('should select the entire row after row header is clicked', function () {
- var hot = handsontable({
- startRows: 5,
- startCols: 5,
- colHeaders: true,
- rowHeaders: true
- });
- this.$container.find('tr:eq(2) th:eq(0)').simulate('mousedown');
- expect(getSelected()).toEqual([1, 0, 1, 4]);
- expect(hot.selection.selectedHeader.rows).toBe(true);
- expect(hot.selection.selectedHeader.cols).toBe(false);
- expect(hot.selection.selectedHeader.corner).toBe(false);
- });
- it('should add classname after select row', function () {
- var hot = handsontable({
- width: 200,
- height: 100,
- startRows: 50,
- startCols: 5,
- rowHeaders: true
- });
- this.$container.find('tbody tr:eq(0) th:eq(0)').simulate('mousedown');
- expect(this.$container.hasClass('ht__selection--rows')).toBeTruthy();
- });
- it('should select the entire row of a partially fixed table after row header is clicked', function () {
- handsontable({
- startRows: 5,
- startCols: 5,
- colHeaders: true,
- rowHeaders: true,
- fixedRowsTop: 2,
- fixedColumnsLeft: 2
- });
- this.$container.find('tr:eq(2) th:eq(0)').simulate('mousedown');
- expect(getSelected()).toEqual([1, 0, 1, 4]);
- this.$container.find('tr:eq(3) th:eq(0)').simulate('mousedown');
- expect(getSelected()).toEqual([2, 0, 2, 4]);
- });
- it('should select a cell in a newly added row after automatic row adding, triggered by editing a cell in the last row with minSpareRows > 0, ' + 'unless editing happened within the fixed bottom rows', function (done) {
- var hot = handsontable({
- startRows: 5,
- startCols: 2,
- minSpareRows: 1
- });
- setTimeout(function () {
- selectCell(4, 0);
- keyDownUp('enter');
- }, 10);
- setTimeout(function () {
- keyDownUp('enter');
- }, 100);
- setTimeout(function () {
- expect(countRows()).toEqual(6);
- expect(getSelected()).toEqual([5, 0, 5, 0]);
- }, 200);
- setTimeout(function () {
- done();
- }, 250);
- });
- it('should change selected coords by modifying coords object via `modifyTransformStart` hook', function () {
- var hot = handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(0, 0);
- hot.addHook('modifyTransformStart', function (coords) {
- coords.col += 1;
- coords.row += 1;
- });
- keyDown('arrow_down');
- expect(getSelected()).toEqual([2, 1, 2, 1]);
- });
- it('should change selected coords by modifying coords object via `modifyTransformEnd` hook', function () {
- var hot = handsontable({
- startRows: 5,
- startCols: 5
- });
- selectCell(0, 0);
- hot.addHook('modifyTransformEnd', function (coords) {
- coords.col += 2;
- coords.row += 1;
- });
- keyDown('shift+arrow_down');
- expect(getSelected()).toEqual([0, 0, 2, 2]);
- });
- it('should indicate is coords is out of bounds via `afterModifyTransformStart` hook', function () {
- var spy = jasmine.createSpy();
- var hot = handsontable({
- startRows: 5,
- startCols: 5
- });
- hot.addHook('afterModifyTransformStart', spy);
- selectCell(2, 0);
- keyDownUp('arrow_left');
- expect(spy.calls.mostRecent().args[1]).toBe(0);
- expect(spy.calls.mostRecent().args[2]).toBe(-1);
- spy.calls.reset();
- selectCell(2, 4);
- keyDownUp('arrow_right');
- expect(spy.calls.mostRecent().args[1]).toBe(0);
- expect(spy.calls.mostRecent().args[2]).toBe(1);
- spy.calls.reset();
- selectCell(4, 2);
- keyDownUp('arrow_down');
- expect(spy.calls.mostRecent().args[1]).toBe(1);
- expect(spy.calls.mostRecent().args[2]).toBe(0);
- spy.calls.reset();
- selectCell(0, 2);
- keyDownUp('arrow_up');
- expect(spy.calls.mostRecent().args[1]).toBe(-1);
- expect(spy.calls.mostRecent().args[2]).toBe(0);
- });
- it('should indicate is coords is out of bounds via `afterModifyTransformEnd` hook', function () {
- var spy = jasmine.createSpy();
- var hot = handsontable({
- startRows: 5,
- startCols: 5
- });
- hot.addHook('afterModifyTransformEnd', spy);
- selectCell(2, 0);
- keyDownUp('shift+arrow_left');
- expect(spy.calls.mostRecent().args[1]).toBe(0);
- expect(spy.calls.mostRecent().args[2]).toBe(-1);
- spy.calls.reset();
- selectCell(2, 4);
- keyDownUp('shift+arrow_right');
- expect(spy.calls.mostRecent().args[1]).toBe(0);
- expect(spy.calls.mostRecent().args[2]).toBe(1);
- spy.calls.reset();
- selectCell(4, 2);
- keyDownUp('shift+arrow_down');
- expect(spy.calls.mostRecent().args[1]).toBe(1);
- expect(spy.calls.mostRecent().args[2]).toBe(0);
- spy.calls.reset();
- selectCell(0, 2);
- keyDownUp('shift+arrow_up');
- expect(spy.calls.mostRecent().args[1]).toBe(-1);
- expect(spy.calls.mostRecent().args[2]).toBe(0);
- });
- it('should change selection after left mouse button on one of selected cell', function () {
- var hot = handsontable({
- startRows: 5,
- startCols: 5
- });
- var cells = $('.ht_master.handsontable td');
- cells.eq(6).simulate('mousedown');
- cells.eq(18).simulate('mouseover');
- cells.eq(18).simulate('mouseup');
- expect(hot.getSelected()).toEqual([1, 1, 3, 3]);
- cells.eq(16).simulate('mousedown');
- cells.eq(16).simulate('mouseup');
- expect(hot.getSelected()).toEqual([3, 1, 3, 1]);
- });
- it('should select the first row after corner header is clicked', function () {
- var hot = handsontable({
- startRows: 5,
- startCols: 5,
- colHeaders: true,
- rowHeaders: true
- });
- this.$container.find('thead').find('th').eq(0).simulate('mousedown');
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- expect(hot.selection.selectedHeader.rows).toBe(false);
- expect(hot.selection.selectedHeader.cols).toBe(false);
- expect(hot.selection.selectedHeader.corner).toBe(true);
- });
- it('should redraw selection when option `colHeaders` is set and user scrolled', function (done) {
- var hot = handsontable({
- startRows: 20,
- startCols: 20,
- colHeaders: true,
- rowHeaders: true,
- width: 400,
- height: 200
- });
- var cellVerticalPosition;
- var borderOffsetInPixels = 1;
- var topBorder;
- selectCell(5, 5);
- hot.view.wt.wtOverlays.topOverlay.scrollTo(2);
- setTimeout(function () {
- cellVerticalPosition = hot.getCell(5, 5).offsetTop;
- topBorder = $('.wtBorder.current')[0];
- expect(topBorder.offsetTop).toEqual(cellVerticalPosition - borderOffsetInPixels);
- hot.view.wt.wtOverlays.topOverlay.scrollTo(0);
- }, 100);
- setTimeout(function () {
- cellVerticalPosition = hot.getCell(5, 5).offsetTop;
- topBorder = $('.wtBorder.current')[0];
- expect(topBorder.offsetTop).toEqual(cellVerticalPosition - borderOffsetInPixels);
- done();
- }, 200);
- });
- it('should redraw selection on `leftOverlay` when options `colHeaders` and `fixedColumnsLeft` are set, and user scrolled', function (done) {
- var hot = handsontable({
- fixedColumnsLeft: 2,
- startRows: 20,
- startCols: 20,
- colHeaders: true,
- rowHeaders: true,
- width: 400,
- height: 200
- });
- var cellVerticalPosition;
- var borderOffsetInPixels = 1;
- var topBorder;
- selectCell(1, 0);
- hot.view.wt.wtOverlays.topOverlay.scrollTo(5);
- setTimeout(function () {
- cellVerticalPosition = hot.getCell(1, 0).offsetTop;
- topBorder = $('.wtBorder.current')[0];
- expect(topBorder.offsetTop).toEqual(cellVerticalPosition - borderOffsetInPixels);
- hot.view.wt.wtOverlays.topOverlay.scrollTo(0);
- }, 100);
- setTimeout(function () {
- cellVerticalPosition = hot.getCell(1, 0).offsetTop;
- topBorder = $('.wtBorder.current')[0];
- expect(topBorder.offsetTop).toEqual(cellVerticalPosition - borderOffsetInPixels);
- done();
- }, 200);
- });
- });
- /***/ }),
- /* 177 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_setDataAtCell', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfNestedObjects = function arrayOfNestedObjects() {
- return [{ id: 1,
- name: {
- first: 'Ted',
- last: 'Right'
- } }, { id: 2,
- name: {
- first: 'Frank',
- last: 'Honest'
- } }, { id: 3,
- name: {
- first: 'Joan',
- last: 'Well'
- } }];
- };
- var htmlText = 'Ben & Jerry\'s';
- it('HTML special chars should be preserved in data map but escaped in DOM', function () {
- // https://github.com/handsontable/handsontable/issues/147
- handsontable();
- var td = setDataAtCell(0, 0, htmlText);
- selectCell(0, 0);
- $(td).simulate('dblclick');
- deselectCell();
- expect(getDataAtCell(0, 0)).toEqual(htmlText);
- });
- it('should correctly paste string that contains "quotes"', function (done) {
- // https://github.com/handsontable/handsontable/issues/205
- handsontable({});
- selectCell(0, 0);
- triggerPaste('1\nThis is a "test" and a test\n2');
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toEqual('1');
- expect(getDataAtCell(1, 0)).toEqual('This is a "test" and a test');
- expect(getDataAtCell(2, 0)).toEqual('2');
- done();
- }, 200);
- });
- it('should correctly paste string when dataSchema is used', function (done) {
- // https://github.com/handsontable/handsontable/issues/237
- handsontable({
- colHeaders: true,
- dataSchema: {
- col1: null,
- col2: null,
- col3: null
- }
- });
- selectCell(0, 0);
- triggerPaste('1\tTest\t2');
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toEqual('1');
- expect(getDataAtCell(0, 1)).toEqual('Test');
- expect(getDataAtCell(0, 2)).toEqual('2');
- done();
- }, 200);
- });
- it('should paste not more rows than maxRows', function (done) {
- handsontable({
- minSpareRows: 1,
- minRows: 5,
- maxRows: 10
- });
- selectCell(4, 0);
- triggerPaste('1\n2\n3\n4\n5\n6\n7\n8\n9\n10');
- setTimeout(function () {
- expect(countRows()).toEqual(10);
- expect(getDataAtCell(9, 0)).toEqual('6');
- done();
- }, 200);
- });
- it('should paste not more cols than maxCols', function (done) {
- handsontable({
- minSpareCols: 1,
- minCols: 5,
- maxCols: 10
- });
- selectCell(0, 4);
- triggerPaste('1\t2\t3\t4\t5\t6\t7\t8\t9\t10');
- setTimeout(function () {
- expect(countCols()).toEqual(10);
- expect(getDataAtCell(0, 9)).toEqual('6');
- done();
- }, 200);
- });
- it('should paste not more rows & cols than maxRows & maxCols', function (done) {
- handsontable({
- minSpareRows: 1,
- minSpareCols: 1,
- minRows: 5,
- minCols: 5,
- maxRows: 6,
- maxCols: 6
- });
- selectCell(4, 4);
- triggerPaste('1\t2\t3\n4\t5\t6\n7\t8\t9');
- setTimeout(function () {
- expect(countRows()).toEqual(6);
- expect(countCols()).toEqual(6);
- expect(getDataAtCell(5, 5)).toEqual('5');
- done();
- }, 200);
- });
- // https://github.com/handsontable/handsontable/issues/250
- it('should create new rows when pasting into grid with object data source', function (done) {
- handsontable({
- data: arrayOfNestedObjects(),
- colHeaders: true,
- columns: [{ data: 'id' }, { data: 'name.last' }, { data: 'name.first' }],
- minSpareRows: 1
- });
- selectCell(3, 0);
- triggerPaste('a\tb\tc\nd\te\tf\ng\th\ti');
- setTimeout(function () {
- expect(countRows()).toEqual(7);
- expect(getDataAtCell(5, 2)).toEqual('i');
- done();
- }, 200);
- });
- // https://handsontable.com/demo/datasources.html
- it('should work with functional data source', function () {
- handsontable({
- data: [model({ id: 1, name: 'Ted Right', address: '' }), model({ id: 2, name: 'Frank Honest', address: '' }), model({ id: 3, name: 'Joan Well', address: '' })],
- dataSchema: model,
- startRows: 5,
- startCols: 3,
- colHeaders: ['ID', 'Name', 'Address'],
- columns: [{ data: property('id') }, { data: property('name') }, { data: property('address') }],
- minSpareRows: 1
- });
- function model(opts) {
- var _pub = {},
- _priv = $.extend({
- id: undefined,
- name: undefined,
- address: undefined
- }, opts);
- _pub.attr = function (attr, val) {
- if (typeof val === 'undefined') {
- return _priv[attr];
- }
- _priv[attr] = val;
- return _pub;
- };
- return _pub;
- }
- function property(attr) {
- return function (row, value) {
- return row.attr(attr, value);
- };
- }
- expect(getDataAtCell(1, 1)).toEqual('Frank Honest');
- setDataAtCell(1, 1, 'Something Else');
- expect(getDataAtCell(1, 1)).toEqual('Something Else');
- });
- it('should accept changes array as 1st param and source as 2nd param', function () {
- var callCount = 0,
- lastSource = '';
- handsontable({
- afterChange: function afterChange(changes, source) {
- callCount++;
- lastSource = source;
- }
- });
- setDataAtCell([[0, 0, 'new value']], 'customSource');
- expect(getDataAtCell(0, 0)).toEqual('new value');
- expect(lastSource).toEqual('customSource');
- });
- it('should trigger `afterSetDataAtCell` hook with applied changes', function () {
- var _changes;
- var _source;
- handsontable({
- afterSetDataAtCell: function afterSetDataAtCell(changes, source) {
- _changes = changes;
- _source = source;
- }
- });
- setDataAtCell(0, 0, 'foo bar', 'customSource');
- expect(_changes).toEqual([[0, 0, null, 'foo bar']]);
- expect(_source).toBe('customSource');
- expect(getDataAtCell(0, 0)).toEqual('foo bar');
- });
- it('should modify value on the fly using `afterSetDataAtCell` hook', function () {
- handsontable({
- data: [['a', 'b', 'c'], [1, 2, 3]],
- afterSetDataAtCell: function afterSetDataAtCell(changes, source) {
- if (changes[0][3] === 'foo bar') {
- changes[0][3] = 'bar';
- }
- if (changes[0][3] === 22) {
- changes[0][3] = 33;
- }
- }
- });
- setDataAtCell(0, 0, 'foo bar', 'customSource');
- setDataAtCell(1, 2, 22, 'customSource');
- expect(getDataAtCell(0, 0)).toBe('bar');
- expect(getDataAtCell(1, 2)).toBe(33);
- expect(getData()).toEqual([['bar', 'b', 'c'], [1, 2, 33]]);
- });
- it('should trigger `afterSetDataAtRowProp` hook with applied changes', function () {
- var _changes;
- var _source;
- handsontable({
- columns: [{ data: 'name' }, { data: 'id' }],
- afterSetDataAtRowProp: function afterSetDataAtRowProp(changes, source) {
- _changes = changes;
- _source = source;
- }
- });
- setDataAtRowProp(0, 'name', 'foo bar', 'customSource');
- expect(_changes).toEqual([[0, 'name', void 0, 'foo bar']]);
- expect(_source).toBe('customSource');
- expect(getDataAtCell(0, 0)).toBe('foo bar');
- });
- it('should modify value on the fly using `afterSetDataAtRowProp` hook', function () {
- handsontable({
- data: [{ name: 'a', id: 1 }, { name: 'b', id: 2 }, { name: 'c', id: 3 }],
- columns: [{ data: 'name' }, { data: 'id' }],
- afterSetDataAtRowProp: function afterSetDataAtRowProp(changes, source) {
- if (changes[0][3] === 'foo bar') {
- changes[0][3] = 'bar';
- }
- if (changes[0][3] === 22) {
- changes[0][3] = 33;
- }
- }
- });
- setDataAtRowProp(0, 'name', 'foo bar', 'customSource');
- setDataAtRowProp(1, 'id', 22, 'customSource');
- expect(getDataAtRowProp(0, 'name')).toEqual('bar');
- expect(getDataAtRowProp(1, 'id')).toBe(33);
- expect(getData()).toEqual([['bar', 1], ['b', 33], ['c', 3]]);
- });
- });
- /***/ }),
- /* 178 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_splice', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfArrays = function arrayOfArrays() {
- return [['', 'Kia', 'Nissan', 'Toyota', 'Honda'], ['2008', 10, 11, 12, 13], ['2009', 20, 11, 14, 13], ['2010', 30, 15, 12, 13]];
- };
- describe('spliceCol', function () {
- it('should remove data from specified col', function () {
- handsontable({
- data: arrayOfArrays(),
- minSpareRows: 1
- });
- expect(spliceCol(1, 0, 2)).toEqual(['Kia', 10]);
- expect(getData(0, 1, 3, 1)).toEqual([[20], [30], [null], [null]]);
- });
- it('should insert data into specified col', function () {
- handsontable({
- data: arrayOfArrays(),
- minSpareRows: 1
- });
- expect(spliceCol(1, 1, 0, 'test', 'test', 'test')).toEqual([]);
- expect(getData(0, 1, 6, 1)).toEqual([['Kia'], ['test'], ['test'], ['test'], [10], [20], [30]]);
- });
- it('should remove and insert data into specified col', function () {
- handsontable({
- data: arrayOfArrays(),
- minSpareRows: 1
- });
- expect(spliceCol(1, 0, 2, 'test', 'test', 'test')).toEqual(['Kia', 10]);
- expect(getData(0, 1, 4, 1)).toEqual([['test'], ['test'], ['test'], [20], [30]]);
- });
- });
- describe('spliceRow', function () {
- it('should remove data from specified row', function () {
- handsontable({
- data: arrayOfArrays(),
- minSpareCols: 1
- });
- expect(spliceRow(0, 0, 3)).toEqual(['', 'Kia', 'Nissan']);
- expect(getData(0, 0, 0, 4)).toEqual([['Toyota', 'Honda', null, null, null]]);
- });
- it('should insert data into specified row', function () {
- handsontable({
- data: arrayOfArrays(),
- minSpareCols: 1
- });
- expect(spliceRow(0, 0, 0, 'test', 'test', 'test')).toEqual([]);
- expect(getData(0, 0, 0, 7)).toEqual([['test', 'test', 'test', '', 'Kia', 'Nissan', 'Toyota', 'Honda']]);
- });
- it('should remove and insert data into specified row', function () {
- handsontable({
- data: arrayOfArrays(),
- minSpareCols: 1
- });
- expect(spliceRow(0, 0, 2, 'test', 'test', 'test')).toEqual(['', 'Kia']);
- expect(getData(0, 0, 0, 5)).toEqual([['test', 'test', 'test', 'Nissan', 'Toyota', 'Honda']]);
- });
- });
- });
- /***/ }),
- /* 179 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_updateSettings', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should inherit cell type', function () {
- handsontable({
- data: [[1, 2]],
- columns: [{}, { type: 'checkbox' }],
- cells: function cells(row, col, prop) {
- if (row === 0 && col === 0) {
- return {
- type: 'numeric'
- };
- }
- }
- });
- expect(getCellMeta(0, 0).type).toEqual('numeric');
- expect(getCellMeta(0, 1).type).toEqual('checkbox');
- });
- it('should inherit cell type when columns is a function', function () {
- handsontable({
- data: [[1, 2]],
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = {};
- } else if (column === 1) {
- colMeta = { type: 'checkbox' };
- }
- return colMeta;
- },
- cells: function cells(row, col, prop) {
- if (row === 0 && col === 0) {
- return {
- type: 'numeric'
- };
- }
- }
- });
- expect(getCellMeta(0, 0).type).toEqual('numeric');
- expect(getCellMeta(0, 1).type).toEqual('checkbox');
- });
- it('should ignore mixed in properties to the cell array option', function () {
- /* eslint-disable no-array-constructor */
- /* eslint-disable no-extend-native */
- Array.prototype.willFail = 'BOOM';
- handsontable({
- data: [[1, true]],
- columns: [{ type: 'numeric' }, { type: 'checkbox' }]
- });
- expect(function () {
- updateSettings({ cell: new Array() });
- }).not.toThrow();
- });
- it('should ignore mixed in properties to the cell array option when columns is a function', function () {
- /* eslint-disable no-array-constructor */
- /* eslint-disable no-extend-native */
- Array.prototype.willFail = 'BOOM';
- handsontable({
- data: [[1, true]],
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = { type: 'numeric' };
- } else if (column === 1) {
- colMeta = { type: 'checkbox' };
- }
- return colMeta;
- }
- });
- expect(function () {
- updateSettings({ cell: new Array() });
- }).not.toThrow();
- });
- it('should not reset columns types to text', function () {
- handsontable({
- data: [[1, true]],
- columns: [{ type: 'numeric' }, { type: 'checkbox' }]
- });
- var td = this.$container.find('td');
- expect(td.eq(0).text()).toEqual('1');
- expect(td.eq(1).text()).toEqual('');
- updateSettings({});
- expect(td.eq(0).text()).toEqual('1');
- expect(td.eq(1).text()).toEqual('');
- });
- it('should not reset columns types to text when columns is a function', function () {
- handsontable({
- data: [[1, true]],
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = { type: 'numeric' };
- } else if (column === 1) {
- colMeta = { type: 'checkbox' };
- }
- return colMeta;
- }
- });
- var td = this.$container.find('td');
- expect(td.eq(0).text()).toEqual('1');
- expect(td.eq(1).text()).toEqual('');
- updateSettings({});
- expect(td.eq(0).text()).toEqual('1');
- expect(td.eq(1).text()).toEqual('');
- });
- it('should update readOnly global setting', function () {
- handsontable({
- readOnly: true,
- data: [['foo', 'bar']],
- columns: [{}, {}]
- });
- expect(getCellMeta(0, 0).readOnly).toBe(true);
- expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(true);
- expect(getCellMeta(0, 1).readOnly).toBe(true);
- expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(true);
- updateSettings({
- readOnly: false
- });
- expect(getCellMeta(0, 0).readOnly).toBe(false);
- expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(false);
- expect(getCellMeta(0, 1).readOnly).toBe(false);
- expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(false);
- });
- it('should update readOnly global setting when columns is a function', function () {
- handsontable({
- readOnly: true,
- data: [['foo', 'bar']],
- columns: function columns(column) {
- var colMeta = {};
- if ([0, 1].indexOf(column) < 0) {
- colMeta = null;
- }
- return colMeta;
- }
- });
- expect(getCellMeta(0, 0).readOnly).toBe(true);
- expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(true);
- expect(getCellMeta(0, 1).readOnly).toBe(true);
- expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(true);
- updateSettings({
- readOnly: false
- });
- expect(getCellMeta(0, 0).readOnly).toBe(false);
- expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(false);
- expect(getCellMeta(0, 1).readOnly).toBe(false);
- expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(false);
- });
- it('should update readOnly columns setting', function () {
- handsontable({
- data: [['foo', true]],
- columns: [{ type: 'text', readOnly: true }, { type: 'checkbox' }]
- });
- expect(getCellMeta(0, 0).readOnly).toBe(true);
- expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(true);
- expect(getCellMeta(0, 1).readOnly).toBe(false);
- expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(false);
- updateSettings({
- columns: [{ type: 'text', readOnly: false }, { type: 'checkbox' }]
- });
- expect(getCellMeta(0, 0).readOnly).toBe(false);
- expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(false);
- expect(getCellMeta(0, 1).readOnly).toBe(false);
- expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(false);
- });
- it('should update readOnly columns setting when columns is a function', function () {
- handsontable({
- data: [['foo', true]],
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = { type: 'text', readOnly: true };
- } else if (column === 1) {
- colMeta = { type: 'checkbox' };
- }
- return colMeta;
- }
- });
- expect(getCellMeta(0, 0).readOnly).toBe(true);
- expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(true);
- expect(getCellMeta(0, 1).readOnly).toBe(false);
- expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(false);
- updateSettings({
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = { type: 'text', readOnly: false };
- } else if (column === 1) {
- colMeta = { type: 'checkbox' };
- }
- return colMeta;
- }
- });
- expect(getCellMeta(0, 0).readOnly).toBe(false);
- expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(false);
- expect(getCellMeta(0, 1).readOnly).toBe(false);
- expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(false);
- });
- it('should update readOnly columns setting and override global setting', function () {
- handsontable({
- readOnly: true,
- data: [['foo', true]],
- columns: [{ type: 'text' }, { type: 'checkbox' }]
- });
- expect(getCellMeta(0, 0).readOnly).toBe(true);
- expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(true);
- expect(getCellMeta(0, 1).readOnly).toBe(true);
- expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(true);
- updateSettings({
- columns: [{ type: 'text', readOnly: false }, { type: 'checkbox' }]
- });
- expect(getCellMeta(0, 0).readOnly).toBe(false);
- expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(false);
- expect(getCellMeta(0, 1).readOnly).toBe(true);
- expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(true);
- });
- it('should update readOnly columns setting and override global setting when columns is a function', function () {
- handsontable({
- readOnly: true,
- data: [['foo', true]],
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = { type: 'text' };
- } else if (column === 1) {
- colMeta = { type: 'checkbox' };
- }
- return colMeta;
- }
- });
- expect(getCellMeta(0, 0).readOnly).toBe(true);
- expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(true);
- expect(getCellMeta(0, 1).readOnly).toBe(true);
- expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(true);
- updateSettings({
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = { type: 'text', readOnly: false };
- } else if (column === 1) {
- colMeta = { type: 'checkbox' };
- }
- return colMeta;
- }
- });
- expect(getCellMeta(0, 0).readOnly).toBe(false);
- expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(false);
- expect(getCellMeta(0, 1).readOnly).toBe(true);
- expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(true);
- });
- it('should not alter the columns object during init', function () {
- var columns = [{
- type: 'text'
- }];
- var columnsCopy = JSON.parse(JSON.stringify(columns));
- handsontable({
- columns: columns
- });
- expect(columns).toEqual(columnsCopy);
- });
- it('should update column type', function () {
- var columns = [{
- type: 'text'
- }];
- handsontable({
- columns: columns
- });
- expect(getCellMeta(0, 0).type).toEqual('text');
- expect(getCellRenderer(0, 0)).toBe(Handsontable.renderers.TextRenderer);
- expect(getCellEditor(0, 0)).toBe(Handsontable.editors.TextEditor);
- columns[0].type = 'date';
- updateSettings({
- columns: columns
- });
- expect(getCellMeta(0, 0).type).toEqual('date');
- expect(getCellRenderer(0, 0)).toBe(Handsontable.renderers.AutocompleteRenderer);
- expect(getCellEditor(0, 0)).toEqual(Handsontable.editors.DateEditor);
- });
- it('should update cell type functions, even if new type does not implement all of those functions', function () {
- var columns = [{
- type: 'numeric'
- }];
- handsontable({
- columns: columns
- });
- expect(getCellMeta(0, 0).type).toEqual('numeric');
- expect(getCellRenderer(0, 0)).toBe(Handsontable.renderers.NumericRenderer);
- expect(getCellEditor(0, 0)).toBe(Handsontable.editors.NumericEditor);
- expect(getCellValidator(0, 0)).toBe(Handsontable.cellTypes.numeric.validator);
- columns[0].type = 'text';
- updateSettings({
- columns: columns
- });
- expect(getCellMeta(0, 0).type).toEqual('text');
- expect(getCellRenderer(0, 0)).toBe(Handsontable.renderers.TextRenderer);
- expect(getCellEditor(0, 0)).toEqual(Handsontable.editors.TextEditor);
- expect(Handsontable.cellTypes.text.validator).toBeUndefined();
- expect(getCellValidator(0, 0)).toBeUndefined();
- });
- it('should allow updating the table height', function () {
- var hot = handsontable({
- startRows: 22,
- startCols: 5
- });
- var initialHeight = parseInt(this.$container[0].style.height, 10);
- updateSettings({
- height: 300
- });
- expect(parseInt(this.$container[0].style.height, 10)).toEqual(300);
- expect(parseInt(this.$container[0].style.height, 10)).not.toEqual(initialHeight);
- });
- it('should not reset the table height, when the updateSettings config object doesn\'t have any height specified', function () {
- var hot = handsontable({
- startRows: 22,
- startCols: 5,
- height: 300
- });
- var initialHeight = this.$container[0].style.height;
- updateSettings({
- rowHeaders: true
- });
- expect(parseInt(this.$container[0].style.height, 10)).toEqual(parseInt(initialHeight, 10));
- });
- it('should allow resetting the table height', function () {
- var hot = handsontable({
- startRows: 22,
- startCols: 5,
- height: 300
- });
- var initialHeight = this.$container[0].style.height;
- updateSettings({
- height: null
- });
- expect(parseInt(this.$container[0].style.height, 10)).not.toEqual(parseInt(initialHeight, 10));
- });
- it('should allow updating the stretching type', function () {
- var hot = handsontable({
- stretchH: 'last'
- });
- expect(hot.view.wt.getSetting('stretchH')).toEqual('last');
- updateSettings({
- stretchH: 'all'
- });
- expect(hot.view.wt.getSetting('stretchH')).toEqual('all');
- updateSettings({
- stretchH: 'none'
- });
- expect(hot.view.wt.getSetting('stretchH')).toEqual('none');
- updateSettings({
- stretchH: 'last'
- });
- expect(hot.view.wt.getSetting('stretchH')).toEqual('last');
- });
- it('should change colHeader\'s row height if is needed', function () {
- var hot = handsontable({
- colHeaders: true,
- rowHeaders: true
- });
- var rowHeights = [];
- rowHeights.push(this.$container.find('.ht_clone_top_left_corner thead th')[0].clientHeight);
- updateSettings({
- colHeaders: ['A<br/>A']
- });
- rowHeights.push(this.$container.find('.ht_clone_top_left_corner thead th')[0].clientHeight);
- expect(rowHeights[0]).toBeLessThan(rowHeights[1]);
- });
- it('should not overwrite properties (created by columns defined as function) of cells below the viewport by updateSettings #4029', function () {
- var rows = 50;
- var columns = 2;
- handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(columns, rows),
- columns: function columns(col) {
- var colProp = {
- data: 'prop' + col,
- readOnly: true
- };
- if (col === 1) {
- colProp.type = 'checkbox';
- }
- return colProp;
- }
- });
- updateSettings({});
- expect(getCellMeta(rows, 0).readOnly).toEqual(true);
- expect(getCellMeta(rows, 1).type).toEqual('checkbox');
- rows = 100;
- updateSettings({ data: Handsontable.helper.createSpreadsheetObjectData(columns, rows) });
- expect(getCellMeta(rows, 0).readOnly).toEqual(true);
- expect(getCellMeta(rows, 1).type).toEqual('checkbox');
- updateSettings({
- columns: function columns(col) {
- var colProp = {
- data: 'prop' + col,
- type: 'numeric'
- };
- return colProp;
- }
- });
- expect(getCellMeta(0, 1).type).toEqual('numeric');
- expect(getCellMeta(0, 1).readOnly).toEqual(false);
- expect(getCellMeta(rows, 1).type).toEqual('numeric');
- expect(getCellMeta(rows, 1).readOnly).toEqual(false);
- });
- it('should not overwrite properties (created by columns defined as array) of cells below the viewport by updateSettings #4029', function () {
- var rows = 50;
- var columns = 2;
- handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(columns, rows),
- columns: [{
- type: 'numeric',
- format: '0,0.00 $'
- }, {
- type: 'text',
- readOnly: true
- }]
- });
- updateSettings({});
- expect(getCellMeta(rows, 0).type).toEqual('numeric');
- expect(getCellMeta(rows, 1).readOnly).toEqual(true);
- rows = 100;
- updateSettings({ data: Handsontable.helper.createSpreadsheetObjectData(columns, rows) });
- expect(getCellMeta(rows, 0).type).toEqual('numeric');
- expect(getCellMeta(rows, 1).readOnly).toEqual(true);
- updateSettings({
- columns: [{
- type: 'text',
- readOnly: true
- }, {
- type: 'numeric',
- format: '0,0.00 $'
- }]
- });
- expect(getCellMeta(0, 0).type).toEqual('text');
- expect(getCellMeta(0, 0).readOnly).toEqual(true);
- expect(getCellMeta(0, 1).type).toEqual('numeric');
- expect(getCellMeta(0, 1).readOnly).toEqual(false);
- expect(getCellMeta(rows, 0).type).toEqual('text');
- expect(getCellMeta(rows, 1).type).toEqual('numeric');
- });
- });
- /***/ }),
- /* 180 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_validate', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfObjects = function arrayOfObjects() {
- return [{ id: 1, name: 'Ted', lastName: 'Right' }, { id: 2, name: 'Frank', lastName: 'Honest' }, { id: 3, name: 'Joan', lastName: 'Well' }, { id: 4, name: 'Sid', lastName: 'Strong' }, { id: 5, name: 'Jane', lastName: 'Neat' }, { id: 6, name: 'Chuck', lastName: 'Jackson' }, { id: 7, name: 'Meg', lastName: 'Jansen' }, { id: 8, name: 'Rob', lastName: 'Norris' }, { id: 9, name: 'Sean', lastName: 'O\'Hara' }, { id: 10, name: 'Eve', lastName: 'Branson' }];
- };
- it('should call beforeValidate', function () {
- var fired = null;
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric' }, { data: 'name' }, { data: 'lastName' }],
- beforeValidate: function beforeValidate() {
- fired = true;
- }
- });
- setDataAtCell(2, 0, 'test');
- expect(fired).toEqual(true);
- });
- it('should call beforeValidate when columns is a function', function () {
- var fired = null;
- handsontable({
- data: arrayOfObjects(),
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = 'id';
- colMeta.type = 'numeric';
- } else if (column === 1) {
- colMeta.data = 'name';
- } else if (column === 2) {
- colMeta.data = 'lastName';
- } else {
- colMeta = null;
- }
- return colMeta;
- },
- beforeValidate: function beforeValidate() {
- fired = true;
- }
- });
- setDataAtCell(2, 0, 'test');
- expect(fired).toBe(true);
- });
- it('should call afterValidate', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, 'test');
- setTimeout(function () {
- expect(onAfterValidate.calls.count()).toBe(1);
- done();
- }, 200);
- });
- it('should call afterValidate when columns is a function', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = 'id';
- colMeta.type = 'numeric';
- } else if (column === 1) {
- colMeta.data = 'name';
- } else if (column === 2) {
- colMeta.data = 'lastName';
- } else {
- colMeta = null;
- }
- return colMeta;
- },
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, 'test');
- setTimeout(function () {
- expect(onAfterValidate.calls.count()).toBe(1);
- done();
- }, 200);
- });
- it('beforeValidate can manipulate value', function (done) {
- var result = null;
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- onAfterValidate.and.callFake(function (valid, value) {
- result = value;
- });
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric' }, { data: 'name' }, { data: 'lastName' }],
- beforeValidate: function beforeValidate(value) {
- value = 999;
- return value;
- },
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, 123);
- setTimeout(function () {
- expect(result).toBe(999);
- done();
- }, 200);
- });
- it('beforeValidate can manipulate value when columns is a function', function (done) {
- var result = null;
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- onAfterValidate.and.callFake(function (valid, value) {
- result = value;
- });
- handsontable({
- data: arrayOfObjects(),
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.data = 'id';
- colMeta.type = 'numeric';
- } else if (column === 1) {
- colMeta.data = 'name';
- } else if (column === 2) {
- colMeta.data = 'lastName';
- } else {
- colMeta = null;
- }
- return colMeta;
- },
- beforeValidate: function beforeValidate(value) {
- value = 999;
- return value;
- },
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, 123);
- setTimeout(function () {
- expect(result).toBe(999);
- done();
- }, 200);
- });
- it('should be able to define custom validator function', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id',
- validator: function validator(value, cb) {
- cb(true);
- }
- }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, 123);
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, 123, 2, 'id', undefined, undefined);
- done();
- }, 200);
- });
- it('should be able to define custom validator function when columns is a function', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = {
- data: 'id',
- validator: function validator(value, cb) {
- cb(true);
- }
- };
- } else if (column === 1) {
- colMeta = { data: 'name' };
- } else if (column === 2) {
- colMeta = { data: 'lastName' };
- }
- return colMeta;
- },
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, 123);
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, 123, 2, 'id', undefined, undefined);
- done();
- }, 200);
- });
- it('should be able to define custom validator RegExp', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', validator: /^\d+$/ }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, 'test');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, 'test', 2, 'id', undefined, undefined);
- done();
- }, 200);
- });
- it('should be able to define custom validator RegExp when columns is a function', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = { data: 'id', validator: /^\d+$/ };
- } else if (column === 1) {
- colMeta = { data: 'name' };
- } else if (column === 2) {
- colMeta = { data: 'lastName' };
- }
- return colMeta;
- },
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, 'test');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, 'test', 2, 'id', undefined, undefined);
- done();
- }, 200);
- });
- it('this in validator should point to cellProperties', function (done) {
- var result = null;
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{
- data: 'id',
- validator: function validator(value, cb) {
- result = this;
- cb(true);
- }
- }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, 123);
- setTimeout(function () {
- expect(result.instance).toEqual(getInstance());
- done();
- }, 200);
- });
- it('this in validator should point to cellProperties when columns is a function', function (done) {
- var result = null;
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = {
- data: 'id',
- validator: function validator(value, cb) {
- result = this;
- cb(true);
- }
- };
- } else if (column === 1) {
- colMeta = { data: 'name' };
- } else if (column === 2) {
- colMeta = { data: 'lastName' };
- }
- return colMeta;
- },
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, 123);
- setTimeout(function () {
- expect(result.instance).toEqual(getInstance());
- done();
- }, 200);
- });
- it('should not throw error after calling validateCells without first argument', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- validator: function validator(value, callb) {
- if (value == 'B1') {
- callb(false);
- } else {
- callb(true);
- }
- },
- afterValidate: onAfterValidate
- });
- expect(hot.validateCells).not.toThrow();
- setTimeout(function () {
- expect(spec().$container.find('td.htInvalid').length).toEqual(1);
- expect(spec().$container.find('td:not(.htInvalid)').length).toEqual(3);
- done();
- }, 200);
- });
- it('should add class name `htInvalid` to an cell that does not validate - on validateCells', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- validator: function validator(value, callb) {
- if (value == 'B1') {
- callb(false);
- } else {
- callb(true);
- }
- },
- afterValidate: onAfterValidate
- });
- hot.validateCells(function () {
- hot.render();
- });
- setTimeout(function () {
- expect(spec().$container.find('td.htInvalid').length).toEqual(1);
- expect(spec().$container.find('td:not(.htInvalid)').length).toEqual(3);
- done();
- }, 200);
- });
- it('should add class name `htInvalid` to an cell that does not validate - when we trigger validateCell', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- validator: function validator(value, cb) {
- cb(false);
- },
- afterValidate: onAfterValidate
- });
- expect(this.$container.find('td:not(.htInvalid)').length).toEqual(4);
- hot.validateCell(hot.getDataAtCell(1, 1), hot.getCellMeta(1, 1), function () {});
- setTimeout(function () {
- expect(spec().$container.find('td.htInvalid').length).toEqual(1);
- expect(spec().$container.find('td:not(.htInvalid)').length).toEqual(3);
- done();
- }, 200);
- });
- it('should remove class name `htInvalid` from an cell that does validate - when we change validator rules', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var isValid = false;
- var _validator = function _validator() {
- return isValid;
- };
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- validator: function validator(value, cb) {
- cb(_validator());
- },
- afterValidate: onAfterValidate
- });
- hot.validateCells(function () {});
- setTimeout(function () {
- expect(spec().$container.find('td.htInvalid').length).toEqual(4);
- expect(spec().$container.find('td:not(.htInvalid)').length).toEqual(0);
- isValid = true;
- onAfterValidate.calls.reset();
- hot.validateCell(hot.getDataAtCell(1, 1), hot.getCellMeta(1, 1), function () {});
- }, 200);
- setTimeout(function () {
- expect(spec().$container.find('td.htInvalid').length).toEqual(3);
- expect(spec().$container.find('td:not(.htInvalid)').length).toEqual(1);
- done();
- }, 400);
- });
- it('should add class name `htInvalid` to an cell that does not validate - on edit', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- validator: function validator(value, callb) {
- if (value == 'test') {
- callb(false);
- } else {
- callb(true);
- }
- },
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, 'test');
- setTimeout(function () {
- expect(spec().$container.find('td.htInvalid').length).toEqual(1);
- expect(spec().$container.find('tr:eq(0) td:eq(0)').hasClass('htInvalid')).toEqual(true);
- done();
- }, 200);
- });
- it('should add class name `htInvalid` to a cell without removing other classes', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var validator = jasmine.createSpy('validator');
- validator.and.callFake(function (value, callb) {
- if (value == 123) {
- callb(false);
- } else {
- callb(true);
- }
- });
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- type: 'numeric',
- validator: validator,
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, 123);
- setTimeout(function () {
- expect(validator.calls.count()).toEqual(1);
- expect(spec().$container.find('tr:eq(0) td:eq(0)').hasClass('htInvalid')).toEqual(true);
- expect(spec().$container.find('tr:eq(0) td:eq(0)').hasClass('htNumeric')).toEqual(true);
- onAfterValidate.calls.reset();
- setDataAtCell(0, 0, 124);
- }, 200);
- setTimeout(function () {
- expect(spec().$container.find('tr:eq(0) td:eq(0)').hasClass('htInvalid')).toEqual(false);
- expect(spec().$container.find('tr:eq(0) td:eq(0)').hasClass('htNumeric')).toEqual(true);
- done();
- }, 400);
- });
- it('should add class name `htInvalid` to an cell that does not validate - after validateCells', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, 'test');
- setTimeout(function () {
- expect(spec().$container.find('td.htInvalid').length).toEqual(0);
- updateSettings({
- validator: function validator(value, callb) {
- if (value == 'test') {
- callb(false);
- } else {
- callb(true);
- }
- }
- });
- onAfterValidate.calls.reset();
- hot.validateCells(function () {});
- }, 200);
- setTimeout(function () {
- expect(spec().$container.find('td.htInvalid').length).toEqual(1);
- expect(spec().$container.find('tr:eq(0) td:eq(0)').hasClass('htInvalid')).toEqual(true);
- done();
- }, 400);
- });
- it('should remove class name `htInvalid` when cell is edited to validate', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- validator: function validator(value, callb) {
- if (value == 'A1') {
- callb(false);
- } else {
- callb(true);
- }
- },
- afterValidate: onAfterValidate
- });
- hot.validateCells(function () {
- hot.render();
- });
- setTimeout(function () {
- expect(spec().$container.find('tr:eq(0) td:eq(0)').hasClass('htInvalid')).toEqual(true);
- onAfterValidate.calls.reset();
- setDataAtCell(0, 0, 'test');
- }, 200);
- setTimeout(function () {
- expect(spec().$container.find('tr:eq(0) td:eq(0)').hasClass('htInvalid')).toEqual(false);
- done();
- }, 400);
- });
- it('should call callback with first argument as `true` if all cells are valid', function (done) {
- var onValidate = jasmine.createSpy('onValidate');
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- validator: function validator(value, callback) {
- callback(true);
- },
- afterValidate: onAfterValidate
- });
- hot.validateCells(onValidate);
- setTimeout(function () {
- expect(onValidate).toHaveBeenCalledWith(true);
- done();
- }, 200);
- });
- it('should call callback with first argument as `false` if one of cells is invalid', function (done) {
- var onValidate = jasmine.createSpy('onValidate');
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(2, 2),
- validator: function validator(value, callback) {
- callback(false);
- },
- afterValidate: onAfterValidate
- });
- hot.validateCells(onValidate);
- setTimeout(function () {
- expect(onValidate).toHaveBeenCalledWith(false);
- done();
- }, 200);
- });
- it('should not allow for changes where data is invalid (multiple changes, async)', function (done) {
- var validatedChanges;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: false,
- validator: function validator(value, callb) {
- setTimeout(function () {
- if (value === 'fail') {
- callb(false);
- } else {
- callb(true);
- }
- }, 10);
- },
- afterChange: function afterChange(changes, source) {
- if (source !== 'loadData') {
- validatedChanges = changes;
- }
- }
- });
- populateFromArray(0, 0, [['A1-new'], ['fail'], ['A3-new']]);
- setTimeout(function () {
- expect(validatedChanges.length).toEqual(2);
- expect(validatedChanges[0]).toEqual([0, 0, 'A1', 'A1-new']);
- expect(validatedChanges[1]).toEqual([2, 0, 'A3', 'A3-new']);
- expect(getDataAtCell(0, 0)).toEqual('A1-new');
- expect(getDataAtCell(1, 0)).toEqual('A2');
- expect(getDataAtCell(2, 0)).toEqual('A3-new');
- expect(getCellMeta(0, 0).valid).toBe(true);
- expect(getCellMeta(1, 0).valid).toBe(true);
- expect(getCellMeta(2, 0).valid).toBe(true);
- done();
- }, 200);
- });
- it('should call beforeChange exactly once after cell value edit and validator is synchronous', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var onBeforeChange = jasmine.createSpy('onBeforeChange');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: false,
- validator: function validator(value, callback) {
- callback(true);
- },
- beforeChange: onBeforeChange,
- afterValidate: onAfterValidate
- });
- expect(onBeforeChange.calls.count()).toEqual(0);
- hot.setDataAtCell(0, 0, 10);
- setTimeout(function () {
- expect(onBeforeChange.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- it('should call beforeChange exactly once after cell value edit and validator is asynchronous', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var onBeforeChange = jasmine.createSpy('onBeforeChange');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: false,
- validator: function validator(value, callback) {
- setTimeout(function () {
- callback(true);
- }, 10);
- },
- beforeChange: onBeforeChange,
- afterValidate: onAfterValidate
- });
- expect(onBeforeChange.calls.count()).toEqual(0);
- hot.setDataAtCell(0, 0, 10);
- setTimeout(function () {
- expect(onBeforeChange.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- it('should call afterChange exactly once after cell value edit and validator is synchronous', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var onAfterChange = jasmine.createSpy('onAfterChange');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: false,
- validator: function validator(value, callback) {
- callback(true);
- },
- afterChange: onAfterChange,
- afterValidate: onAfterValidate
- });
- expect(onAfterChange.calls.count()).toEqual(1); // loadData
- hot.setDataAtCell(0, 0, 10);
- setTimeout(function () {
- expect(onAfterChange.calls.count()).toEqual(2);
- done();
- }, 200);
- });
- it('should call afterChange exactly once after cell value edit and validator is asynchronous', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var onAfterChange = jasmine.createSpy('onAfterChange');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: false,
- validator: function validator(value, callback) {
- setTimeout(function () {
- callback(true);
- }, 10);
- },
- afterChange: onAfterChange,
- afterValidate: onAfterValidate
- });
- expect(onAfterChange.calls.count()).toEqual(1); // loadData
- hot.setDataAtCell(0, 0, 10);
- setTimeout(function () {
- expect(onAfterChange.calls.count()).toEqual(2);
- done();
- }, 200);
- });
- it('edited cell should stay on screen until value is validated', function (done) {
- var isEditorVisibleBeforeChange;
- var isEditorVisibleAfterChange;
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var onAfterChange = jasmine.createSpy('onAfterChange');
- onAfterValidate.and.callFake(function () {
- isEditorVisibleBeforeChange = isEditorVisible();
- });
- onAfterChange.and.callFake(function () {
- isEditorVisibleAfterChange = isEditorVisible();
- });
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: false,
- afterValidate: onAfterValidate,
- afterChange: onAfterChange,
- validator: function validator(value, callback) {
- setTimeout(function () {
- callback(true);
- }, 100);
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'Ted';
- onAfterValidate.calls.reset();
- onAfterChange.calls.reset();
- keyDown('enter');
- expect(document.activeElement.nodeName).toEqual('TEXTAREA');
- setTimeout(function () {
- expect(isEditorVisibleBeforeChange).toBe(true);
- expect(isEditorVisibleAfterChange).toBe(true);
- expect(isEditorVisible()).toBe(false);
- done();
- }, 200);
- });
- it('should validate edited cell after selecting another cell', function (done) {
- var validated = false;
- var validatedValue;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: false,
- validator: function validator(value, callback) {
- setTimeout(function () {
- validated = true;
- validatedValue = value;
- callback(true);
- }, 100);
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'Ted';
- selectCell(0, 1);
- setTimeout(function () {
- expect(validatedValue).toEqual('Ted');
- done();
- }, 200);
- });
- it('should leave the new value in editor if it does not validate (async validation), after hitting ENTER', function (done) {
- var validated = false;
- var validationResult;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: false,
- validator: function validator(value, callback) {
- setTimeout(function () {
- validated = true;
- validationResult = value.length == 2;
- callback(validationResult);
- }, 100);
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'Ted';
- keyDown('enter');
- setTimeout(function () {
- expect(validationResult).toBe(false);
- expect(document.activeElement.value).toEqual('Ted');
- done();
- }, 200);
- });
- it('should leave the new value in editor if it does not validate (sync validation), after hitting ENTER', function (done) {
- var validated = false;
- var validationResult;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: false,
- validator: function validator(value, callback) {
- validated = true;
- validationResult = value.length == 2;
- callback(validationResult);
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'Ted';
- keyDown('enter');
- setTimeout(function () {
- expect(validationResult).toBe(false);
- expect(document.activeElement.value).toEqual('Ted');
- done();
- }, 200);
- });
- it('should leave the new value in editor if it does not validate (async validation), after selecting another cell', function (done) {
- var validated = false;
- var validationResult;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: false,
- validator: function validator(value, callback) {
- setTimeout(function () {
- setTimeout(function () {
- validated = true;
- }, 0);
- validationResult = value.length == 2;
- callback(validationResult);
- }, 100);
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'Ted';
- selectCell(1, 0);
- setTimeout(function () {
- expect(validationResult).toBe(false);
- expect(document.activeElement.value).toEqual('Ted');
- done();
- }, 200);
- });
- it('should leave the new value in editor if it does not validate (sync validation), after selecting another cell', function (done) {
- var validated = false;
- var validationResult;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: false,
- validator: function validator(value, callback) {
- validationResult = value.length == 2;
- callback(validationResult);
- /* Setting this variable has to be async, because we are not interested in when the validation happens, but when
- the callback is being called. Since internally all the callbacks are processed asynchronously (even if they are
- synchronous) end of validator function is not the equivalent of whole validation routine end.
- If it still sounds weird, take a look at HandsontableTextEditorClass.prototype.finishEditing method.
- */
- setTimeout(function () {
- validated = true;
- }, 0);
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'Ted';
- selectCell(1, 0);
- setTimeout(function () {
- expect(validationResult).toBe(false);
- expect(document.activeElement.value).toEqual('Ted');
- done();
- }, 200);
- });
- it('should close the editor and save the new value if validation fails and allowInvalid is set to "true"', function (done) {
- var validated = false;
- var validationResult;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: true,
- validator: function validator(value, callback) {
- setTimeout(function () {
- validated = true;
- validationResult = value.length == 2;
- callback(validationResult);
- }, 100);
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'Ted';
- selectCell(1, 0);
- setTimeout(function () {
- expect(validationResult).toBe(false);
- expect(getDataAtCell(0, 0)).toEqual('Ted');
- expect(getCell(0, 0).className).toMatch(/htInvalid/);
- done();
- }, 200);
- });
- it('should close the editor and save the new value after double clicking on a cell, if the previously edited cell validated correctly', function (done) {
- var validated = false;
- var validationResult;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: false,
- validator: function validator(value, callback) {
- setTimeout(function () {
- validated = true;
- validationResult = value.length == 2;
- callback(validationResult);
- }, 100);
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- var editor = $('.handsontableInputHolder');
- expect(editor.is(':visible')).toBe(true);
- document.activeElement.value = 'AA';
- expect(document.activeElement.value).toEqual('AA');
- var cell = $(getCell(1, 0));
- var clicks = 0;
- setTimeout(function () {
- mouseDown(cell);
- mouseUp(cell);
- clicks++;
- }, 0);
- setTimeout(function () {
- mouseDown(cell);
- mouseUp(cell);
- clicks++;
- }, 100);
- setTimeout(function () {
- expect(editor.is(':visible')).toBe(false);
- expect(validationResult).toBe(true);
- expect(getDataAtCell(0, 0)).toEqual('AA');
- done();
- }, 300);
- });
- it('should close the editor and restore the original value after double clicking on a cell, if the previously edited cell have not validated', function (done) {
- var validated = false;
- var validationResult;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- allowInvalid: false,
- validator: function validator(value, callback) {
- setTimeout(function () {
- validated = true;
- validationResult = value.length == 2;
- callback(validationResult);
- }, 100);
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'AAA';
- expect(document.activeElement.value).toEqual('AAA');
- var cell = $(getCell(1, 0));
- var clicks = 0;
- setTimeout(function () {
- mouseDown(cell);
- mouseUp(cell);
- clicks++;
- }, 0);
- setTimeout(function () {
- mouseDown(cell);
- mouseUp(cell);
- clicks++;
- }, 100);
- setTimeout(function () {
- expect(validationResult).toBe(false);
- expect(getDataAtCell(0, 0)).toEqual('A1');
- done();
- }, 300);
- });
- it('should listen to key changes after cell is corrected (allowInvalid: false)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- allowInvalid: false,
- columns: [{ data: 'id',
- type: 'numeric',
- validator: function validator(val, cb) {
- cb(parseInt(val, 10) > 100);
- }
- }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- keyDownUp('enter');
- document.activeElement.value = '99';
- onAfterValidate.calls.reset();
- keyDownUp('enter'); // should be ignored
- setTimeout(function () {
- expect(isEditorVisible()).toBe(true);
- document.activeElement.value = '999';
- onAfterValidate.calls.reset();
- keyDownUp('enter'); // should be accepted
- }, 200);
- setTimeout(function () {
- expect(isEditorVisible()).toBe(false);
- expect(getSelected()).toEqual([3, 0, 3, 0]);
- keyDownUp('arrow_up');
- expect(getSelected()).toEqual([2, 0, 2, 0]);
- done();
- }, 400);
- });
- it('should allow keyboard movement when cell is being validated (move DOWN)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- allowInvalid: false,
- columns: [{ data: 'id',
- type: 'numeric',
- validator: function validator(val, cb) {
- setTimeout(function () {
- cb(parseInt(val, 10) > 100);
- }, 100);
- }
- }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- keyDownUp('enter');
- document.activeElement.value = '999';
- keyDownUp('enter');
- expect(getSelected()).toEqual([3, 0, 3, 0]);
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- expect(isEditorVisible()).toBe(true);
- expect(getSelected()).toEqual([5, 0, 5, 0]);
- setTimeout(function () {
- expect(isEditorVisible()).toBe(false);
- expect(getSelected()).toEqual([5, 0, 5, 0]); // only enterMove and first arrow_down is performed
- done();
- }, 200);
- });
- it('should not allow keyboard movement until cell is validated (move UP)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- allowInvalid: false,
- columns: [{ data: 'id',
- type: 'numeric',
- validator: function validator(val, cb) {
- setTimeout(function () {
- cb(parseInt(val, 10) > 100);
- }, 100);
- }
- }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- keyDownUp('enter');
- document.activeElement.value = '999';
- keyDownUp('enter');
- expect(getSelected()).toEqual([3, 0, 3, 0]);
- keyDownUp('arrow_up');
- keyDownUp('arrow_up');
- expect(isEditorVisible()).toBe(true);
- expect(getSelected()).toEqual([1, 0, 1, 0]);
- setTimeout(function () {
- expect(isEditorVisible()).toBe(false);
- expect(getSelected()).toEqual([1, 0, 1, 0]);
- done();
- }, 200);
- });
- it('should not allow keyboard movement until cell is validated (move RIGHT)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- allowInvalid: false,
- columns: [{ data: 'id',
- type: 'numeric',
- validator: function validator(val, cb) {
- setTimeout(function () {
- cb(parseInt(val, 10) > 100);
- }, 100);
- }
- }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- keyDownUp('enter');
- document.activeElement.value = '999';
- keyDownUp('enter'); // should be accepted but only after 100 ms
- expect(getSelected()).toEqual([3, 0, 3, 0]);
- keyDownUp('arrow_right');
- keyDownUp('arrow_right');
- expect(isEditorVisible()).toBe(true);
- expect(getSelected()).toEqual([3, 2, 3, 2]);
- setTimeout(function () {
- expect(isEditorVisible()).toBe(false);
- expect(getSelected()).toEqual([3, 2, 3, 2]);
- done();
- }, 200);
- });
- it('should not allow keyboard movement until cell is validated (move LEFT)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- hot = handsontable({
- data: arrayOfObjects(),
- allowInvalid: false,
- columns: [{ data: 'name' }, { data: 'lastName' }, { data: 'id',
- type: 'numeric',
- validator: function validator(val, cb) {
- setTimeout(function () {
- cb(parseInt(val, 10) > 100);
- }, 100);
- }
- }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 2);
- keyDownUp('enter');
- document.activeElement.value = '999';
- keyDownUp('enter'); // should be accepted but only after 100 ms
- expect(getSelected()).toEqual([3, 2, 3, 2]);
- this.$container.simulate('keydown', { keyCode: Handsontable.helper.KEY_CODES.ARROW_LEFT });
- this.$container.simulate('keyup', { keyCode: Handsontable.helper.KEY_CODES.ARROW_LEFT });
- this.$container.simulate('keydown', { keyCode: Handsontable.helper.KEY_CODES.ARROW_LEFT });
- this.$container.simulate('keyup', { keyCode: Handsontable.helper.KEY_CODES.ARROW_LEFT });
- expect(isEditorVisible()).toBe(true);
- expect(getSelected()).toEqual([3, 0, 3, 0]);
- setTimeout(function () {
- expect(isEditorVisible()).toBe(false);
- expect(getSelected()).toEqual([3, 0, 3, 0]);
- done();
- }, 200);
- });
- it('should not validate cell if editing has been canceled', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(0, 0);
- keyDownUp(Handsontable.helper.KEY_CODES.ENTER); // open editor
- keyDownUp(Handsontable.helper.KEY_CODES.ESCAPE); // cancel editing
- setTimeout(function () {
- expect(onAfterValidate).not.toHaveBeenCalled();
- done();
- }, 100);
- });
- it('should not validate cell if editing has been canceled when columns is a function', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = { data: 'id' };
- } else if (column === 1) {
- colMeta = { data: 'name' };
- } else if (column === 2) {
- colMeta = { data: 'lastName' };
- }
- return colMeta;
- },
- afterValidate: onAfterValidate
- });
- selectCell(0, 0);
- keyDownUp(Handsontable.helper.KEY_CODES.ENTER); // open editor
- keyDownUp(Handsontable.helper.KEY_CODES.ESCAPE); // cancel editing
- setTimeout(function () {
- expect(onAfterValidate).not.toHaveBeenCalled();
- done();
- }, 100);
- });
- it('should leave cell invalid if editing has been canceled', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id',
- validator: function validator(value, cb) {
- cb(false);
- }
- }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, 'foo');
- setTimeout(function () {
- expect(getCellMeta(0, 0).valid).toBe(false);
- selectCell(0, 0);
- keyDownUp(Handsontable.helper.KEY_CODES.ENTER); // open editor
- keyDownUp(Handsontable.helper.KEY_CODES.ESCAPE); // cancel editing
- expect(getCellMeta(0, 0).valid).toBe(false);
- done();
- }, 200);
- });
- it('should leave cell invalid if editing has been canceled when columns is a function', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = {
- data: 'id',
- validator: function validator(value, cb) {
- cb(false);
- }
- };
- } else if (column === 1) {
- colMeta = { data: 'name' };
- } else if (column === 2) {
- colMeta = { data: 'lastName' };
- }
- return colMeta;
- },
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, 'foo');
- setTimeout(function () {
- expect(getCellMeta(0, 0).valid).toBe(false);
- selectCell(0, 0);
- keyDownUp(Handsontable.helper.KEY_CODES.ENTER); // open editor
- keyDownUp(Handsontable.helper.KEY_CODES.ESCAPE); // cancel editing
- expect(getCellMeta(0, 0).valid).toBe(false);
- done();
- }, 200);
- });
- it('should open an appropriate editor after cell value is valid again', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: arrayOfObjects(),
- columns: [{
- data: 'id',
- validator: function validator(value, cb) {
- cb(value == parseInt(value, 10));
- },
- allowInvalid: false
- }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(0, 0);
- var activeEditor = hot.getActiveEditor();
- expect(activeEditor.row).toEqual(0);
- expect(activeEditor.col).toEqual(0);
- keyDownUp(Handsontable.helper.KEY_CODES.ENTER); // open editor
- activeEditor.setValue('foo');
- keyDownUp(Handsontable.helper.KEY_CODES.ENTER); // save changes, close editor
- setTimeout(function () {
- onAfterValidate.calls.reset();
- activeEditor = hot.getActiveEditor();
- expect(activeEditor.isOpened()).toBe(true); // value is invalid, so editor stays opened
- expect(activeEditor.row).toEqual(0);
- expect(activeEditor.col).toEqual(0);
- activeEditor.setValue(2);
- keyDownUp(Handsontable.helper.KEY_CODES.ENTER); // save changes and move to cell below (row: 1, col: ś0)
- }, 200);
- setTimeout(function () {
- keyDownUp(Handsontable.helper.KEY_CODES.ENTER); // open editor
- activeEditor = hot.getActiveEditor();
- expect(activeEditor.row).toEqual(1);
- expect(activeEditor.col).toEqual(0);
- done();
- }, 400);
- });
- it('should open an appropriate editor after cell value is valid again when columns is a function', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: arrayOfObjects(),
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = {
- data: 'id',
- validator: function validator(value, cb) {
- cb(value == parseInt(value, 10));
- },
- allowInvalid: false
- };
- } else if (column === 1) {
- colMeta = { data: 'name' };
- } else if (column === 2) {
- colMeta = { data: 'lastName' };
- }
- return colMeta;
- },
- afterValidate: onAfterValidate
- });
- selectCell(0, 0);
- var activeEditor = hot.getActiveEditor();
- expect(activeEditor.row).toEqual(0);
- expect(activeEditor.col).toEqual(0);
- keyDownUp(Handsontable.helper.KEY_CODES.ENTER); // open editor
- activeEditor.setValue('foo');
- keyDownUp(Handsontable.helper.KEY_CODES.ENTER); // save changes, close editor
- setTimeout(function () {
- onAfterValidate.calls.reset();
- activeEditor = hot.getActiveEditor();
- expect(activeEditor.isOpened()).toBe(true); // value is invalid, so editor stays opened
- expect(activeEditor.row).toEqual(0);
- expect(activeEditor.col).toEqual(0);
- activeEditor.setValue(2);
- keyDownUp(Handsontable.helper.KEY_CODES.ENTER); // save changes and move to cell below (row: 1, col: ś0)
- }, 200);
- setTimeout(function () {
- keyDownUp(Handsontable.helper.KEY_CODES.ENTER); // open editor
- activeEditor = hot.getActiveEditor();
- expect(activeEditor.row).toEqual(1);
- expect(activeEditor.col).toEqual(0);
- done();
- }, 400);
- });
- it('should call the validation callback only once, when using the validateCells method on a mixed set of data', function (done) {
- var onValidate = jasmine.createSpy('onValidate');
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: [{ id: 'sth', name: 'Steve' }, { id: 'sth else', name: 'Bob' }],
- columns: [{
- data: 'id',
- validator: function validator(value, cb) {
- cb(value == parseInt(value, 10));
- }
- }, { data: 'name' }],
- afterValidate: onAfterValidate
- });
- hot.validateCells(onValidate);
- setTimeout(function () {
- expect(onValidate).toHaveBeenCalledWith(false);
- expect(onValidate.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- it('should call the validation callback only once, when using the validateCells method on a mixed set of data and when columns is a function', function (done) {
- var onValidate = jasmine.createSpy('onValidate');
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: [{ id: 'sth', name: 'Steve' }, { id: 'sth else', name: 'Bob' }],
- columns: function columns(column) {
- var colMeta = null;
- if (column === 0) {
- colMeta = {
- data: 'id',
- validator: function validator(value, cb) {
- cb(value == parseInt(value, 10));
- }
- };
- } else if (column === 1) {
- colMeta = { data: 'name' };
- }
- return colMeta;
- },
- afterValidate: onAfterValidate
- });
- hot.validateCells(onValidate);
- setTimeout(function () {
- expect(onValidate).toHaveBeenCalledWith(false);
- expect(onValidate.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- });
- /***/ }),
- /* 181 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core_view', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should focus cell after viewport is scrolled using down arrow', function () {
- this.$container[0].style.width = '400px';
- this.$container[0].style.height = '60px';
- handsontable({
- startRows: 20
- });
- selectCell(0, 0);
- keyDown('arrow_down');
- keyDown('arrow_down');
- keyDown('arrow_down');
- keyDown('arrow_down');
- expect(getSelected()).toEqual([4, 0, 4, 0]);
- keyDown('enter');
- expect(isEditorVisible()).toEqual(true);
- });
- it('should not render "undefined" class name', function () {
- this.$container[0].style.width = '501px';
- this.$container[0].style.height = '100px';
- this.$container[0].style.overflow = 'hidden';
- var hot = handsontable({
- startRows: 10,
- startCols: 5,
- colWidths: [47, 47, 47, 47, 47],
- rowHeaders: true,
- colHeaders: true,
- stretchH: 'all'
- });
- selectCell(0, 0);
- expect(this.$container.find('.undefined').length).toBe(0);
- });
- it('should scroll viewport when partially visible cell is clicked', function () {
- this.$container[0].style.width = '400px';
- this.$container[0].style.height = '60px';
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 3),
- height: 60
- });
- var htCore = getHtCore();
- var scrollTop = hot.rootElement.querySelector('.wtHolder').scrollTop;
- expect(scrollTop).toBe(0);
- expect(this.$container.height()).toEqual(60);
- expect(this.$container.find('.wtHolder .wtHider').height()).toBeGreaterThan(60);
- expect(htCore.find('tr:eq(0) td:eq(0)').html()).toEqual('A1');
- expect(htCore.find('tr:eq(1) td:eq(0)').html()).toEqual('A2');
- expect(htCore.find('tr:eq(2) td:eq(0)').html()).toEqual('A3');
- htCore.find('tr:eq(3) td:eq(0)').simulate('mousedown');
- expect(hot.rootElement.querySelector('.wtHolder').scrollTop).toBeGreaterThan(scrollTop);
- expect(getSelected()).toEqual([3, 0, 3, 0]);
- });
- it('should scroll viewport without cell selection', function () {
- this.$container[0].style.width = '400px';
- var hot1 = handsontable({
- data: Handsontable.helper.createSpreadsheetData(20, 20),
- height: 100
- });
- hot1.scrollViewportTo(10, 10);
- var wtHolder = this.$container.find('.ht_master .wtHolder');
- expect(wtHolder[0].scrollTop).toEqual(230);
- expect(wtHolder[0].scrollLeft).toEqual(500);
- });
- it('should not throw error while scrolling viewport to 0, 0 (empty data)', function () {
- this.$container[0].style.width = '400px';
- var hot1 = handsontable({
- data: [],
- height: 100
- });
- expect(function () {
- hot1.view.scrollViewport({ row: 0, col: 0 });
- }).not.toThrow();
- });
- it('should throw error while scrolling viewport below 0 (empty data)', function () {
- this.$container[0].style.width = '400px';
- var hot1 = handsontable({
- data: [],
- height: 100
- });
- expect(function () {
- hot1.view.scrollViewport({ row: -1, col: 0 });
- }).toThrow();
- expect(function () {
- hot1.view.scrollViewport({ row: 0, col: -1 });
- }).toThrow();
- expect(function () {
- hot1.view.scrollViewport({ row: -1, col: -1 });
- }).toThrow();
- });
- it('should scroll viewport, respecting fixed rows', function () {
- this.$container[0].style.width = '400px';
- this.$container[0].style.height = '60px';
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 9),
- fixedRowsTop: 1,
- height: 60
- });
- var htCore = getHtCore();
- var scrollTop = hot.rootElement.querySelector('.wtHolder').scrollTop;
- expect(scrollTop).toBe(0);
- expect(htCore.find('tr:eq(0) td:eq(0)').html()).toEqual('A1');
- expect(htCore.find('tr:eq(0) td:eq(1)').html()).toEqual('B1');
- expect(htCore.find('tr:eq(0) td:eq(2)').html()).toEqual('C1');
- selectCell(0, 0);
- keyDown('arrow_down');
- keyDown('arrow_down');
- keyDown('arrow_down');
- keyDown('arrow_down');
- expect(hot.rootElement.querySelector('.wtHolder').scrollTop).toBeGreaterThan(scrollTop);
- });
- it('should enable to change fixedRowsTop with updateSettings', function () {
- this.$container[0].style.width = '400px';
- this.$container[0].style.height = '60px';
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 9),
- fixedRowsTop: 1,
- width: 200,
- height: 100
- });
- selectCell(0, 0);
- var htCore = getHtCore();
- var topClone = getTopClone();
- expect(topClone.find('tr').length).toEqual(1);
- expect(topClone.find('tr:eq(0) td:eq(0)').html()).toEqual('A1');
- expect(htCore.find('tr:eq(0) td:eq(0)').html()).toEqual('A1');
- expect(htCore.find('tr:eq(1) td:eq(0)').html()).toEqual('A2');
- expect(htCore.find('tr:eq(2) td:eq(0)').html()).toEqual('A3');
- expect(htCore.find('tr:eq(3) td:eq(0)').html()).toEqual('A4');
- keyDown('arrow_down');
- keyDown('arrow_down');
- keyDown('arrow_down');
- keyDown('arrow_down');
- expect(topClone.find('tr').length).toEqual(1);
- expect(topClone.find('tr:eq(0) td:eq(0)').html()).toEqual('A1');
- HOT.updateSettings({
- fixedRowsTop: 2
- });
- expect(topClone.find('tr').length).toEqual(2);
- expect(topClone.find('tr:eq(0) td:eq(0)').html()).toEqual('A1');
- expect(topClone.find('tr:eq(1) td:eq(0)').html()).toEqual('A2');
- expect(htCore.find('tr:eq(0) td:eq(0)').html()).toEqual('A1');
- expect(htCore.find('tr:eq(1) td:eq(0)').html()).toEqual('A2');
- expect(htCore.find('tr:eq(2) td:eq(0)').html()).toEqual('A3');
- expect(htCore.find('tr:eq(3) td:eq(0)').html()).toEqual('A4');
- });
- it('should scroll viewport, respecting fixed columns', function () {
- this.$container[0].style.width = '200px';
- this.$container[0].style.height = '100px';
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 9),
- fixedColumnsLeft: 1
- });
- var htCore = getHtCore();
- var leftClone = this.$container.find('.ht_clone_left');
- expect(leftClone.find('tr:eq(0) td').length).toEqual(1);
- expect(leftClone.find('tr:eq(0) td:eq(0)').html()).toEqual('A1');
- expect(leftClone.find('tr:eq(1) td:eq(0)').html()).toEqual('A2');
- expect(leftClone.find('tr:eq(2) td:eq(0)').html()).toEqual('A3');
- expect(htCore.find('tr:eq(0) td:eq(0)').html()).toEqual('A1');
- expect(htCore.find('tr:eq(1) td:eq(0)').html()).toEqual('A2');
- expect(htCore.find('tr:eq(2) td:eq(0)').html()).toEqual('A3');
- selectCell(0, 3);
- keyDown('arrow_right');
- keyDown('arrow_right');
- keyDown('arrow_right');
- keyDown('arrow_right');
- expect(leftClone.find('tr:eq(0) td:eq(0)').html()).toEqual('A1');
- expect(leftClone.find('tr:eq(1) td:eq(0)').html()).toEqual('A2');
- expect(leftClone.find('tr:eq(2) td:eq(0)').html()).toEqual('A3');
- });
- it('should enable to change fixedColumnsLeft with updateSettings', function () {
- this.$container[0].style.width = '200px';
- this.$container[0].style.height = '100px';
- var HOT = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 9),
- fixedColumnsLeft: 1
- });
- selectCell(0, 0);
- var leftClone = this.$container.find('.ht_clone_left');
- expect(leftClone.find('tr:eq(0) td').length).toEqual(1);
- expect(leftClone.find('tr:eq(0) td:eq(0)').html()).toEqual('A1');
- expect(leftClone.find('tr:eq(1) td:eq(0)').html()).toEqual('A2');
- expect(leftClone.find('tr:eq(2) td:eq(0)').html()).toEqual('A3');
- keyDown('arrow_right');
- keyDown('arrow_right');
- keyDown('arrow_right');
- keyDown('arrow_right');
- expect(leftClone.find('tr:eq(0) td:eq(0)').html()).toEqual('A1');
- expect(leftClone.find('tr:eq(1) td:eq(0)').html()).toEqual('A2');
- expect(leftClone.find('tr:eq(2) td:eq(0)').html()).toEqual('A3');
- selectCell(0, 0);
- HOT.updateSettings({
- fixedColumnsLeft: 2
- });
- expect(leftClone.find('tr:eq(0) td').length).toEqual(2);
- expect(leftClone.find('tr:eq(0) td:eq(0)').html()).toEqual('A1');
- expect(leftClone.find('tr:eq(0) td:eq(1)').html()).toEqual('B1');
- expect(leftClone.find('tr:eq(1) td:eq(0)').html()).toEqual('A2');
- expect(leftClone.find('tr:eq(1) td:eq(1)').html()).toEqual('B2');
- expect(leftClone.find('tr:eq(2) td:eq(0)').html()).toEqual('A3');
- expect(leftClone.find('tr:eq(2) td:eq(1)').html()).toEqual('B3');
- });
- it('should not scroll viewport when last cell is clicked', function () {
- handsontable({
- startRows: 40
- });
- var lastScroll;
- $(window).scrollTop(10000);
- lastScroll = $(window).scrollTop();
- render(); // renders synchronously so we don't have to put stuff in waits/runs
- selectCell(39, 0);
- expect($(window).scrollTop()).toEqual(lastScroll);
- keyDown('arrow_right');
- expect(getSelected()).toEqual([39, 1, 39, 1]);
- expect($(window).scrollTop()).toEqual(lastScroll);
- });
- it('should not shrink table when width and height is not specified for container', function (done) {
- var initHeight;
- this.$container[0].style.overflow = 'hidden';
- this.$container.wrap('<div style="width: 50px;"></div>');
- handsontable({
- startRows: 10,
- startCols: 10
- });
- setTimeout(function () {
- initHeight = spec().$container.height();
- }, 250);
- setTimeout(function () {
- expect(spec().$container.height()).toEqual(initHeight);
- done();
- }, 500);
- });
- it('should allow height to be a number', function () {
- handsontable({
- startRows: 10,
- startCols: 10,
- height: 107
- });
- expect(this.$container.height()).toEqual(107);
- });
- it('should allow height to be a function', function () {
- handsontable({
- startRows: 10,
- startCols: 10,
- height: function height() {
- return 107;
- }
- });
- expect(this.$container.height()).toEqual(107);
- });
- it('should allow width to be a number', function () {
- handsontable({
- startRows: 10,
- startCols: 10,
- width: 107
- });
- expect(this.$container.width()).toEqual(107); // rootElement is full width but this should do the trick
- });
- it('should allow width to be a function', function () {
- handsontable({
- startRows: 10,
- startCols: 10,
- width: function width() {
- return 107;
- }
- });
- expect(this.$container.width()).toEqual(107); // rootElement is full width but this should do the trick
- });
- it('should fire beforeRender event after table has been scrolled', function (done) {
- this.$container[0].style.width = '400px';
- this.$container[0].style.height = '60px';
- this.$container[0].style.overflow = 'hidden';
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(100, 3)
- });
- var beforeRenderCallback = jasmine.createSpy('beforeRenderCallback');
- hot.addHook('beforeRender', beforeRenderCallback);
- this.$container.find('.ht_master .wtHolder').scrollTop(1000);
- setTimeout(function () {
- expect(beforeRenderCallback.calls.count()).toBe(1);
- done();
- }, 200);
- });
- it('should fire afterRender event after table has been scrolled', function (done) {
- this.$container[0].style.width = '400px';
- this.$container[0].style.height = '60px';
- this.$container[0].style.overflow = 'hidden';
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(20, 3)
- });
- var afterRenderCallback = jasmine.createSpy('afterRenderCallback');
- hot.addHook('afterRender', afterRenderCallback);
- this.$container.find('.ht_master .wtHolder').first().scrollTop(1000);
- setTimeout(function () {
- expect(afterRenderCallback.calls.count()).toBe(1);
- done();
- }, 200);
- });
- it('should fire afterRender event after table physically rendered', function (done) {
- this.$container[0].style.width = '400px';
- this.$container[0].style.height = '60px';
- this.$container[0].style.overflow = 'hidden';
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(20, 3)
- });
- hot.addHook('afterRender', function () {
- hot.view.wt.wtTable.holder.style.overflow = 'scroll';
- hot.view.wt.wtTable.holder.style.width = '220px';
- });
- this.$container.find('.ht_master .wtHolder').first().scrollTop(1000);
- setTimeout(function () {
- // after afterRender hook triggered element style shouldn't changed
- expect(hot.view.wt.wtTable.holder.style.overflow).toBe('scroll');
- expect(hot.view.wt.wtTable.holder.style.width).toBe('220px');
- done();
- }, 100);
- });
- // TODO fix these tests - https://github.com/handsontable/handsontable/issues/1559
- describe('maximumVisibleElementWidth', function () {
- it('should return maximum width until right edge of the viewport', function () {
- var hot = handsontable({
- startRows: 2,
- startCols: 10,
- width: 100,
- height: 100
- });
- expect(hot.view.maximumVisibleElementWidth(0)).toEqual(100);
- });
- it('should return maximum width until right edge of the viewport (excluding the scrollbar)', function () {
- var hot = handsontable({
- startRows: 10,
- startCols: 10,
- width: 100,
- height: 100
- });
- expect(hot.view.maximumVisibleElementWidth(200)).toBeLessThan(100);
- });
- });
- describe('maximumVisibleElementHeight', function () {
- it('should return maximum height until bottom edge of the viewport', function () {
- var hot = handsontable({
- startRows: 10,
- startCols: 2,
- width: 120,
- height: 100
- });
- expect(hot.view.maximumVisibleElementHeight(0)).toEqual(100);
- });
- it('should return maximum height until bottom edge of the viewport (excluding the scrollbar)', function () {
- var hot = handsontable({
- startRows: 10,
- startCols: 10,
- width: 120,
- height: 100
- });
- expect(hot.view.maximumVisibleElementHeight()).toBeLessThan(100);
- });
- });
- describe('fixed column row heights', function () {
- it('should be the same as the row heights in the main table', function () {
- var hot = handsontable({
- data: [['A', 'B', 'C', 'D'], ['a', 'b', 'c\nc', 'd'], ['aa', 'bb', 'cc', 'dd']],
- startRows: 3,
- startCols: 4,
- fixedColumnsLeft: 2
- });
- expect(hot.getCell(1, 2).clientHeight).toEqual(hot.getCell(1, 1).clientHeight);
- hot.setDataAtCell(1, 2, 'c');
- expect(hot.getCell(1, 2).clientHeight).toEqual(hot.getCell(1, 1).clientHeight);
- });
- it('should be the same as the row heights in the main table (after scroll)', function () {
- var myData = Handsontable.helper.createSpreadsheetData(20, 4);
- myData[1][3] = 'very\nlong\ntext';
- myData[5][3] = 'very\nlong\ntext';
- myData[10][3] = 'very\nlong\ntext';
- myData[15][3] = 'very\nlong\ntext';
- var hot = handsontable({
- data: myData,
- startRows: 3,
- startCols: 4,
- fixedRowsTop: 2,
- fixedColumnsLeft: 2,
- width: 200,
- height: 200
- });
- var mainHolder = hot.view.wt.wtTable.holder;
- $(mainHolder).scrollTop(200);
- hot.render();
- var masterTD = this.$container.find('.ht_master tbody tr:eq(5) td:eq(1)')[0];
- var cloneTD = this.$container.find('.ht_clone_left tbody tr:eq(5) td:eq(1)')[0];
- expect(cloneTD.clientHeight).toEqual(masterTD.clientHeight);
- });
- it('should be the same as the row heights in the main table (after scroll, in corner)', function () {
- var myData = Handsontable.helper.createSpreadsheetData(20, 4);
- myData[1][3] = 'very\nlong\ntext';
- myData[5][3] = 'very\nlong\ntext';
- myData[10][3] = 'very\nlong\ntext';
- myData[15][3] = 'very\nlong\ntext';
- var hot = handsontable({
- data: myData,
- startRows: 3,
- startCols: 4,
- fixedRowsTop: 2,
- fixedColumnsLeft: 2,
- width: 200,
- height: 200
- });
- var rowHeight = hot.getCell(1, 3).clientHeight;
- var mainHolder = hot.view.wt.wtTable.holder;
- expect(this.$container.find('.ht_clone_top_left_corner tbody tr:eq(1) td:eq(1)')[0].clientHeight).toEqual(rowHeight);
- $(mainHolder).scrollTop(200);
- hot.render();
- expect(this.$container.find('.ht_clone_top_left_corner tbody tr:eq(1) td:eq(1)')[0].clientHeight).toEqual(rowHeight);
- });
- });
- describe('fixed column widths', function () {
- it('should set the columns width correctly after changes made during updateSettings', function () {
- var hot = handsontable({
- startRows: 2,
- fixedColumnsLeft: 2,
- columns: [{
- width: 50
- }, {
- width: 80
- }, {
- width: 110
- }, {
- width: 140
- }, {
- width: 30
- }, {
- width: 30
- }, {
- width: 30
- }]
- });
- var leftClone = this.$container.find('.ht_clone_left');
- expect(Handsontable.dom.outerWidth(leftClone.find('tbody tr:nth-child(1) td:nth-child(2)')[0])).toEqual(80);
- hot.updateSettings({
- manualColumnMove: [2, 0, 1],
- fixedColumnsLeft: 1
- });
- expect(leftClone.find('tbody tr:nth-child(1) td:nth-child(2)')[0]).toBe(undefined);
- hot.updateSettings({
- manualColumnMove: false,
- fixedColumnsLeft: 2
- });
- expect(Handsontable.dom.outerWidth(leftClone.find('tbody tr:nth-child(1) td:nth-child(2)')[0])).toEqual(80);
- });
- it('should set the columns width correctly after changes made during updateSettings when columns is a function', function () {
- var hot = handsontable({
- startCols: 7,
- startRows: 2,
- fixedColumnsLeft: 2,
- columns: function columns(column) {
- var colMeta = {};
- if (column === 0) {
- colMeta.width = 50;
- } else if (column === 1) {
- colMeta.width = 80;
- } else if (column === 2) {
- colMeta.width = 110;
- } else if (column === 3) {
- colMeta.width = 140;
- } else if ([4, 5, 6].indexOf(column) > -1) {
- colMeta.width = 30;
- } else {
- colMeta = null;
- }
- return colMeta;
- }
- });
- var leftClone = this.$container.find('.ht_clone_left');
- expect(Handsontable.dom.outerWidth(leftClone.find('tbody tr:nth-child(1) td:nth-child(2)')[0])).toEqual(80);
- hot.updateSettings({
- manualColumnMove: [2, 0, 1],
- fixedColumnsLeft: 1
- });
- expect(leftClone.find('tbody tr:nth-child(1) td:nth-child(2)')[0]).toBe(undefined);
- hot.updateSettings({
- manualColumnMove: false,
- fixedColumnsLeft: 2
- });
- expect(Handsontable.dom.outerWidth(leftClone.find('tbody tr:nth-child(1) td:nth-child(2)')[0])).toEqual(80);
- });
- });
- describe('stretchH', function () {
- it('should stretch all visible columns with the ratio appropriate to the container\'s width', function () {
- this.$container[0].style.width = '300px';
- var hot = handsontable({
- startRows: 5,
- startCols: 5,
- rowHeaders: true,
- colHeaders: true,
- stretchH: 'all'
- }),
- rowHeaderWidth = hot.view.wt.wtViewport.getRowHeaderWidth(),
- expectedCellWidth = (parseInt(this.$container[0].style.width, 10) - rowHeaderWidth) / 5;
- expect(getCell(0, 0).offsetWidth).toEqual(expectedCellWidth);
- expect(getCell(0, 1).offsetWidth).toEqual(expectedCellWidth);
- expect(getCell(0, 2).offsetWidth).toEqual(expectedCellWidth);
- expect(getCell(0, 3).offsetWidth).toEqual(expectedCellWidth);
- expect(getCell(0, 4).offsetWidth).toEqual(expectedCellWidth);
- this.$container[0].style.width = '';
- this.$container.wrap('<div class="temp_wrapper" style="width:400px;"></div>');
- hot.render();
- expectedCellWidth = (parseInt($('.temp_wrapper')[0].style.width, 10) - rowHeaderWidth) / 5;
- expect(getCell(0, 0).offsetWidth).toEqual(expectedCellWidth);
- expect(getCell(0, 1).offsetWidth).toEqual(expectedCellWidth);
- expect(getCell(0, 2).offsetWidth).toEqual(expectedCellWidth);
- expect(getCell(0, 3).offsetWidth).toEqual(expectedCellWidth);
- expect(getCell(0, 4).offsetWidth).toEqual(expectedCellWidth);
- this.$container.unwrap();
- });
- it('should stretch all visible columns with overflow hidden', function () {
- this.$container[0].style.width = '501px';
- this.$container[0].style.height = '100px';
- this.$container[0].style.overflow = 'hidden';
- var hot = handsontable({
- startRows: 10,
- startCols: 5,
- colWidths: [47, 47, 47, 47, 47],
- rowHeaders: true,
- colHeaders: true,
- stretchH: 'all'
- });
- var masterTH = this.$container[0].querySelectorAll('.ht_master thead tr th');
- var overlayTH = this.$container[0].querySelectorAll('.ht_clone_top thead tr th');
- expect(masterTH[0].offsetWidth).toEqual(50);
- expect(overlayTH[0].offsetWidth).toEqual(50);
- expect(masterTH[1].offsetWidth).toBeInArray([86, 87, 88, 90]);
- expect(overlayTH[1].offsetWidth).toBeInArray([86, 87, 88, 90]); // if you get 90, it means it is calculated before scrollbars were applied, or show scroll on scrolling is enabled
- expect(masterTH[2].offsetWidth).toEqual(overlayTH[2].offsetWidth);
- expect(masterTH[3].offsetWidth).toEqual(overlayTH[3].offsetWidth);
- expect(masterTH[4].offsetWidth).toEqual(overlayTH[4].offsetWidth);
- expect(masterTH[5].offsetWidth).toEqual(overlayTH[5].offsetWidth);
- });
- it('should respect stretched widths returned in beforeStretchingColumnWidth hook', function () {
- this.$container[0].style.width = '501px';
- this.$container[0].style.height = '100px';
- this.$container[0].style.overflow = 'hidden';
- var callbackSpy = jasmine.createSpy();
- callbackSpy.and.callFake(function (width, column) {
- if (column === 1) {
- return 150;
- }
- return width;
- });
- var hot = handsontable({
- startRows: 2,
- startCols: 5,
- rowHeaders: true,
- colHeaders: true,
- stretchH: 'all',
- beforeStretchingColumnWidth: callbackSpy
- });
- var $columnHeaders = this.$container.find('thead tr:eq(0) th');
- expect($columnHeaders.eq(0).width()).toEqual(48);
- expect($columnHeaders.eq(1).width()).toEqual(73);
- expect($columnHeaders.eq(2).width()).toEqual(149);
- expect($columnHeaders.eq(3).width()).toEqual(74);
- expect($columnHeaders.eq(4).width()).toEqual(74);
- expect(callbackSpy).toHaveBeenCalled();
- // First cycle to check what columns has permanent width
- expect(callbackSpy.calls.argsFor(0)[0]).not.toBeDefined();
- expect(callbackSpy.calls.argsFor(0)[1]).toBe(0);
- expect(callbackSpy.calls.argsFor(1)[0]).not.toBeDefined();
- expect(callbackSpy.calls.argsFor(1)[1]).toBe(1);
- expect(callbackSpy.calls.argsFor(2)[0]).not.toBeDefined();
- expect(callbackSpy.calls.argsFor(2)[1]).toBe(2);
- expect(callbackSpy.calls.argsFor(3)[0]).not.toBeDefined();
- expect(callbackSpy.calls.argsFor(3)[1]).toBe(3);
- expect(callbackSpy.calls.argsFor(4)[0]).not.toBeDefined();
- expect(callbackSpy.calls.argsFor(4)[1]).toBe(4);
- // // Second cycle retrieve stretched width or permanent width
- expect(callbackSpy.calls.argsFor(5)[0]).toBe(75);
- expect(callbackSpy.calls.argsFor(6)[0]).toBe(75);
- expect(callbackSpy.calls.argsFor(7)[0]).toBe(75);
- expect(callbackSpy.calls.argsFor(8)[0]).toBe(75);
- expect(callbackSpy.calls.argsFor(9)[0]).toBe(75);
- });
- });
- });
- /***/ }),
- /* 182 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Handsontable.Dom', function () {
- describe('offset', function () {
- var $window = $(window),
- $forceScrollbar = $('<div id="forceScrollbar"></div>').css({
- position: 'absolute',
- height: '4000px',
- width: '4000px',
- top: 0,
- left: 0
- });
- beforeEach(function () {
- $forceScrollbar.appendTo(document.body);
- this.$div = $('<div id="test"></div>').appendTo($forceScrollbar);
- this.div = this.$div[0];
- });
- afterEach(function () {
- this.$div.remove();
- $forceScrollbar.remove();
- });
- describe('top', function () {
- it('should return offset top with position absolute', function () {
- this.$div.css({ position: 'absolute', top: 200 });
- expect(Handsontable.dom.offset(this.div).top).toEqual(200);
- });
- it('should return offset top with position absolute & scrolled window', function () {
- this.$div.css({ position: 'absolute', top: 200 });
- $window.scrollTop(1900);
- expect(Handsontable.dom.offset(this.div).top).toEqual(200);
- $window.scrollTop(0);
- });
- it('should return offset top with position fixed', function () {
- this.$div.css({ position: 'fixed', top: 200 });
- expect(Handsontable.dom.offset(this.div).top).toEqual(200);
- });
- it('should return offset top with position fixed & scrolled window', function () {
- this.$div.css({ position: 'fixed', top: 200 });
- $window.scrollTop(1900);
- expect(Handsontable.dom.offset(this.div).top).toEqual(2100); // this is the same jQuery offset returns
- $window.scrollTop(0);
- });
- });
- describe('left', function () {
- it('should return offset left with position absolute', function () {
- this.$div.css({ position: 'absolute', left: 200 });
- expect(Handsontable.dom.offset(this.div).left).toEqual(200);
- });
- it('should return offset left with position absolute & scrolled window', function () {
- this.$div.css({ position: 'absolute', left: 200 });
- $window.scrollLeft(1900);
- expect(Handsontable.dom.offset(this.div).left).toEqual(200);
- $window.scrollLeft(0);
- });
- it('should return offset left with position fixed', function () {
- this.$div.css({ position: 'fixed', left: 200 });
- expect(Handsontable.dom.offset(this.div).left).toEqual(200);
- });
- it('should return offset left with position fixed & scrolled window', function () {
- this.$div.css({ position: 'fixed', left: 200 });
- $window.scrollLeft(1900);
- expect(Handsontable.dom.offset(this.div).left).toEqual(2100); // this is the same jQuery offset returns
- $window.scrollLeft(0);
- });
- });
- });
- describe('isVisible', function () {
- it('should return true for appended table', function () {
- var $table = $('<table></table>').appendTo('body');
- expect(Handsontable.dom.isVisible($table[0])).toBe(true);
- $table.remove();
- });
- it('should return false for not appended table', function () {
- var $table = $('<table></table>');
- expect(Handsontable.dom.isVisible($table[0])).toBe(false);
- $table.remove();
- });
- it('should return false for table with `display: none`', function () {
- var $table = $('<table style="display: none"></table>').appendTo('body');
- expect(Handsontable.dom.isVisible($table[0])).toBe(false);
- $table.remove();
- });
- it('should return false for table with parent `display: none`', function () {
- var $div = $('<div style="display: none"></div>').appendTo('body');
- var $table = $('<table></table>').appendTo($div);
- expect(Handsontable.dom.isVisible($table[0])).toBe(false);
- $table.remove();
- });
- it('should return false for something detached from DOM', function () {
- var $table = $('<table><tr><td></td></tr></table>').appendTo('body');
- var TD = $table.find('td')[0];
- var TR = TD.parentNode;
- expect(Handsontable.dom.isVisible(TD)).toBe(true);
- TR.parentNode.removeChild(TR);
- expect(Handsontable.dom.isVisible(TD)).toBe(false);
- $table.remove();
- });
- });
- describe('outerHeight', function () {
- it('should return correct outerHeight for table', function () {
- var $table = $('<table style="border-width: 0;"><tbody><tr><td style="border: 1px solid black"><div style="height: 30px">test</div></td>' + '</tr></tbody></table>').appendTo('body');
- expect(Handsontable.dom.outerHeight($table[0])).toBe(38); // this is according to current stylesheet
- expect($table.outerHeight()).toBe(38); // jQuery check to confirm
- $table.remove();
- });
- it('should return correct outerHeight for table (with caption)', function () {
- var $table = $('<table style="border-width: 0;"><caption style="padding: 0; margin:0"><div style="height: 30px">caption</div></caption><tbody>' + '<tr><td style="border: 1px solid black"><div style="height: 30px">test</div></td></tr></tbody></table>').appendTo('body');
- expect(Handsontable.dom.outerHeight($table[0])).toBe(68); // this is according to current stylesheet
- $table.remove();
- });
- });
- it('should return correct offset for table cell (table with caption)', function () {
- var $table = $('<table style="border-width: 0;"><caption style="padding: 0; margin:0"><div style="height: 30px">caption</div></caption><tbody>' + '<tr><td style="border: 1px solid black"><div style="height: 30px">test</div></td></tr></tbody></table>').appendTo('body');
- var tableOffset = Handsontable.dom.offset($table[0]);
- var tdOffset = Handsontable.dom.offset($table.find('td')[0]);
- expect(parseInt(tdOffset.left - tableOffset.left, 10)).toBeAroundValue(2); // this is according to current stylesheet
- expect(parseInt(tdOffset.top - tableOffset.top, 10)).toBeAroundValue(32); // this is according to current stylesheet
- $table.remove();
- });
- it('should return font size', function () {
- var $html = $('<style>.bigText{font: 12px serif;}</style><div class="bigText"><span id="testable"></span></div>').appendTo('body');
- var span = document.getElementById('testable');
- var compStyle = Handsontable.dom.getComputedStyle(span);
- expect(compStyle.fontSize).toBe('12px');
- $html.remove();
- });
- it('should return top border width', function () {
- var $html = $('<style>.redBorder{border: 10px solid red;}</style><div class="redBorder" id="testable"></div>').appendTo('body');
- var div = document.getElementById('testable');
- var compStyle = Handsontable.dom.getComputedStyle(div);
- expect(compStyle.borderTopWidth).toBe('10px');
- $html.remove();
- });
- it('should insert HTML properly', function () {
- var $html = $('<div id="testable"></div>').appendTo('body');
- var text = '<span>test<br>test</span>';
- var div = document.getElementById('testable');
- Handsontable.dom.fastInnerHTML(div, text);
- Handsontable.dom.fastInnerHTML(div, text);
- expect(div.childNodes[0].childNodes.length).toEqual(3);
- $html.remove();
- });
- it('should set the immediatePropagation properties properly for given event', function () {
- var event = document.createEvent('MouseEvents');
- event.initMouseEvent('mousedown', true, true, window, null, null, null, null, null, null, null, null, null, null, null);
- Handsontable.dom.stopImmediatePropagation(event);
- expect(event.isImmediatePropagationEnabled).toBe(false);
- expect(Handsontable.dom.isImmediatePropagationStopped(event)).toBe(true);
- });
- describe('getScrollableElement', function () {
- it('should return scrollable element with \'scroll\' value of \'overflow\', \'overflowX\' or \'overflowY\' property', function () {
- var $html = $(['<div style="overflow: scroll"><span class="overflow"></span></div>', '<div style="overflow-x: scroll"><span class="overflowX"></span></div>', '<div style="overflow-y: scroll"><span class="overflowY"></span></div>'].join('')).appendTo('body');
- expect(Handsontable.dom.getScrollableElement($html.find('.overflow')[0])).toBe($html[0]);
- expect(Handsontable.dom.getScrollableElement($html.find('.overflowX')[0])).toBe($html[1]);
- expect(Handsontable.dom.getScrollableElement($html.find('.overflowY')[0])).toBe($html[2]);
- $html.remove();
- });
- it('should return scrollable element with \'auto\' value of \'overflow\' or \'overflowY\' property', function () {
- var $html = $(['<div style="overflow: auto; height: 50px;"><div class="knob" style="height: 100px"></div></div>', '<div style="overflow-y: auto; height: 50px;"><div class="knob" style="height: 100px"></div></div>', '<div style="overflow-y: auto; height: 50px;">', '<div>', '<div class="knob" style="height: 100px;"></div>', '</div>', '</div>'].join('')).appendTo('body');
- expect(Handsontable.dom.getScrollableElement($html.find('.knob')[0])).toBe($html[0]);
- expect(Handsontable.dom.getScrollableElement($html.find('.knob')[1])).toBe($html[1]);
- expect(Handsontable.dom.getScrollableElement($html.find('.knob')[2])).toBe($html[2]);
- $html.remove();
- });
- it('should return scrollable element with \'auto\' value of \'overflow\' or \'overflowX\' property', function () {
- var $html = $(['<div style="overflow: auto; width: 50px; height: 10px"><div class="knob" style="width: 100px; height: 5px"></div></div>', '<div style="overflow-x: auto; width: 50px; height: 10px"><div class="knob" style="width: 100px; height: 5px"></div></div>', '<div style="overflow-x: auto; width: 50px; height: 10px">', '<div>', '<div class="knob" style="width: 100px; height: 5px"></div>', '</div>', '</div>'].join('')).appendTo('body');
- expect(Handsontable.dom.getScrollableElement($html.find('.knob')[0])).toBe($html[0]);
- expect(Handsontable.dom.getScrollableElement($html.find('.knob')[1])).toBe($html[1]);
- expect(Handsontable.dom.getScrollableElement($html.find('.knob')[2])).toBe($html[2]);
- $html.remove();
- });
- it('should return window object as scrollable element', function () {
- var $html = $(['<div style="overflow: hidden; width: 50px; height: 10px"><div class="knob" style="width: 100px; height: 5px"></div></div>', '<div style="width: 50px; height: 10px"><div class="knob" style="width: 100px; height: 5px"></div></div>'].join('')).appendTo('body');
- expect(Handsontable.dom.getScrollableElement($html.find('.knob')[0])).toBe(window);
- expect(Handsontable.dom.getScrollableElement($html.find('.knob')[1])).toBe(window);
- $html.remove();
- });
- });
- //
- // Handsontable.dom.isChildOfWebComponentTable
- //
- describe('isChildOfWebComponentTable', function () {
- it('should return correct Boolean value depending on whether an element exists in `hot-table` or not', function () {
- // skip if browser not support Shadow DOM natively
- if (!document.createElement('div').createShadowRoot) {
- // Fix for "no exceptations" warnings
- expect(true).toBe(true);
- return;
- }
- var hotTable = document.createElement('hot-table');
- var outsideDiv = document.createElement('div');
- expect(Handsontable.dom.isChildOfWebComponentTable(hotTable)).toBe(true);
- expect(Handsontable.dom.isChildOfWebComponentTable(outsideDiv)).toBe(false);
- var hotTableDiv = document.createElement('div');
- hotTable.appendChild(hotTableDiv);
- expect(Handsontable.dom.isChildOfWebComponentTable(hotTableDiv)).toBe(true);
- var fragment = document.createDocumentFragment();
- expect(Handsontable.dom.isChildOfWebComponentTable(fragment)).toBe(false);
- var myElement = document.createElement('my-element');
- expect(Handsontable.dom.isChildOfWebComponentTable(myElement)).toBe(false);
- var shadowRoot = myElement.createShadowRoot();
- var insideDiv = shadowRoot.appendChild(document.createElement('div'));
- hotTable.createShadowRoot().appendChild(myElement);
- expect(Handsontable.dom.isChildOfWebComponentTable(myElement)).toBe(true);
- expect(Handsontable.dom.isChildOfWebComponentTable(insideDiv)).toBe(true);
- });
- });
- //
- // Handsontable.dom.polymerWrap
- //
- describe('polymerWrap', function () {
- it('should wrap element into polymer wrapper if exists', function () {
- expect(Handsontable.dom.polymerWrap(1)).toBe(1);
- window.wrap = function () {
- return 'wrapped';
- };
- window.Polymer = {};
- expect(Handsontable.dom.polymerWrap(1)).toBe('wrapped');
- // Test https://github.com/handsontable/handsontable/issues/2283
- window.wrap = document.createElement('div');
- expect(Handsontable.dom.polymerWrap(1)).toBe(1);
- delete window.wrap;
- delete window.Polymer;
- });
- });
- //
- // Handsontable.dom.polymerUnwrap
- //
- describe('polymerUnwrap', function () {
- it('should unwrap element from polymer wrapper if exists', function () {
- expect(Handsontable.dom.polymerUnwrap('wrapped')).toBe('wrapped');
- window.unwrap = function () {
- return 1;
- };
- window.Polymer = {};
- expect(Handsontable.dom.polymerUnwrap('wrapped')).toBe(1);
- window.unwrap = document.createElement('div');
- expect(Handsontable.dom.polymerUnwrap('wrapped')).toBe('wrapped');
- delete window.unwrap;
- delete window.Polymer;
- });
- });
- //
- // Handsontable.dom.addClass
- //
- describe('addClass', function () {
- it('should add class names as string to an element', function () {
- var element = document.createElement('div');
- expect(element.className).toBe('');
- Handsontable.dom.addClass(element, 'test');
- expect(element.className).toBe('test');
- Handsontable.dom.addClass(element, 'test test1 test2');
- expect(element.className).toBe('test test1 test2');
- Handsontable.dom.addClass(element, 'test3');
- expect(element.className).toBe('test test1 test2 test3');
- Handsontable.dom.addClass(element, '');
- expect(element.className).toBe('test test1 test2 test3');
- });
- it('should add class names as array to an element', function () {
- var element = document.createElement('div');
- expect(element.className).toBe('');
- Handsontable.dom.addClass(element, ['test']);
- expect(element.className).toBe('test');
- Handsontable.dom.addClass(element, ['test1', 'test2', 'test3']);
- expect(element.className).toBe('test test1 test2 test3');
- Handsontable.dom.addClass(element, 'test4');
- expect(element.className).toBe('test test1 test2 test3 test4');
- Handsontable.dom.addClass(element, '');
- expect(element.className).toBe('test test1 test2 test3 test4');
- });
- });
- //
- // Handsontable.dom.removeClass
- //
- describe('removeClass', function () {
- it('should remove class names as string from an element', function () {
- var element = document.createElement('div');
- element.className = 'test test1 test2 test3 test4';
- Handsontable.dom.removeClass(element, 'not-exists');
- expect(element.className).toBe('test test1 test2 test3 test4');
- Handsontable.dom.removeClass(element, 'test');
- expect(element.className).toBe('test1 test2 test3 test4');
- Handsontable.dom.removeClass(element, 'test test1 test4');
- expect(element.className).toBe('test2 test3');
- Handsontable.dom.removeClass(element, '');
- expect(element.className).toBe('test2 test3');
- });
- it('should remove class names as array from an element', function () {
- var element = document.createElement('div');
- element.className = 'test test1 test2 test3 test4';
- Handsontable.dom.removeClass(element, ['not-exists']);
- expect(element.className).toBe('test test1 test2 test3 test4');
- Handsontable.dom.removeClass(element, ['test']);
- expect(element.className).toBe('test1 test2 test3 test4');
- Handsontable.dom.removeClass(element, ['test', 'test1', 'test4']);
- expect(element.className).toBe('test2 test3');
- Handsontable.dom.removeClass(element, ['test', '', '']);
- expect(element.className).toBe('test2 test3');
- });
- });
- //
- // Handsontable.dom.hasClass
- //
- describe('hasClass', function () {
- it('should checks if an element has passed class name', function () {
- var element = document.createElement('div');
- element.className = 'test test1 test2 test3 test4';
- expect(Handsontable.dom.hasClass(element, 'not-exists')).toBe(false);
- expect(Handsontable.dom.hasClass(element, 'test3')).toBe(true);
- expect(Handsontable.dom.hasClass(element, 'test')).toBe(true);
- expect(Handsontable.dom.hasClass(element, '')).toBe(false);
- });
- });
- });
- /***/ }),
- /* 183 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('FillHandle', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should appear when fillHandle equals true', function () {
- handsontable({
- fillHandle: true
- });
- selectCell(2, 2);
- expect(isFillHandleVisible()).toBe(true);
- });
- it('should appear when fillHandle is enabled as `string` value', function () {
- handsontable({
- fillHandle: 'horizontal'
- });
- selectCell(2, 2);
- expect(isFillHandleVisible()).toBe(true);
- });
- it('should not change cell value (drag vertically when fillHandle option is set to `horizontal`)', function () {
- handsontable({
- data: [[1, 2, 3, 4, 5, 6], [7, 8, 9, 1, 2, 3], [4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6]],
- fillHandle: 'horizontal'
- });
- selectCell(0, 0);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tbody tr:eq(1) td:eq(0)').simulate('mouseover').simulate('mouseup');
- expect(getDataAtCell(1, 0)).toEqual(7);
- });
- it('should not change cell value (drag horizontally when fillHandle option is set to `vertical`)', function () {
- handsontable({
- data: [[1, 2, 3, 4, 5, 6], [7, 8, 9, 1, 2, 3], [4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6]],
- fillHandle: 'vertical'
- });
- selectCell(0, 0);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tbody tr:eq(0) td:eq(1)').simulate('mouseover').simulate('mouseup');
- expect(getDataAtCell(0, 1)).toEqual(2);
- });
- it('should work properly when fillHandle option is set to object with property `direction` set to `vertical`)', function () {
- handsontable({
- data: [[1, 2, 3, 4, 5, 6], [7, 8, 9, 1, 2, 3], [4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6]],
- fillHandle: {
- direction: 'vertical'
- }
- });
- selectCell(0, 0);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tbody tr:eq(0) td:eq(1)').simulate('mouseover').simulate('mouseup');
- expect(getDataAtCell(0, 1)).toEqual(2);
- selectCell(0, 0);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tbody tr:eq(1) td:eq(0)').simulate('mouseover').simulate('mouseup');
- expect(getDataAtCell(1, 0)).toEqual(1);
- });
- it('should work properly when fillHandle option is set to object with property `direction` set to `horizontal`)', function () {
- handsontable({
- data: [[1, 2, 3, 4, 5, 6], [7, 8, 9, 1, 2, 3], [4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6]],
- fillHandle: {
- direction: 'horizontal'
- }
- });
- selectCell(0, 0);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tbody tr:eq(0) td:eq(1)').simulate('mouseover').simulate('mouseup');
- expect(getDataAtCell(0, 1)).toEqual(1);
- selectCell(0, 0);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tbody tr:eq(1) td:eq(0)').simulate('mouseover').simulate('mouseup');
- expect(getDataAtCell(1, 0)).toEqual(7);
- });
- it('should not change cell value (drag when fillHandle is set to `false`)', function () {
- handsontable({
- data: [[1, 2, 3, 4, 5, 6], [7, 8, 9, 1, 2, 3], [4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6]],
- fillHandle: false
- });
- // checking drag vertically - should not change cell value
- selectCell(0, 0);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tbody tr:eq(0) td:eq(1)').simulate('mouseover').simulate('mouseup');
- expect(getDataAtCell(0, 1)).toEqual(2);
- // checking drag horizontally - should not change cell value
- selectCell(0, 0);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tbody tr:eq(0) td:eq(1)').simulate('mouseover').simulate('mouseup');
- expect(getDataAtCell(0, 1)).toEqual(2);
- });
- it('should work properly when using updateSettings', function () {
- var hot = handsontable({
- data: [[1, 2, 3, 4, 5, 6], [7, 8, 9, 1, 2, 3], [4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6]],
- fillHandle: 'horizontal'
- });
- updateSettings({ fillHandle: 'vertical' });
- // checking drag vertically - should change cell value
- selectCell(0, 0);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tbody tr:eq(0) td:eq(1)').simulate('mouseover').simulate('mouseup');
- expect(getDataAtCell(0, 1)).toEqual(2);
- updateSettings({ fillHandle: false });
- // checking drag vertically - should not change cell value
- selectCell(0, 1);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tbody tr:eq(1) td:eq(1)').simulate('mouseover').simulate('mouseup');
- expect(getDataAtCell(1, 1)).toEqual(8);
- // checking drag horizontally - should not change cell value
- selectCell(0, 1);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tbody tr:eq(0) td:eq(2)').simulate('mouseover').simulate('mouseup');
- expect(getDataAtCell(0, 2)).toEqual(3);
- });
- it('should appear when fillHandle is enabled as `object` value', function () {
- handsontable({
- fillHandle: {
- allowInsertRow: true
- }
- });
- selectCell(2, 2);
- expect(isFillHandleVisible()).toBe(true);
- });
- it('should not appear when fillHandle equals false', function () {
- handsontable({
- fillHandle: false
- });
- selectCell(2, 2);
- expect(isFillHandleVisible()).toBe(false);
- });
- it('should disappear when beginediting is triggered', function () {
- handsontable({
- fillHandle: true
- });
- selectCell(2, 2);
- keyDown('enter');
- expect(isFillHandleVisible()).toBe(false);
- });
- it('should appear when finishediting is triggered', function () {
- handsontable({
- fillHandle: true
- });
- selectCell(2, 2);
- keyDown('enter');
- keyDown('enter');
- expect(isFillHandleVisible()).toBe(true);
- });
- it('should not appear when fillHandle equals false and finishediting is triggered', function () {
- handsontable({
- fillHandle: false
- });
- selectCell(2, 2);
- keyDown('enter');
- keyDown('enter');
- expect(isFillHandleVisible()).toBe(false);
- });
- it('should appear when editor is discarded using the ESC key', function () {
- handsontable({
- fillHandle: true
- });
- selectCell(2, 2);
- keyDown('enter');
- keyDown('esc');
- expect(isFillHandleVisible()).toBe(true);
- });
- it('should add custom value after autofill', function () {
- handsontable({
- data: [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]],
- beforeAutofill: function beforeAutofill(start, end, data) {
- data[0][0] = 'test';
- }
- });
- selectCell(0, 0);
- this.$container.find('.wtBorder.corner').simulate('mousedown');
- this.$container.find('tr:eq(1) td:eq(0)').simulate('mouseover');
- this.$container.find('tr:eq(2) td:eq(0)').simulate('mouseover');
- this.$container.find('.wtBorder.corner').simulate('mouseup');
- expect(getSelected()).toEqual([0, 0, 2, 0]);
- expect(getDataAtCell(1, 0)).toEqual('test');
- });
- it('should use correct cell coordinates also when Handsontable is used inside a TABLE (#355)', function () {
- var $table = $('<table><tr><td></td></tr></table>').appendTo('body');
- this.$container.appendTo($table.find('td'));
- var ev;
- handsontable({
- data: [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]],
- beforeAutofill: function beforeAutofill(start, end, data) {
- data[0][0] = 'test';
- }
- });
- selectCell(1, 1);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tr:eq(1) td:eq(0)').simulate('mouseover');
- this.$container.find('tr:eq(2) td:eq(0)').simulate('mouseover');
- this.$container.find('tr:eq(2) td:eq(0)').simulate('mouseup');
- expect(getSelected()).toEqual([1, 1, 2, 1]);
- expect(getDataAtCell(2, 1)).toEqual('test');
- document.body.removeChild($table[0]);
- });
- it('should fill cells below until the end of content in the neighbouring column with current cell\'s data', function () {
- var hot = handsontable({
- data: [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, null, null, null, null], [1, 2, null, null, null, null]]
- });
- selectCell(1, 3);
- var fillHandle = this.$container.find('.wtBorder.current.corner')[0];
- mouseDoubleClick(fillHandle);
- expect(getDataAtCell(2, 3)).toEqual(null);
- expect(getDataAtCell(3, 3)).toEqual(null);
- selectCell(1, 2);
- mouseDoubleClick(fillHandle);
- expect(getDataAtCell(2, 2)).toEqual(3);
- expect(getDataAtCell(3, 2)).toEqual(3);
- });
- it('should fill cells below until the end of content in the neighbouring column with the currently selected area\'s data', function () {
- var hot = handsontable({
- data: [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, null, null, null, null], [1, 2, null, null, null, null]]
- });
- selectCell(1, 3, 1, 4);
- var fillHandle = this.$container.find('.wtBorder.area.corner')[0];
- mouseDoubleClick(fillHandle);
- expect(getDataAtCell(2, 3)).toEqual(null);
- expect(getDataAtCell(3, 3)).toEqual(null);
- expect(getDataAtCell(2, 4)).toEqual(null);
- expect(getDataAtCell(3, 4)).toEqual(null);
- selectCell(1, 2, 1, 3);
- mouseDoubleClick(fillHandle);
- expect(getDataAtCell(2, 2)).toEqual(3);
- expect(getDataAtCell(3, 2)).toEqual(3);
- expect(getDataAtCell(2, 3)).toEqual(4);
- expect(getDataAtCell(3, 3)).toEqual(4);
- });
- it('should add new row after dragging the handle to the last table row', function (done) {
- var hot = handsontable({
- data: [[1, 2, 'test', 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]]
- });
- selectCell(0, 2);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tr:last-child td:eq(2)').simulate('mouseover');
- expect(hot.countRows()).toBe(4);
- setTimeout(function () {
- expect(hot.countRows()).toBe(5);
- spec().$container.find('tr:last-child td:eq(2)').simulate('mouseover');
- }, 300);
- setTimeout(function () {
- expect(hot.countRows()).toBe(6);
- done();
- }, 600);
- });
- it('should add new row after dragging the handle to the last table row (autoInsertRow as true)', function (done) {
- var hot = handsontable({
- data: [[1, 2, 'test', 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]],
- fillHandle: {
- autoInsertRow: true
- }
- });
- selectCell(0, 2);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tr:last-child td:eq(2)').simulate('mouseover');
- expect(hot.countRows()).toBe(4);
- setTimeout(function () {
- expect(hot.countRows()).toBe(5);
- spec().$container.find('tr:last-child td:eq(2)').simulate('mouseover');
- }, 300);
- setTimeout(function () {
- expect(hot.countRows()).toBe(6);
- done();
- }, 600);
- });
- it('should add new row after dragging the handle to the last table row (autoInsertRow as true, vertical)', function (done) {
- var hot = handsontable({
- data: [[1, 2, 'test', 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]],
- fillHandle: {
- direction: 'vertical',
- autoInsertRow: true
- }
- });
- selectCell(0, 2);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tr:last-child td:eq(2)').simulate('mouseover');
- expect(hot.countRows()).toBe(4);
- setTimeout(function () {
- expect(hot.countRows()).toBe(5);
- spec().$container.find('tr:last-child td:eq(2)').simulate('mouseover');
- }, 300);
- setTimeout(function () {
- expect(hot.countRows()).toBe(6);
- done();
- }, 600);
- });
- it('should not add new row after dragging the handle to the last table row (autoInsertRow as true, horizontal)', function (done) {
- var hot = handsontable({
- data: [[1, 2, 'test', 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]],
- fillHandle: {
- direction: 'horizontal',
- autoInsertRow: true
- }
- });
- selectCell(0, 2);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tr:last-child td:eq(2)').simulate('mouseover');
- expect(hot.countRows()).toBe(4);
- setTimeout(function () {
- expect(hot.countRows()).toBe(4);
- spec().$container.find('tr:last-child td:eq(2)').simulate('mouseover');
- }, 300);
- setTimeout(function () {
- expect(hot.countRows()).toBe(4);
- done();
- }, 600);
- });
- it('should not add new row after dragging the handle below the viewport when `autoInsertRow` is disabled', function (done) {
- var hot = handsontable({
- data: [[1, 2, 'test', 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]],
- fillHandle: {
- autoInsertRow: false
- }
- });
- selectCell(0, 2);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- var ev = {};
- var $lastRow = this.$container.find('tr:last-child td:eq(2)');
- expect(hot.countRows()).toBe(4);
- ev.clientX = $lastRow.offset().left / 2;
- ev.clientY = $lastRow.offset().top + 50;
- $(document.documentElement).simulate('mousemove', ev);
- setTimeout(function () {
- expect(hot.countRows()).toBe(4);
- ev.clientY = $lastRow.offset().top + 150;
- $(document.documentElement).simulate('mousemove', ev);
- }, 300);
- setTimeout(function () {
- expect(hot.countRows()).toBe(4);
- done();
- }, 600);
- });
- it('should not add new rows if the current number of rows reaches the maxRows setting', function (done) {
- var hot = handsontable({
- data: [[1, 2, 'test', 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]],
- maxRows: 5
- });
- selectCell(0, 2);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tr:last-child td:eq(2)').simulate('mouseover');
- expect(hot.countRows()).toBe(4);
- setTimeout(function () {
- expect(hot.countRows()).toBe(5);
- spec().$container.find('tr:last-child td:eq(2)').simulate('mouseover');
- }, 200);
- setTimeout(function () {
- expect(hot.countRows()).toBe(5);
- done();
- }, 400);
- });
- it('should add new row after dragging the handle below the viewport', function (done) {
- var hot = handsontable({
- data: [[1, 2, 'test', 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]]
- });
- selectCell(0, 2);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- var ev = {};
- var $lastRow = this.$container.find('tr:last-child td:eq(2)');
- expect(hot.countRows()).toBe(4);
- ev.clientX = $lastRow.offset().left / 2;
- ev.clientY = $lastRow.offset().top + 50;
- $(document.documentElement).simulate('mousemove', ev);
- setTimeout(function () {
- expect(hot.countRows()).toBe(5);
- ev.clientY = $lastRow.offset().top + 150;
- $(document.documentElement).simulate('mousemove', ev);
- }, 300);
- setTimeout(function () {
- expect(hot.countRows()).toBe(6);
- done();
- }, 600);
- });
- it('should fill cells when dragging the handle to the headers', function () {
- var hot = handsontable({
- data: [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 7, 4, 5, 6], [1, 2, 3, 4, 5, 6]],
- colHeaders: true,
- rowHeaders: true
- });
- // col headers:
- selectCell(2, 2);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- var errors = 0;
- try {
- this.$container.find('thead tr:first-child th:eq(2)').simulate('mouseover').simulate('mouseup');
- } catch (err) {
- errors++;
- }
- expect(errors).toEqual(0);
- expect(getDataAtCell(1, 2)).toEqual(7);
- expect(getDataAtCell(0, 2)).toEqual(7);
- expect($('.fill').filter(function () {
- return $(this).css('display') !== 'none';
- }).length).toEqual(0); // check if fill selection is refreshed
- // row headers:
- selectCell(2, 2);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- errors = 0;
- try {
- this.$container.find('tbody tr:nth(2) th:first-child').simulate('mouseover').simulate('mouseup');
- } catch (err) {
- errors++;
- }
- expect(errors).toEqual(0);
- expect(getDataAtCell(2, 1)).toEqual(7);
- expect(getDataAtCell(2, 0)).toEqual(7);
- expect($('.fill').filter(function () {
- return $(this).css('display') !== 'none';
- }).length).toEqual(0); // check if fill selection is refreshed
- });
- it('should not add a new row if dragging from the last row upwards or sideways', function (done) {
- var mouseOverSpy = jasmine.createSpy('mouseOverSpy');
- var hot = handsontable({
- data: [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 'test', 4, 5, 6], [1, 2, 3, 4, 5, 6]],
- afterOnCellMouseOver: mouseOverSpy
- });
- selectCell(3, 2);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- this.$container.find('tr:nth-child(3) td:eq(2)').simulate('mouseover');
- setTimeout(function () {
- expect(hot.countRows()).toBe(4);
- selectCell(3, 2);
- spec().$container.find('.wtBorder.current.corner').simulate('mousedown');
- spec().$container.find('tr:nth-child(4) td:eq(3)').simulate('mouseover');
- }, 300);
- setTimeout(function () {
- expect(hot.countRows()).toBe(4);
- selectCell(3, 2);
- spec().$container.find('.wtBorder.current.corner').simulate('mousedown');
- spec().$container.find('tr:nth-child(4) td:eq(1)').simulate('mouseover');
- }, 500);
- setTimeout(function () {
- expect(hot.countRows()).toBe(4);
- done();
- }, 700);
- });
- it('should add new row after dragging the handle below the viewport', function (done) {
- var hot = handsontable({
- data: [[1, 2, 'test', 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]]
- });
- selectCell(0, 2);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- var ev = {};
- var $lastRow = this.$container.find('tr:last-child td:eq(2)');
- expect(hot.countRows()).toBe(4);
- ev.clientX = $lastRow.offset().left / 2;
- ev.clientY = $lastRow.offset().top + 50;
- $(document.documentElement).simulate('mousemove', ev);
- setTimeout(function () {
- expect(hot.countRows()).toBe(5);
- ev.clientY = $lastRow.offset().top + 150;
- $(document.documentElement).simulate('mousemove', ev);
- }, 300);
- setTimeout(function () {
- expect(hot.countRows()).toBe(6);
- done();
- }, 600);
- });
- it('should not add new row after dragging the handle below the viewport (direction is set to horizontal)', function (done) {
- var hot = handsontable({
- data: [[1, 2, 'test', 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]],
- fillHandle: {
- direction: 'horizontal',
- autoInsertRow: true
- }
- });
- selectCell(0, 2);
- this.$container.find('.wtBorder.current.corner').simulate('mousedown');
- var ev = {};
- var $lastRow = this.$container.find('tr:last-child td:eq(2)');
- expect(hot.countRows()).toBe(4);
- ev.clientX = $lastRow.offset().left / 2;
- ev.clientY = $lastRow.offset().top + 50;
- $(document.documentElement).simulate('mousemove', ev);
- setTimeout(function () {
- expect(hot.countRows()).toBe(4);
- done();
- }, 300);
- });
- describe('should works properly when two or more instances of Handsontable was initialized with other settings (#3257)', function () {
- var getData;
- var $container1;
- var $container2;
- beforeAll(function () {
- getData = function getData() {
- return [[1, 2, 3, 4, 5, 6], [7, 8, 9, 1, 2, 3], [4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6]];
- };
- $container1 = $('<div id="hot1"></div>').appendTo('body').handsontable({
- data: getData(),
- fillHandle: true
- });
- $container2 = $('<div id="hot2"></div>').appendTo('body').handsontable({
- data: getData(),
- fillHandle: 'horizontal'
- });
- });
- it('checking drag vertically on 1. instance of Handsontable - should change cell value', function () {
- $container1.handsontable('selectCell', 0, 0);
- $container1.find('.wtBorder.current.corner').simulate('mousedown');
- $container1.find('tbody tr:eq(1) td:eq(0)').simulate('mouseover').simulate('mouseup');
- expect($container1.handsontable('getDataAtCell', 1, 0)).toEqual(1);
- });
- describe('-> updating settings on 2. instance of Handsontable', function () {
- beforeAll(function () {
- $container2.handsontable('updateSettings', { fillHandle: 'vertical' });
- });
- it('checking drag vertically on 2. instance of Handsontable - should change cell value', function () {
- $container2.handsontable('selectCell', 0, 2);
- $container2.find('.wtBorder.current.corner').simulate('mousedown');
- $container2.find('tbody tr:eq(1) td:eq(2)').simulate('mouseover').simulate('mouseup');
- expect($container2.handsontable('getDataAtCell', 1, 2)).toEqual(3);
- });
- });
- afterAll(function () {
- // destroing containers
- $container1.handsontable('destroy');
- $container1.remove();
- $container2.handsontable('destroy');
- $container2.remove();
- });
- });
- });
- /***/ }),
- /* 184 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Performance', function () {
- var id = 'testContainer';
- // this is a test suite to test if there are no redundant operations
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should call renderer once for one cell (fixed column width)', function () {
- var count = 0;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 1),
- colWidths: 100,
- rowHeights: 23,
- renderer: function renderer() {
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- count++;
- }
- });
- expect(count).toEqual(1); // only for master table
- });
- it('should call renderer twice for one cell (auto column width)', function () {
- var count = 0;
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 1),
- rowHeights: 23,
- renderer: function renderer() {
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- count++;
- }
- });
- expect(count).toEqual(2); // 1 for autoColumnSize, 1 for actual cell render
- });
- it('should call renderer twice for one cell (auto row height)', function () {
- var count = 0;
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 1),
- colWidths: 50,
- renderer: function renderer() {
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- count++;
- }
- });
- expect(count).toEqual(1); // 1 for actual cell render (colWidths prevent autoColumnSize to enable)
- });
- it('should call renderer triple times for one cell (auto row height, auto column width)', function () {
- var count = 0;
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 1),
- autoRowSize: true,
- autoColumnSize: true,
- renderer: function renderer() {
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- count++;
- }
- });
- expect(count).toEqual(3); // 1 for autoColumnSize, 1 for autoRowSize, 1 for actual cell render
- });
- it('should call getCellMeta minimum number of times for one cell (auto column width, without overlays)', function () {
- var count = 0;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 1),
- rowHeights: 23,
- beforeGetCellMeta: function beforeGetCellMeta() {
- count++;
- }
- });
- expect(count).toEqual(7);
- });
- it('should call getCellMeta minimum number of times for one cell (auto row height, without overlays)', function () {
- var count = 0;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 1),
- colWidths: 50,
- beforeGetCellMeta: function beforeGetCellMeta() {
- count++;
- }
- });
- expect(count).toEqual(5);
- });
- it('should call getCellMeta minimum number of times for one cell (auto column width, with left overlay)', function () {
- var count = 0;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 1),
- colHeaders: true,
- rowHeights: 23,
- beforeGetCellMeta: function beforeGetCellMeta() {
- count++;
- }
- });
- expect(count).toEqual(8);
- });
- it('should call getCellMeta minimum number of times for one cell (auto row height, with left overlay)', function () {
- var count = 0;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 1),
- colHeaders: true,
- colWidths: 50,
- beforeGetCellMeta: function beforeGetCellMeta() {
- count++;
- }
- });
- expect(count).toEqual(6);
- });
- it('should call getCellMeta minimum number of times for one cell (auto column width, with top overlay)', function () {
- var count = 0;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 1),
- rowHeaders: true,
- rowHeights: 23,
- beforeGetCellMeta: function beforeGetCellMeta() {
- count++;
- }
- });
- expect(count).toEqual(7);
- });
- it('should call getCellMeta minimum number of times for one cell (auto row height, with top overlay)', function () {
- var count = 0;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 1),
- rowHeaders: true,
- colWidths: 50,
- beforeGetCellMeta: function beforeGetCellMeta() {
- count++;
- }
- });
- expect(count).toEqual(5);
- });
- it('should call getCellMeta minimum number of times for one cell (auto column width, with all overlays)', function () {
- var count = 0;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 1),
- colHeaders: true,
- rowHeaders: true,
- rowHeights: 23,
- beforeGetCellMeta: function beforeGetCellMeta() {
- count++;
- }
- });
- expect(count).toEqual(8);
- });
- it('should call getCellMeta minimum number of times for one cell (auto row height, with all overlays)', function () {
- var count = 0;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(1, 1),
- colHeaders: true,
- rowHeaders: true,
- colWidths: 50,
- beforeGetCellMeta: function beforeGetCellMeta() {
- count++;
- }
- });
- expect(count).toEqual(6);
- });
- it('should call renderer twice for each cell (auto column width)', function () {
- var count = 0;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- rowHeights: 23,
- autoColumnSize: true,
- renderer: function renderer() {
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- count++;
- }
- });
- expect(count).toEqual(28);
- });
- it('should call renderer twice for each cell (auto row height)', function () {
- var count = 0;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- colWidths: 50,
- autoRowSize: true,
- renderer: function renderer() {
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- count++;
- }
- });
- expect(count).toEqual(28); // 16 in main table and 4 rows for autoRowSize
- });
- it('should call renderer twice for each cell (auto row height, auto column width)', function () {
- var count = 0;
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- autoRowSize: true,
- autoColumnSize: true,
- renderer: function renderer() {
- Handsontable.renderers.TextRenderer.apply(this, arguments);
- count++;
- }
- });
- expect(count).toEqual(40); // 16x2 in main table, 4 rows for autoRowSize and 4 cols for autoColumnSize
- });
- });
- /***/ }),
- /* 185 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('PluginHooks', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should add a many local hooks at init (as array)', function () {
- var handler1 = jasmine.createSpy('handler1');
- var handler2 = jasmine.createSpy('handler2');
- var handler3 = jasmine.createSpy('handler3');
- handsontable({
- afterInit: [handler1, handler2, handler3]
- });
- expect(handler1).toHaveBeenCalled();
- expect(handler2).toHaveBeenCalled();
- expect(handler3).toHaveBeenCalled();
- });
- it('should remove a global hook', function () {
- var test = 0,
- hook = function hook() {
- test = 5;
- };
- Handsontable.hooks.add('afterInit', hook);
- Handsontable.hooks.remove('afterInit', hook);
- handsontable();
- expect(test).toEqual(0);
- });
- it('should remove a local hook', function () {
- var test = 0,
- hook = function hook() {
- test = 5;
- };
- handsontable();
- getInstance().addHook('afterInit', hook);
- getInstance().removeHook('afterInit', hook);
- expect(test).toEqual(0);
- });
- it('should run global hook', function () {
- var test = 0;
- Handsontable.hooks.add('afterInit', function () {
- test = 5;
- });
- handsontable();
- expect(test).toEqual(5);
- });
- it('should run local hook', function () {
- var test = 0;
- handsontable();
- getInstance().addHook('myHook', function () {
- test += 5;
- });
- getInstance().runHooks('myHook');
- getInstance().runHooks('myHook');
- expect(test).toEqual(10);
- });
- it('should run local hook once', function () {
- var test = 0;
- handsontable();
- getInstance().addHookOnce('myHook', function () {
- test += 5;
- });
- getInstance().runHooks('myHook');
- getInstance().runHooks('myHook');
- expect(test).toEqual(5);
- });
- it('should run all hooks', function () {
- var test = 0;
- Handsontable.hooks.add('afterInit', function () {
- test += 5;
- });
- handsontable({
- afterInit: function afterInit() {
- test += 5;
- }
- });
- expect(test).toEqual(10);
- });
- it('list of all avaliable plugin hooks should be exposed as a public method', function () {
- var hooks = Handsontable.hooks.getRegistered(); // this is used in demo/callbacks.html
- expect(hooks.indexOf('beforeInit')).toBeGreaterThan(-1);
- });
- it('should add a local hook with addHooks method', function () {
- var hot1 = handsontable();
- var test = 0;
- hot1.addHook('myHook', function () {
- test += 5;
- });
- hot1.runHooks('myHook');
- expect(test).toEqual(5);
- });
- it('should remove a local hook with removeHook method', function () {
- var hot1 = handsontable();
- var test = 0;
- var handler = function handler() {
- test += 5;
- };
- hot1.addHook('myHook', handler);
- hot1.runHooks('myHook');
- hot1.runHooks('myHook');
- expect(test).toEqual(10);
- hot1.removeHook('myHook', handler);
- hot1.runHooks('myHook');
- expect(test).toEqual(10);
- });
- it('should add a local hook with addHookOnce method and run it just once', function () {
- var hot1 = handsontable();
- var test = 0;
- var handler = function handler() {
- test += 5;
- };
- hot1.addHookOnce('myHook', handler);
- hot1.runHooks('myHook');
- hot1.runHooks('myHook');
- expect(test).toEqual(5);
- });
- it('should run hook with runHooks and return value', function () {
- var hot = handsontable();
- var handler = function handler() {
- return 5;
- };
- hot.addHook('myHook', handler);
- expect(hot.runHooks('myHook')).toEqual(5);
- });
- it('should run two "once" hooks in desired order', function () {
- var hot = handsontable();
- var arr = [];
- hot.addHookOnce('myHook', function () {
- arr.push(1);
- });
- hot.addHookOnce('myHook', function () {
- arr.push(2);
- });
- hot.runHooks('myHook');
- expect(arr).toEqual([1, 2]);
- });
- it('should execute two "once" hooks in desired order', function () {
- var hot = handsontable();
- var str = 'a';
- hot.addHookOnce('myHook', function (str) {
- return str + 'b';
- });
- hot.addHookOnce('myHook', function (str) {
- return str + 'c';
- });
- expect(hot.runHooks('myHook', str)).toEqual('abc');
- });
- it('adding same hook twice should register it only once (without an error)', function () {
- var i = 0;
- var fn = function fn() {
- i++;
- };
- var hot = handsontable({
- afterOnCellMouseOver: fn
- });
- hot.getInstance().updateSettings({ afterOnCellMouseOver: fn });
- hot.runHooks('afterOnCellMouseOver');
- expect(i).toEqual(1);
- });
- it('should mark the hook callbacks added with Handsontable initialization', function () {
- var fn = function fn() {};
- var fn2 = function fn2() {};
- var hot = handsontable({
- afterChange: fn
- });
- hot.addHook('afterChange', fn2);
- expect(fn.initialHook).toEqual(true);
- expect(fn2.initialHook).toEqual(void 0);
- });
- it('should mark the hook callbacks added using the updateSettings method', function () {
- var fn = function fn() {};
- var fn2 = function fn2() {};
- var hot = handsontable();
- hot.updateSettings({
- afterChange: fn
- });
- hot.addHook('afterChange', fn2);
- expect(fn.initialHook).toEqual(true);
- expect(fn2.initialHook).toEqual(void 0);
- });
- it('should replace the existing hook callbacks, if they\'re updated using the updateSettings method (when there was a hook ' + 'already declared in the initialization)', function () {
- var fn = function fn() {};
- var fn2 = function fn2() {};
- var hot = handsontable({
- afterGetCellMeta: fn
- });
- var initialCallbackCount = hot.pluginHookBucket.afterGetCellMeta.length;
- hot.updateSettings({
- afterGetCellMeta: function afterGetCellMeta() {
- var a = 'another function';
- }
- });
- hot.updateSettings({
- afterGetCellMeta: function afterGetCellMeta() {
- var a = 'yet another function';
- }
- });
- hot.updateSettings({
- afterGetCellMeta: fn2
- });
- expect(hot.pluginHookBucket.afterGetCellMeta.length).toEqual(initialCallbackCount);
- });
- it('should replace the existing hook callbacks, if they\'re updated using the updateSettings method', function () {
- var fn = function fn() {};
- var fn2 = function fn2() {};
- var hot = handsontable();
- hot.addHook('afterGetCellMeta', function () {
- return 'doesn\'t matter 1';
- });
- hot.addHook('afterGetCellMeta', function () {
- return 'doesn\'t matter 2';
- });
- hot.addHook('afterGetCellMeta', function () {
- return 'doesn\'t matter 3';
- });
- hot.updateSettings({
- afterGetCellMeta: fn
- });
- var initialCallbackCount = hot.pluginHookBucket.afterGetCellMeta.length;
- hot.updateSettings({
- afterGetCellMeta: function afterGetCellMeta() {
- var a = 'another function';
- }
- });
- hot.updateSettings({
- afterGetCellMeta: function afterGetCellMeta() {
- var a = 'yet another function';
- }
- });
- hot.updateSettings({
- afterGetCellMeta: fn2
- });
- expect(hot.pluginHookBucket.afterGetCellMeta.length).toEqual(initialCallbackCount);
- });
- it('should NOT replace existing hook callbacks, if the\'re added using the addHook method', function () {
- var fn = function fn() {};
- var fn2 = function fn2() {};
- var hot = handsontable();
- hot.updateSettings({
- afterGetCellMeta: fn
- });
- var initialCallbackCount = hot.pluginHookBucket.afterGetCellMeta.length;
- hot.addHook('afterGetCellMeta', function () {
- var a = 'another function';
- });
- hot.addHook('afterGetCellMeta', function () {
- var a = 'yet another function';
- });
- hot.addHook('afterGetCellMeta', fn2);
- // should not add this one, as it's a duplicate
- hot.addHook('afterGetCellMeta', fn);
- expect(hot.pluginHookBucket.afterGetCellMeta.length).toEqual(initialCallbackCount + 3);
- });
- describe('controlling handler queue execution', function () {
- it('should execute all handlers if none of them hasn\'t skipped', function () {
- var handler1 = jasmine.createSpy('handler1');
- var handler2 = jasmine.createSpy('handler2');
- var handler3 = jasmine.createSpy('handler3');
- var hot = handsontable();
- hot.addHook('fakeEvent', handler1);
- hot.addHook('fakeEvent', handler2);
- hot.addHook('fakeEvent', handler3);
- expect(handler1).not.toHaveBeenCalled();
- expect(handler2).not.toHaveBeenCalled();
- expect(handler3).not.toHaveBeenCalled();
- hot.runHooks('fakeEvent');
- expect(handler1).toHaveBeenCalled();
- expect(handler2).toHaveBeenCalled();
- expect(handler3).toHaveBeenCalled();
- });
- });
- });
- /***/ }),
- /* 186 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('RowHeader', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should not show row headers by default', function () {
- var that = this;
- handsontable();
- expect(that.$container.find('tbody th').length).toEqual(0);
- });
- it('should show row headers if true', function () {
- var that = this;
- handsontable({
- rowHeaders: true
- });
- expect(that.$container.find('tbody th').length).toBeGreaterThan(0);
- });
- it('should show row headers numbered 1-10 by default', function () {
- var that = this;
- var startRows = 5;
- handsontable({
- startRows: startRows,
- rowHeaders: true
- });
- var ths = getLeftClone().find('tbody th');
- expect(ths.length).toEqual(startRows);
- expect($.trim(ths.eq(0).text())).toEqual('1');
- expect($.trim(ths.eq(1).text())).toEqual('2');
- expect($.trim(ths.eq(2).text())).toEqual('3');
- expect($.trim(ths.eq(3).text())).toEqual('4');
- expect($.trim(ths.eq(4).text())).toEqual('5');
- });
- it('should show row headers with custom label', function () {
- var that = this;
- var startRows = 5;
- handsontable({
- startRows: startRows,
- rowHeaders: ['First', 'Second', 'Third']
- });
- var ths = getLeftClone().find('tbody th');
- expect(ths.length).toEqual(startRows);
- expect($.trim(ths.eq(0).text())).toEqual('First');
- expect($.trim(ths.eq(1).text())).toEqual('Second');
- expect($.trim(ths.eq(2).text())).toEqual('Third');
- expect($.trim(ths.eq(3).text())).toEqual('4');
- expect($.trim(ths.eq(4).text())).toEqual('5');
- });
- it('should not show row headers if false', function () {
- var that = this;
- handsontable({
- rowHeaders: false
- });
- expect(getLeftClone().find('tbody th').length).toEqual(0);
- });
- it('should hide rows headers after updateSetting', function () {
- var hot = handsontable({
- startRows: 5,
- rowHeaders: true
- });
- expect(getHtCore().find('tbody th').length).toEqual(5);
- expect(getLeftClone().find('tbody th').length).toEqual(5);
- hot.updateSettings({
- rowHeaders: false
- });
- expect(getHtCore().find('tbody th').length).toEqual(0);
- });
- it('should show rows headers after updateSettings', function () {
- var hot = handsontable({
- startRows: 5,
- rowHeaders: false
- });
- expect(getHtCore().find('tbody th').length).toEqual(0);
- expect(getLeftClone().find('tbody th').length).toEqual(0);
- hot.updateSettings({
- rowHeaders: true
- });
- expect(getHtCore().find('tbody th').length).toEqual(5);
- expect(getLeftClone().find('tbody th').length).toEqual(5);
- });
- it('should show/hide rows headers after multiple updateSettings', function () {
- var hot = handsontable({
- startRows: 5,
- rowHeaders: false
- });
- expect(getHtCore().find('tbody th').length).toEqual(0);
- expect(getLeftClone().find('tbody th').length).toEqual(0);
- hot.updateSettings({
- rowHeaders: true
- });
- expect(getHtCore().find('tbody th').length).toEqual(5);
- expect(getLeftClone().width()).toBeGreaterThan(0);
- hot.updateSettings({
- rowHeaders: false
- });
- expect(getHtCore().find('tbody th').length).toEqual(0);
- expect(getLeftClone().width()).toEqual(0);
- hot.updateSettings({
- rowHeaders: true
- });
- expect(getHtCore().find('tbody th').length).toEqual(5);
- expect(getLeftClone().width()).toBeGreaterThan(0);
- });
- it('should show new rows headers after updateSettings', function () {
- var hot = handsontable({
- startCols: 3,
- rowHeaders: ['A', 'B', 'C']
- });
- var leftClone = getLeftClone();
- expect(leftClone.find('tbody tr:eq(0) th:eq(0)').text()).toEqual('A');
- expect(leftClone.find('tbody tr:eq(1) th:eq(0)').text()).toEqual('B');
- expect(leftClone.find('tbody tr:eq(2) th:eq(0)').text()).toEqual('C');
- hot.updateSettings({
- rowHeaders: ['X', 'Y', 'Z']
- });
- expect(leftClone.find('tbody tr:eq(0) th:eq(0)').text()).toEqual('X');
- expect(leftClone.find('tbody tr:eq(1) th:eq(0)').text()).toEqual('Y');
- expect(leftClone.find('tbody tr:eq(2) th:eq(0)').text()).toEqual('Z');
- });
- it('should allow defining custom row header width using the rowHeaderWidth config option', function () {
- var hot = handsontable({
- startCols: 3,
- rowHeaders: true,
- rowHeaderWidth: 150
- });
- expect(this.$container.find('th').eq(0).outerWidth()).toEqual(150);
- expect(this.$container.find('col').first().css('width')).toEqual('150px');
- });
- it('should allow defining custom column header heights using the columnHeaderHeight config option, when multiple column header levels are defined', function () {
- var hot = handsontable({
- startCols: 3,
- rowHeaders: true,
- rowHeaderWidth: [66, 96],
- afterGetRowHeaderRenderers: function afterGetRowHeaderRenderers(array) {
- array.push(function (index, TH) {
- TH.innerHTML = '';
- var div = document.createElement('div');
- var span = document.createElement('span');
- div.className = 'relative';
- span.className = 'rowHeader';
- span.innerText = index;
- div.appendChild(span);
- TH.appendChild(div);
- });
- return array;
- }
- });
- hot.render();
- expect(this.$container.find('.handsontable.ht_clone_left tr:nth-child(1) th:nth-child(1)').outerWidth()).toEqual(66);
- expect(this.$container.find('.handsontable.ht_clone_left tr:nth-child(1) th:nth-child(2)').outerWidth()).toEqual(96);
- expect(this.$container.find('col').first().css('width')).toEqual('66px');
- expect(this.$container.find('col').eq(1).css('width')).toEqual('96px');
- });
- });
- /***/ }),
- /* 187 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
- describe('cellTypes', function () {
- var id = 'testContainer';
- var _Handsontable$cellTyp = Handsontable.cellTypes,
- registerCellType = _Handsontable$cellTyp.registerCellType,
- getCellType = _Handsontable$cellTyp.getCellType;
- var _Handsontable$editors = Handsontable.editors,
- registerEditor = _Handsontable$editors.registerEditor,
- getEditor = _Handsontable$editors.getEditor,
- BaseEditor = _Handsontable$editors.BaseEditor;
- var _Handsontable$rendere = Handsontable.renderers,
- registerRenderer = _Handsontable$rendere.registerRenderer,
- getRenderer = _Handsontable$rendere.getRenderer;
- var _Handsontable$validat = Handsontable.validators,
- registerValidator = _Handsontable$validat.registerValidator,
- getValidator = _Handsontable$validat.getValidator;
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should register custom cell type (with custom editor, renderer and validator)', _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
- var MyEditor, onAfterValidate, hot;
- return regeneratorRuntime.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- MyEditor = function (_BaseEditor) {
- _inherits(MyEditor, _BaseEditor);
- function MyEditor() {
- _classCallCheck(this, MyEditor);
- return _possibleConstructorReturn(this, (MyEditor.__proto__ || Object.getPrototypeOf(MyEditor)).apply(this, arguments));
- }
- _createClass(MyEditor, [{
- key: 'init',
- value: function init() {
- this.TEXTAREA = document.createElement('TEXTAREA');
- this.TEXTAREA_PARENT = document.createElement('DIV');
- this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
- this.instance.rootElement.appendChild(this.TEXTAREA_PARENT);
- }
- }, {
- key: 'getValue',
- value: function getValue() {
- return '**' + this.TEXTAREA.value + '**';
- }
- }, {
- key: 'setValue',
- value: function setValue(value) {
- this.TEXTAREA.value = value;
- }
- }, {
- key: 'open',
- value: function open() {}
- }, {
- key: 'close',
- value: function close() {}
- }, {
- key: 'focus',
- value: function focus() {
- this.TEXTAREA.focus();
- }
- }]);
- return MyEditor;
- }(BaseEditor);
- registerCellType('myCellType', {
- editor: MyEditor,
- renderer: function renderer(hot, td, row, col, prop, value, cellProperties) {
- td.innerHTML = '--' + value + '--';
- },
- validator: function validator(value, cb) {
- cb(value === 10);
- }
- });
- onAfterValidate = jasmine.createSpy('onAfterValidate');
- hot = handsontable({
- data: [[1, 6, 10]],
- columns: [{
- type: 'myCellType'
- }],
- afterValidate: onAfterValidate
- });
- hot.setDataAtCell(1, 0, 10);
- _context.next = 7;
- return sleep(100);
- case 7:
- expect(onAfterValidate).toHaveBeenCalledWith(true, 10, 1, 0, undefined, undefined);
- expect(getCell(1, 0).innerHTML).toBe('--10--');
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'hello';
- destroyEditor();
- _context.next = 15;
- return sleep(100);
- case 15:
- expect(onAfterValidate).toHaveBeenCalledWith(false, '**hello**', 0, 0, 'edit', undefined);
- expect(getCell(0, 0).innerHTML).toBe('--**hello**--');
- case 17:
- case 'end':
- return _context.stop();
- }
- }
- }, _callee, undefined);
- })));
- it('should retrieve predefined cell types by its names', function () {
- var _Handsontable = Handsontable,
- editors = _Handsontable.editors,
- renderers = _Handsontable.renderers,
- validators = _Handsontable.validators;
- expect(getCellType('autocomplete').editor).toBe(editors.AutocompleteEditor);
- expect(getCellType('autocomplete').renderer).toBe(renderers.AutocompleteRenderer);
- expect(getCellType('autocomplete').validator).toBe(validators.AutocompleteValidator);
- expect(getCellType('checkbox').editor).toBe(editors.CheckboxEditor);
- expect(getCellType('checkbox').renderer).toBe(renderers.CheckboxRenderer);
- expect(getCellType('checkbox').validator).not.toBeDefined();
- expect(getCellType('date').editor).toBe(editors.DateEditor);
- expect(getCellType('date').renderer).toBe(renderers.AutocompleteRenderer);
- expect(getCellType('date').validator).toBe(validators.DateValidator);
- expect(getCellType('dropdown').editor).toBe(editors.DropdownEditor);
- expect(getCellType('dropdown').renderer).toBe(renderers.AutocompleteRenderer);
- expect(getCellType('dropdown').validator).toBe(validators.AutocompleteValidator);
- expect(getCellType('handsontable').editor).toBe(editors.HandsontableEditor);
- expect(getCellType('handsontable').renderer).toBe(renderers.AutocompleteRenderer);
- expect(getCellType('handsontable').validator).not.toBeDefined();
- expect(getCellType('numeric').editor).toBe(editors.NumericEditor);
- expect(getCellType('numeric').renderer).toBe(renderers.NumericRenderer);
- expect(getCellType('numeric').validator).toBe(validators.NumericValidator);
- expect(getCellType('numeric').dataType).toBe('number');
- expect(getCellType('password').editor).toBe(editors.PasswordEditor);
- expect(getCellType('password').renderer).toBe(renderers.PasswordRenderer);
- expect(getCellType('password').validator).not.toBeDefined();
- expect(getCellType('password').copyable).toBe(false);
- expect(getCellType('text').editor).toBe(editors.TextEditor);
- expect(getCellType('text').renderer).toBe(renderers.TextRenderer);
- expect(getCellType('text').validator).not.toBeDefined();
- expect(getCellType('time').editor).toBe(editors.TextEditor);
- expect(getCellType('time').renderer).toBe(renderers.TextRenderer);
- expect(getCellType('time').validator).toBe(validators.TimeValidator);
- });
- it('should register custom cell type into renderers, editors and validators', function () {
- var MyEditor = function MyEditor() {
- _classCallCheck(this, MyEditor);
- };
- function myRenderer() {}
- function myValidator() {}
- registerCellType('myCellType', {
- editor: MyEditor,
- renderer: myRenderer,
- validator: myValidator
- });
- expect(getEditor('myCellType')).toBe(MyEditor);
- expect(getRenderer('myCellType')).toBe(myRenderer);
- expect(getValidator('myCellType')).toBe(myValidator);
- });
- it('should overwrite cell types under the same name', function () {
- var MyEditor = function MyEditor() {
- _classCallCheck(this, MyEditor);
- };
- function myRenderer() {}
- function myValidator() {}
- registerCellType('myCellType', {
- editor: MyEditor,
- renderer: myRenderer,
- validator: myValidator
- });
- expect(getEditor('myCellType')).toBe(MyEditor);
- expect(getRenderer('myCellType')).toBe(myRenderer);
- expect(getValidator('myCellType')).toBe(myValidator);
- function myRenderer2() {}
- function myValidator2() {}
- registerCellType('myCellType', {
- renderer: myRenderer2,
- validator: myValidator2
- });
- expect(getEditor('myCellType')).toBe(MyEditor);
- expect(getRenderer('myCellType')).toBe(myRenderer2);
- expect(getValidator('myCellType')).toBe(myValidator2);
- });
- it('should retrieve custom cell type by its names', function () {
- var MyEditor = function MyEditor() {
- _classCallCheck(this, MyEditor);
- };
- function myRenderer() {}
- function myValidator() {}
- registerCellType('myCellType', {
- editor: MyEditor,
- renderer: myRenderer,
- validator: myValidator
- });
- expect(getCellType('myCellType').editor).toBe(MyEditor);
- expect(getCellType('myCellType').renderer).toBe(myRenderer);
- expect(getCellType('myCellType').validator).toBe(myValidator);
- });
- });
- /***/ }),
- /* 188 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.colToProp', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should return the property name for the provided column number', function () {
- var hot = handsontable({
- data: [{
- id: 1,
- firstName: 'Tobias',
- lastName: 'Forge'
- }]
- });
- expect(colToProp(0)).toBe('id');
- expect(colToProp(1)).toBe('firstName');
- expect(colToProp(2)).toBe('lastName');
- });
- it('it should return the provided property name, when the user passes a property name as a column number', function () {
- var hot = handsontable({
- data: [{
- id: 1,
- sort: true,
- length: 2
- }]
- });
- expect(colToProp('id')).toBe('id');
- expect(colToProp('sort')).toBe('sort');
- expect(colToProp('length')).toBe('length');
- });
- });
- /***/ }),
- /* 189 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.countSourceCols', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should return properly index from ', function () {
- var hot = handsontable({
- data: [['', '', '', '', '', '', '', '', '', '', '', '', '', '', '']],
- columns: function columns(column) {
- return [1, 5, 9].indexOf(column) > -1 ? {} : null;
- }
- });
- expect(hot.countSourceCols()).toBe(15);
- });
- });
- /***/ }),
- /* 190 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.getCellMetaAtRow', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should return a row of cell meta in a form of an array', function () {
- handsontable();
- var rowOfMeta = getCellMetaAtRow(0);
- expect(rowOfMeta.length).toBe(5);
- expect(rowOfMeta[0].row).toBe(0);
- expect(rowOfMeta[1].row).toBe(0);
- expect(rowOfMeta[2].row).toBe(0);
- expect(rowOfMeta[3].row).toBe(0);
- expect(rowOfMeta[4].row).toBe(0);
- expect(rowOfMeta[0].col).toBe(0);
- expect(rowOfMeta[1].col).toBe(1);
- expect(rowOfMeta[2].col).toBe(2);
- expect(rowOfMeta[3].col).toBe(3);
- expect(rowOfMeta[4].col).toBe(4);
- expect(rowOfMeta[0].prop).toBe(0);
- expect(rowOfMeta[1].prop).toBe(1);
- expect(rowOfMeta[2].prop).toBe(2);
- expect(rowOfMeta[3].prop).toBe(3);
- expect(rowOfMeta[4].prop).toBe(4);
- });
- });
- /***/ }),
- /* 191 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.getCellsMeta', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should return all initialized cells meta as flatten array', function () {
- handsontable();
- var metas = getCellsMeta();
- expect(metas.length).toBe(25); // default data size
- expect(metas[0].row).toBe(0);
- expect(metas[0].col).toBe(0);
- expect(metas[0].prop).toBe(0);
- expect(metas[19].row).toBe(3);
- expect(metas[19].col).toBe(4);
- expect(metas[19].prop).toBe(4);
- });
- });
- /***/ }),
- /* 192 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.getCopyableData', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should return copyable data when `copyable` option is enabled', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- copyable: true
- });
- expect(getCopyableData(0, 0)).toBe('A1');
- expect(getCopyableData(1, 1)).toBe('B2');
- expect(getCopyableData(5, 1)).toBe('B6');
- expect(getCopyableData(8, 9)).toBe('J9');
- });
- it('should return empty string as copyable data when `copyable` option is disabled', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- copyable: false
- });
- expect(getCopyableData(0, 0)).toBe('');
- expect(getCopyableData(1, 1)).toBe('');
- expect(getCopyableData(5, 1)).toBe('');
- expect(getCopyableData(8, 9)).toBe('');
- });
- });
- /***/ }),
- /* 193 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.getCopyableText', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should return copyable string when `copyable` option is enabled', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- copyable: true
- });
- expect(getCopyableText(0, 0)).toBe('A1');
- expect(getCopyableText(0, 0, 1, 2)).toBe('A1\tB1\tC1\nA2\tB2\tC2');
- });
- it('should return empty string as copyable data when `copyable` option is disabled', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- copyable: false
- });
- expect(getCopyableText(0, 0)).toBe('');
- expect(getCopyableText(0, 0, 1, 2)).toBe('\t\t\n\t\t');
- });
- });
- /***/ }),
- /* 194 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.getSourceDataArray', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should return data as an array when provided data was an array of arrays', function () {
- handsontable({
- data: [[1, 2, 3], ['a', 'b', 'c']],
- copyable: true
- });
- expect(getSourceDataArray()).toEqual([[1, 2, 3], ['a', 'b', 'c']]);
- expect(getSourceDataArray(0, 1, 1, 2)).toEqual([[2, 3], ['b', 'c']]);
- });
- it('should return data as an array when provided data was an array of objects', function () {
- handsontable({
- data: [{ a: 1, b: 2, c: 3 }, { a: 'a', b: 'b', c: 'c' }],
- copyable: true
- });
- expect(getSourceDataArray()).toEqual([[1, 2, 3], ['a', 'b', 'c']]);
- expect(getSourceDataArray(0, 1, 1, 2)).toEqual([[2, 3], ['b', 'c']]);
- });
- });
- /***/ }),
- /* 195 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.getSourceDataAtCell', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should return null when is call without arguments', function () {
- handsontable({
- data: [[1, 2, 3], ['a', 'b', 'c']]
- });
- expect(getSourceDataAtCell()).toBeNull();
- });
- it('should return cell value when provided data was an array of arrays', function () {
- handsontable({
- data: [[1, 2, 3], ['a', 'b', 'c']]
- });
- expect(getSourceDataAtCell(1, 1)).toEqual('b');
- });
- it('should return cell value when provided data was an array of objects', function () {
- handsontable({
- data: [{ a: 1, b: 2, c: 3 }, { a: 'a', b: 'b', c: 'c' }],
- copyable: true
- });
- expect(getSourceDataAtCell(1, 'b')).toEqual('b');
- });
- it('should return cell value when provided data was an array of objects (nested structure)', function () {
- handsontable({
- data: [{ a: 1, b: { a: 21, b: 22 }, c: 3 }, { a: 'a', b: { a: 'ba', b: 'bb' }, c: 'c' }],
- columns: [{ data: 'a' }, { data: 'b.a' }, { data: 'b.b' }, { data: 'c' }]
- });
- expect(getSourceDataAtCell(1, 'b.b')).toEqual('bb');
- });
- it('should return cell value when data is provided by dataSchema', function () {
- handsontable({
- data: [model({ id: 1, name: 'Ted Right', address: '' }), model({ id: 2, name: 'Frank Honest', address: '' }), model({ id: 3, name: 'Joan Well', address: '' }), model({ id: 4, name: 'Gail Polite', address: '' }), model({ id: 5, name: 'Michael Fair', address: '' })],
- dataSchema: model,
- columns: [{ data: property('id') }, { data: property('name') }, { data: property('address') }]
- });
- function model(opts) {
- var _pub = {},
- _priv = {
- id: undefined,
- name: undefined,
- address: undefined
- };
- for (var i in opts) {
- if (Object.prototype.hasOwnProperty.call(opts, i)) {
- _priv[i] = opts[i];
- }
- }
- _pub.attr = function (attr, val) {
- if (typeof val === 'undefined') {
- return _priv[attr];
- }
- _priv[attr] = val;
- return _pub;
- };
- return _pub;
- }
- function property(attr) {
- return function (row, value) {
- return row.attr(attr, value);
- };
- }
- expect(getSourceDataAtCell(1, 1)).toEqual('Frank Honest');
- });
- describe('`modifyRowData` hook', function () {
- it('should be possible to change data for row on the fly ', function () {
- handsontable({
- data: [['', 'Kia', 'Nissan', 'Toyota', 'Honda'], ['2008', 10, 11, 12, 13], ['2009', 20, 11, 14, 13], ['2010', 30, 15, 12, 13]],
- modifyRowData: function modifyRowData(row) {
- var newDataset = [];
- if (row === 1) {
- newDataset.push('2016', 0, 0, 0, 0);
- }
- return newDataset.length ? newDataset : void 0;
- }
- });
- expect(getSourceDataAtCell(1, 0)).toEqual('2016');
- });
- });
- });
- /***/ }),
- /* 196 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.propToCol', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should return valid index for newly added column when manualColumnMove is enabled', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- manualColumnMove: true
- });
- hot.alter('insert_col', 5);
- expect(propToCol(0)).toBe(0);
- expect(propToCol(10)).toBe(10);
- });
- });
- /***/ }),
- /* 197 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.setCellMeta', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should set correct meta className for cell', function () {
- var className = 'htCenter htMiddle';
- handsontable({
- afterCellMetaReset: function afterCellMetaReset() {
- this.setCellMeta(0, 0, 'className', className);
- }
- });
- var cellMeta = getCellMeta(0, 0);
- expect(cellMeta.className).not.toBeUndefined();
- expect(cellMeta.className).toEqual(className);
- });
- it('should set correct meta className for non existed cell', function () {
- var className = 'htCenter htMiddle';
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- afterCellMetaReset: function afterCellMetaReset() {
- this.setCellMeta(100, 100, 'className', className);
- }
- });
- var cellMeta = getCellMeta(100, 100);
- expect(cellMeta.className).not.toBeUndefined();
- expect(cellMeta.className).toEqual(className);
- });
- it('should set correct meta classNames for cells using cell in configuration', function () {
- var classNames = ['htCenter htTop', 'htRight htBottom'];
- handsontable({
- cell: [{ row: 0, col: 0, className: classNames[0] }, { row: 1, col: 1, className: classNames[1] }]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)')[0].className).toEqual(classNames[0]);
- expect(this.$container.find('tbody tr:eq(1) td:eq(1)')[0].className).toEqual(classNames[1]);
- });
- it('should change cell meta data with updateSettings when the cell option is defined', function () {
- var classNames = ['htCenter htTop', 'htRight htBottom'];
- handsontable({
- cell: [{ row: 0, col: 0, className: classNames[0] }, { row: 1, col: 1, className: classNames[1] }]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)')[0].className).toEqual(classNames[0]);
- expect(this.$container.find('tbody tr:eq(1) td:eq(1)')[0].className).toEqual(classNames[1]);
- updateSettings({
- cell: []
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)')[0].className).toEqual('');
- expect(this.$container.find('tbody tr:eq(1) td:eq(1)')[0].className).toEqual('');
- updateSettings({
- cell: [{ row: 0, col: 0, className: classNames[1] }, { row: 1, col: 1, className: classNames[0] }]
- });
- expect(this.$container.find('tbody tr:eq(0) td:eq(0)')[0].className).toEqual(classNames[1]);
- expect(this.$container.find('tbody tr:eq(1) td:eq(1)')[0].className).toEqual(classNames[0]);
- });
- it('should call afterSetCellMeta plugin hook', function () {
- var className = 'htCenter htMiddle';
- var res = {};
- handsontable({
- afterCellMetaReset: function afterCellMetaReset() {
- this.setCellMeta(0, 1, 'className', className);
- },
- afterSetCellMeta: function afterSetCellMeta(row, col, key, val) {
- res.row = row;
- res.col = col;
- res.key = key;
- res.val = val;
- }
- });
- expect(res.row).toEqual(0);
- expect(res.col).toEqual(1);
- expect(res.key).toEqual('className');
- expect(res.val).toEqual(className);
- });
- });
- /***/ }),
- /* 198 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.spliceCellsMeta', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should splice the cell meta array analogously to the native `splice` method', function () {
- handsontable();
- var allMeta = getCellsMeta();
- expect(allMeta.length).toBe(25);
- spliceCellsMeta(3, 1);
- allMeta = getCellsMeta();
- expect(allMeta.length).toBe(20);
- var metaAtRow = getCellMetaAtRow(2);
- expect(metaAtRow[0].row).toEqual(2);
- metaAtRow = getCellMetaAtRow(3);
- expect(metaAtRow[0].row).toEqual(4);
- });
- });
- /***/ }),
- /* 199 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.spliceCol', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should remove from the second column three rows starting from the beginning', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5)
- });
- var removedData = hot.spliceCol(1, 0, 3);
- expect(removedData).toEqual(['B1', 'B2', 'B3']);
- expect(hot.getDataAtRow(0)).toEqual(['A1', 'B4', 'C1', 'D1', 'E1']);
- expect(hot.getDataAtRow(1)).toEqual(['A2', 'B5', 'C2', 'D2', 'E2']);
- expect(hot.getDataAtRow(2)).toEqual(['A3', null, 'C3', 'D3', 'E3']);
- expect(hot.getDataAtRow(3)).toEqual(['A4', null, 'C4', 'D4', 'E4']);
- expect(hot.getDataAtRow(4)).toEqual(['A5', null, 'C5', 'D5', 'E5']);
- });
- it('should remove from the third column three rows starting from the second row', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5)
- });
- var removedData = hot.spliceCol(2, 1, 3);
- expect(removedData).toEqual(['C2', 'C3', 'C4']);
- expect(hot.getDataAtRow(0)).toEqual(['A1', 'B1', 'C1', 'D1', 'E1']);
- expect(hot.getDataAtRow(1)).toEqual(['A2', 'B2', 'C5', 'D2', 'E2']);
- expect(hot.getDataAtRow(2)).toEqual(['A3', 'B3', null, 'D3', 'E3']);
- expect(hot.getDataAtRow(3)).toEqual(['A4', 'B4', null, 'D4', 'E4']);
- expect(hot.getDataAtRow(4)).toEqual(['A5', 'B5', null, 'D5', 'E5']);
- });
- it('should replace and append new rows in the second column starting from the second row', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5)
- });
- var removedData = hot.spliceCol(1, 1, 3, 'X1', 'X2', 'X3', 'X4', 'X5');
- expect(removedData).toEqual(['B2', 'B3', 'B4']);
- expect(hot.getDataAtRow(0)).toEqual(['A1', 'B1', 'C1', 'D1', 'E1']);
- expect(hot.getDataAtRow(1)).toEqual(['A2', 'X1', 'C2', 'D2', 'E2']);
- expect(hot.getDataAtRow(2)).toEqual(['A3', 'X2', 'C3', 'D3', 'E3']);
- expect(hot.getDataAtRow(3)).toEqual(['A4', 'X3', 'C4', 'D4', 'E4']);
- expect(hot.getDataAtRow(4)).toEqual(['A5', 'X4', 'C5', 'D5', 'E5']);
- expect(hot.getDataAtRow(5)).toEqual([null, 'X5', null, null, null]);
- expect(hot.getDataAtRow(6)).toEqual([null, 'B5', null, null, null]);
- });
- it('should trigger beforeChange and afterChange hook with proper arguments', function () {
- var spyAfter = jasmine.createSpy('after');
- var spyBefore = jasmine.createSpy('before');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- beforeChange: spyBefore,
- afterChange: spyAfter
- });
- hot.spliceCol(2, 1, 3, 'X1');
- expect(spyBefore.calls.argsFor(0)[0]).toEqual([[1, 2, 'C2', 'X1'], [2, 2, 'C3', 'C5'], [3, 2, 'C4', null], [4, 2, 'C5', null], [5, 2, null, null]]);
- expect(spyBefore.calls.argsFor(0)[1]).toBe('spliceCol');
- expect(spyAfter.calls.argsFor(1)[0]).toEqual([[1, 2, 'C2', 'X1'], [2, 2, 'C3', 'C5'], [3, 2, 'C4', null], [4, 2, 'C5', null], [5, 2, null, null]]);
- expect(spyAfter.calls.argsFor(1)[1]).toBe('spliceCol');
- });
- it('should trigger beforeCreateRow and afterCreateRow hook with proper arguments', function () {
- var spyAfter = jasmine.createSpy('after');
- var spyBefore = jasmine.createSpy('before');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- beforeCreateRow: spyBefore,
- afterCreateRow: spyAfter
- });
- hot.spliceCol(2, 1, 3, 'X1', 'X2', 'X3', 'X4');
- expect(spyBefore).toHaveBeenCalledWith(5, 1, 'spliceCol', undefined, undefined, undefined);
- expect(spyAfter).toHaveBeenCalledWith(5, 1, 'spliceCol', undefined, undefined, undefined);
- });
- });
- /***/ }),
- /* 200 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.spliceRow', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should remove from the second row three columns starting from the beginning', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5)
- });
- var removedData = hot.spliceRow(1, 0, 3);
- expect(removedData).toEqual(['A2', 'B2', 'C2']);
- expect(hot.getDataAtRow(0)).toEqual(['A1', 'B1', 'C1', 'D1', 'E1']);
- expect(hot.getDataAtRow(1)).toEqual(['D2', 'E2', null, null, null]);
- expect(hot.getDataAtRow(2)).toEqual(['A3', 'B3', 'C3', 'D3', 'E3']);
- expect(hot.getDataAtRow(3)).toEqual(['A4', 'B4', 'C4', 'D4', 'E4']);
- expect(hot.getDataAtRow(4)).toEqual(['A5', 'B5', 'C5', 'D5', 'E5']);
- });
- it('should remove from the third row three columns starting from the second column', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5)
- });
- var removedData = hot.spliceRow(2, 1, 3);
- expect(removedData).toEqual(['B3', 'C3', 'D3']);
- expect(hot.getDataAtRow(0)).toEqual(['A1', 'B1', 'C1', 'D1', 'E1']);
- expect(hot.getDataAtRow(1)).toEqual(['A2', 'B2', 'C2', 'D2', 'E2']);
- expect(hot.getDataAtRow(2)).toEqual(['A3', 'E3', null, null, null]);
- expect(hot.getDataAtRow(3)).toEqual(['A4', 'B4', 'C4', 'D4', 'E4']);
- expect(hot.getDataAtRow(4)).toEqual(['A5', 'B5', 'C5', 'D5', 'E5']);
- });
- it('should replace and append new columns in the second row starting from the second column', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5)
- });
- var removedData = hot.spliceRow(1, 1, 3, 'X1', 'X2', 'X3', 'X4', 'X5');
- expect(removedData).toEqual(['B2', 'C2', 'D2']);
- expect(hot.getDataAtRow(0)).toEqual(['A1', 'B1', 'C1', 'D1', 'E1', null, null]);
- expect(hot.getDataAtRow(1)).toEqual(['A2', 'X1', 'X2', 'X3', 'X4', 'X5', 'E2']);
- expect(hot.getDataAtRow(2)).toEqual(['A3', 'B3', 'C3', 'D3', 'E3', null, null]);
- expect(hot.getDataAtRow(3)).toEqual(['A4', 'B4', 'C4', 'D4', 'E4', null, null]);
- expect(hot.getDataAtRow(4)).toEqual(['A5', 'B5', 'C5', 'D5', 'E5', null, null]);
- });
- it('should trigger beforeChange and afterChange hook with proper arguments', function () {
- var spyAfter = jasmine.createSpy('after');
- var spyBefore = jasmine.createSpy('before');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- beforeChange: spyBefore,
- afterChange: spyAfter
- });
- hot.spliceRow(2, 1, 3, 'X1');
- expect(spyBefore.calls.argsFor(0)[0]).toEqual([[2, 1, 'B3', 'X1'], [2, 2, 'C3', 'E3'], [2, 3, 'D3', null], [2, 4, 'E3', null], [2, 5, undefined, null]]);
- expect(spyBefore.calls.argsFor(0)[1]).toBe('spliceRow');
- expect(spyAfter.calls.argsFor(1)[0]).toEqual([[2, 1, 'B3', 'X1'], [2, 2, 'C3', 'E3'], [2, 3, 'D3', null], [2, 4, 'E3', null], [2, 5, undefined, null]]);
- expect(spyAfter.calls.argsFor(1)[1]).toBe('spliceRow');
- });
- it('should trigger beforeCreateCol and afterCreateCol hook with proper arguments', function () {
- var spyAfter = jasmine.createSpy('after');
- var spyBefore = jasmine.createSpy('before');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 5),
- beforeCreateCol: spyBefore,
- afterCreateCol: spyAfter
- });
- hot.spliceRow(2, 1, 3, 'X1', 'X2', 'X3', 'X4');
- expect(spyBefore).toHaveBeenCalledWith(5, 1, 'spliceRow', undefined, undefined, undefined);
- expect(spyAfter).toHaveBeenCalledWith(5, 1, 'spliceRow', undefined, undefined, undefined);
- });
- });
- /***/ }),
- /* 201 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.toPhysicalColumn', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should return valid physical row index', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- modifyCol: function modifyCol(column) {
- return column + 3;
- }
- });
- expect(hot.toPhysicalColumn(0)).toBe(3);
- expect(hot.toPhysicalColumn(1)).toBe(4);
- expect(hot.toPhysicalColumn(2)).toBe(5);
- });
- });
- /***/ }),
- /* 202 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.toPhysicalRow', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should return valid physical row index', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- modifyRow: function modifyRow(row) {
- return row + 3;
- }
- });
- expect(hot.toPhysicalRow(0)).toBe(3);
- expect(hot.toPhysicalRow(1)).toBe(4);
- expect(hot.toPhysicalRow(2)).toBe(5);
- });
- });
- /***/ }),
- /* 203 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.toVisualColumn', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should return valid visual row index', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- unmodifyCol: function unmodifyCol(column) {
- return column + 3;
- }
- });
- expect(hot.toVisualColumn(0)).toBe(3);
- expect(hot.toVisualColumn(1)).toBe(4);
- expect(hot.toVisualColumn(2)).toBe(5);
- });
- });
- /***/ }),
- /* 204 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Core.toVisualRow', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should return valid visual row index', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- unmodifyRow: function unmodifyRow(row) {
- return row + 3;
- }
- });
- expect(hot.toVisualRow(0)).toBe(3);
- expect(hot.toVisualRow(1)).toBe(4);
- expect(hot.toVisualRow(2)).toBe(5);
- });
- });
- /***/ }),
- /* 205 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- describe('AutocompleteEditor', function () {
- var id = 'testContainer';
- var choices = ['yellow', 'red', 'orange', 'green', 'blue', 'gray', 'black', 'white', 'purple', 'lime', 'olive', 'cyan'];
- var hot;
- beforeEach(function () {
- this.$container = $('<div id="' + id + '" style="width: 300px; height: 200px; overflow: auto"></div>').appendTo('body');
- });
- afterEach(function () {
- if (hot) {
- hot = null;
- }
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('open editor', function () {
- it('should display editor (after hitting ENTER)', function () {
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: choices
- }]
- });
- selectCell(0, 0);
- var editor = $('.autocompleteEditor');
- expect(editor.is(':visible')).toBe(false);
- keyDownUp('enter');
- expect(editor.is(':visible')).toBe(true);
- });
- it('should display editor (after hitting F2)', function () {
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: choices
- }]
- });
- selectCell(0, 0);
- var editor = $('.autocompleteEditor');
- expect(editor.is(':visible')).toBe(false);
- keyDownUp('f2');
- expect(editor.is(':visible')).toBe(true);
- });
- it('should display editor (after doubleclicking)', function () {
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: choices
- }]
- });
- selectCell(0, 0);
- var editor = $('.autocompleteEditor');
- expect(editor.is(':visible')).toBe(false);
- mouseDoubleClick($(getCell(0, 0)));
- expect(editor.is(':visible')).toBe(true);
- });
- // see https://github.com/handsontable/handsontable/issues/3380
- it('should not throw error while selecting the next cell by hitting enter key', function () {
- var spy = jasmine.createSpyObj('error', ['test']);
- var prevError = window.onerror;
- window.onerror = function (messageOrEvent, source, lineno, colno, error) {
- spy.test();
- };
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: choices
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- keyDownUp('enter');
- keyDownUp('enter');
- expect(spy.test.calls.count()).toBe(0);
- window.onerror = prevError;
- });
- });
- describe('choices', function () {
- it('should display given choices (array)', function (done) {
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: choices
- }]
- });
- selectCell(0, 0);
- var editor = $('.autocompleteEditor');
- keyDownUp('enter');
- setTimeout(function () {
- expect(editor.find('tbody td:eq(0)').text()).toEqual(choices[0]);
- expect(editor.find('tbody td:eq(1)').text()).toEqual(choices[1]);
- expect(editor.find('tbody td:eq(2)').text()).toEqual(choices[2]);
- expect(editor.find('tbody td:eq(3)').text()).toEqual(choices[3]);
- expect(editor.find('tbody td:eq(4)').text()).toEqual(choices[4]);
- done();
- }, 100);
- });
- it('should call source function with context set as cellProperties', function (done) {
- var source = jasmine.createSpy('source');
- var context;
- source.and.callFake(function (query, process) {
- process(choices);
- context = this;
- });
- var hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: source
- }]
- });
- selectCell(0, 0);
- source.calls.reset();
- keyDownUp('enter');
- setTimeout(function () {
- expect(context.instance).toBe(hot);
- expect(context.row).toBe(0);
- expect(context.col).toBe(0);
- done();
- }, 200);
- });
- it('should display given choices (sync function)', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- var editor = $('.autocompleteEditor');
- syncSources.calls.reset();
- keyDownUp('enter');
- setTimeout(function () {
- expect(editor.find('tbody td:eq(0)').text()).toEqual(choices[0]);
- expect(editor.find('tbody td:eq(1)').text()).toEqual(choices[1]);
- expect(editor.find('tbody td:eq(2)').text()).toEqual(choices[2]);
- expect(editor.find('tbody td:eq(3)').text()).toEqual(choices[3]);
- expect(editor.find('tbody td:eq(4)').text()).toEqual(choices[4]);
- done();
- }, 200);
- });
- it('should display given choices (async function)', function (done) {
- var asyncSources = jasmine.createSpy('asyncSources');
- asyncSources.and.callFake(function (process) {
- process(choices);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: function source(query, process) {
- setTimeout(function () {
- asyncSources(process);
- }, 0);
- }
- }]
- });
- selectCell(0, 0);
- var editor = $('.autocompleteEditor');
- keyDownUp('enter');
- setTimeout(function () {
- expect(asyncSources.calls.count()).toEqual(1);
- expect(editor.find('tbody td:eq(0)').text()).toEqual(choices[0]);
- expect(editor.find('tbody td:eq(1)').text()).toEqual(choices[1]);
- expect(editor.find('tbody td:eq(2)').text()).toEqual(choices[2]);
- expect(editor.find('tbody td:eq(3)').text()).toEqual(choices[3]);
- expect(editor.find('tbody td:eq(4)').text()).toEqual(choices[4]);
- done();
- }, 200);
- });
- it('should NOT update choices list, after cursor leaves and enters the list (#1330)', function (done) {
- spyOn(Handsontable.editors.AutocompleteEditor.prototype, 'updateChoicesList').and.callThrough();
- var updateChoicesList = Handsontable.editors.AutocompleteEditor.prototype.updateChoicesList;
- var hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: choices
- }]
- });
- selectCell(0, 0);
- var editor = hot.getActiveEditor();
- keyDownUp('enter');
- setTimeout(function () {
- updateChoicesList.calls.reset();
- $(editor.htContainer).find('.htCore tr:eq(0) td:eq(0)').mouseenter();
- $(editor.htContainer).find('.htCore tr:eq(0) td:eq(0)').mouseleave();
- $(editor.htContainer).find('.htCore tr:eq(0) td:eq(0)').mouseenter();
- }, 200);
- setTimeout(function () {
- expect(updateChoicesList).not.toHaveBeenCalled();
- done();
- }, 300);
- });
- it('should update choices list exactly once after a key is pressed (#1330)', function (done) {
- spyOn(Handsontable.editors.AutocompleteEditor.prototype, 'updateChoicesList').and.callThrough();
- var updateChoicesList = Handsontable.editors.AutocompleteEditor.prototype.updateChoicesList;
- var hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: choices
- }]
- });
- selectCell(0, 0);
- var editor = hot.getActiveEditor();
- updateChoicesList.calls.reset();
- keyDownUp('enter');
- setTimeout(function () {
- updateChoicesList.calls.reset();
- editor.TEXTAREA.value = 'red';
- $(editor.TEXTAREA).simulate('keydown', {
- keyCode: 'd'.charCodeAt(0)
- });
- }, 200);
- setTimeout(function () {
- expect(updateChoicesList.calls.count()).toEqual(1);
- done();
- }, 100);
- });
- it('should not initialize the dropdown with unneeded scrollbars (scrollbar causing a scrollbar issue)', function (done) {
- spyOn(Handsontable.editors.AutocompleteEditor.prototype, 'updateChoicesList').and.callThrough();
- var updateChoicesList = Handsontable.editors.AutocompleteEditor.prototype.updateChoicesList;
- var hot = handsontable({
- data: [['blue'], [], [], []],
- columns: [{
- editor: 'autocomplete',
- source: choices
- }]
- });
- selectCell(0, 0);
- var editor = hot.getActiveEditor();
- updateChoicesList.calls.reset();
- keyDownUp('enter');
- setTimeout(function () {
- expect(editor.htContainer.scrollWidth).toEqual(editor.htContainer.clientWidth);
- done();
- }, 200);
- });
- it('autocomplete list should have textarea dimensions', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices);
- });
- handsontable({
- colWidths: [200],
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- var editor = $('.handsontableInputHolder');
- syncSources.calls.reset();
- keyDownUp('enter');
- setTimeout(function () {
- // -2 for transparent borders
- expect(editor.find('.autocompleteEditor .htCore td').width()).toEqual(editor.find('.handsontableInput').width() - 2);
- expect(editor.find('.autocompleteEditor .htCore td').width()).toBeGreaterThan(187);
- done();
- }, 200);
- });
- it('autocomplete list should have the suggestion table dimensions, when trimDropdown option is set to false', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(['long text', 'even longer text', 'extremely long text in the suggestion list', 'short text', 'text', 'another', 'yellow', 'black']);
- });
- var hot = handsontable({
- colWidths: [200],
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }],
- trimDropdown: false
- });
- selectCell(0, 0);
- var editor = $('.handsontableInputHolder');
- syncSources.calls.reset();
- keyDownUp('enter');
- setTimeout(function () {
- expect(editor.find('.autocompleteEditor .htCore td').eq(0).width()).toBeGreaterThan(editor.find('.handsontableInput').width());
- done();
- }, 200);
- });
- it('autocomplete textarea should have cell dimensions (after render)', function (done) {
- var data = [['a', 'b'], ['c', 'd']];
- hot = handsontable({
- data: data,
- minRows: 4,
- minCols: 4,
- minSpareRows: 4,
- minSpareCols: 4,
- cells: function cells() {
- return {
- type: Handsontable.AutocompleteCell
- };
- }
- });
- selectCell(1, 1);
- keyDownUp('enter');
- data[1][1] = 'dddddddddddddddddddd';
- render();
- setTimeout(function () {
- var $td = spec().$container.find('.htCore tbody tr:eq(1) td:eq(1)');
- expect(autocompleteEditor().width()).toEqual($td.width());
- done();
- }, 10);
- });
- it('should invoke beginEditing only once after dobleclicking on a cell (#1011)', function () {
- var hot = handsontable({
- columns: [{}, {}, {
- type: 'autocomplete',
- source: choices
- }]
- });
- selectCell(0, 2);
- spyOn(hot.getActiveEditor(), 'beginEditing');
- expect(hot.getActiveEditor().beginEditing.calls.count()).toBe(0);
- mouseDoubleClick(getCell(0, 2));
- expect(hot.getActiveEditor().beginEditing.calls.count()).toBe(1);
- mouseDoubleClick(getCell(1, 2));
- expect(hot.getActiveEditor().beginEditing.calls.count()).toBe(2);
- mouseDoubleClick(getCell(2, 2));
- expect(hot.getActiveEditor().beginEditing.calls.count()).toBe(3);
- });
- it('should not display all the choices from a long source list and not leave any unused space in the dropdown (YouTrack: #HOT-32)', function (done) {
- var hot = handsontable({
- columns: [{
- type: 'autocomplete',
- source: ['Acura', 'Audi', 'BMW', 'Buick', 'Cadillac', 'Chevrolet', 'Chrysler', 'Citroen', 'Dodge', 'Eagle', 'Ferrari', 'Ford', 'General Motors', 'GMC', 'Honda', 'Hummer', 'Hyundai', 'Infiniti', 'Isuzu', 'Jaguar', 'Jeep', 'Kia', 'Lamborghini', 'Land Rover', 'Lexus', 'Lincoln', 'Lotus', 'Mazda', 'Mercedes-Benz', 'Mercury', 'Mitsubishi', 'Nissan', 'Oldsmobile', 'Peugeot', 'Pontiac', 'Porsche', 'Regal', 'Renault', 'Saab', 'Saturn', 'Seat', 'Skoda', 'Subaru', 'Suzuki', 'Toyota', 'Volkswagen', 'Volvo']
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- var $autocomplete = autocomplete();
- var $autocompleteHolder = $autocomplete.find('.ht_master .wtHolder').first();
- setTimeout(function () {
- expect($autocomplete.find('td').first().text()).toEqual('Acura');
- $autocompleteHolder.scrollTop($autocompleteHolder[0].scrollHeight);
- }, 100);
- setTimeout(function () {
- expect($autocomplete.find('td').last().text()).toEqual('Volvo');
- done();
- }, 200);
- });
- it('should display the choices, regardless if they\'re declared as string or numeric', function (done) {
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: ['1', '2', 3, '4', 5, 6]
- }]
- });
- selectCell(0, 0);
- var editor = $('.autocompleteEditor');
- keyDownUp('enter');
- setTimeout(function () {
- expect(editor.find('tbody td:eq(0)').text()).toEqual('1');
- expect(editor.find('tbody td:eq(1)').text()).toEqual('2');
- expect(editor.find('tbody td:eq(2)').text()).toEqual('3');
- expect(editor.find('tbody td:eq(3)').text()).toEqual('4');
- expect(editor.find('tbody td:eq(4)').text()).toEqual('5');
- expect(editor.find('tbody td:eq(5)').text()).toEqual('6');
- done();
- }, 100);
- });
- it('should display the choices, regardless if they\'re declared as string or numeric, when data is present', function (done) {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 1),
- columns: [{
- editor: 'autocomplete',
- source: ['1', '2', 3, '4', 5, 6]
- }]
- });
- selectCell(0, 0);
- keyDownUp('backspace');
- var editor = $('.autocompleteEditor');
- keyDownUp('enter');
- setTimeout(function () {
- expect(editor.find('tbody td:eq(0)').text()).toEqual('1');
- expect(editor.find('tbody td:eq(1)').text()).toEqual('2');
- expect(editor.find('tbody td:eq(2)').text()).toEqual('3');
- expect(editor.find('tbody td:eq(3)').text()).toEqual('4');
- expect(editor.find('tbody td:eq(4)').text()).toEqual('5');
- expect(editor.find('tbody td:eq(5)').text()).toEqual('6');
- done();
- }, 100);
- });
- it('should display the dropdown above the editor, when there is not enough space below the cell AND there is more space above the cell', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(30, 30),
- columns: [{
- editor: 'autocomplete',
- source: choices
- }, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}],
- width: 400,
- height: 400
- });
- setDataAtCell(29, 0, '');
- selectCell(29, 0);
- mouseDoubleClick($(getCell(29, 0)));
- setTimeout(function () {
- var autocompleteEditor = $('.autocompleteEditor');
- expect(autocompleteEditor.css('position')).toEqual('absolute');
- expect(autocompleteEditor.css('top')).toEqual(-1 * autocompleteEditor.height() + 'px');
- done();
- }, 200);
- });
- it('should flip the dropdown upwards when there is no more room left below the cell after filtering the choice list', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(30, 30),
- columns: [{
- editor: 'autocomplete',
- source: choices
- }, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}],
- width: 400,
- height: 400
- });
- setDataAtCell(26, 0, 'b');
- selectCell(26, 0);
- hot.view.wt.wtTable.holder.scrollTop = 999;
- mouseDoubleClick($(getCell(26, 0)));
- var autocompleteEditor = $('.autocompleteEditor');
- setTimeout(function () {
- expect(autocompleteEditor.css('position')).toEqual('relative');
- autocompleteEditor.siblings('textarea').first().val('');
- keyDownUp('backspace');
- }, 20);
- setTimeout(function () {
- expect(autocompleteEditor.css('position')).toEqual('absolute');
- expect(autocompleteEditor.css('top')).toEqual(-1 * autocompleteEditor.height() + 'px');
- done();
- }, 100);
- });
- });
- describe('closing editor', function () {
- it('should destroy editor when value change with mouse click on suggestion', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- setTimeout(function () {
- autocomplete().find('tbody td:eq(3)').simulate('mousedown');
- expect(getDataAtCell(0, 0)).toEqual('green');
- done();
- }, 200);
- });
- it('should not change value type from `numeric` to `string` after mouse click suggestion - ' + 'test no. 1 #4143', function (done) {
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: [1, 2, 3, 4, 5, 11, 14]
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- setTimeout(function () {
- autocomplete().find('tbody td:eq(0)').simulate('mousedown');
- expect(_typeof(getDataAtCell(0, 0))).toEqual('number');
- done();
- }, 200);
- });
- it('should not change value type from `numeric` to `string` after mouse click on suggestion - ' + 'test no. 2 #4143', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- var source = [1, 2, 3, 4, 5, 11, 14];
- syncSources.and.callFake(function (query, process) {
- process(source);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- setTimeout(function () {
- autocomplete().find('tbody td:eq(0)').simulate('mousedown');
- expect(_typeof(getDataAtCell(0, 0))).toEqual('number');
- done();
- }, 200);
- });
- it('should call `afterChange` hook with proper value types - test no. 1 #4143', function (done) {
- var changesInside = void 0;
- var sourceInside = void 0;
- var afterChange = function afterChange(changes, source) {
- if (source !== 'loadData') {
- changesInside = changes;
- sourceInside = source;
- }
- };
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: [1, 2, 3, 4, 5, 11, 14]
- }],
- afterChange: afterChange
- });
- selectCell(0, 0);
- keyDownUp('enter');
- setTimeout(function () {
- autocomplete().find('tbody td:eq(1)').simulate('mousedown');
- expect(changesInside[0]).toEqual([0, 0, null, 2]);
- done();
- }, 200);
- });
- it('should call `afterChange` hook with proper value types - test no. 2 #4143', function (done) {
- var changesInside = void 0;
- var sourceInside = void 0;
- var afterChange = function afterChange(changes, source) {
- if (source !== 'loadData') {
- changesInside = changes;
- sourceInside = source;
- }
- };
- var syncSources = jasmine.createSpy('syncSources');
- var source = [1, 2, 3, 4, 5, 11, 14];
- syncSources.and.callFake(function (query, process) {
- process(source);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }],
- afterChange: afterChange
- });
- selectCell(0, 0);
- keyDownUp('enter');
- setTimeout(function () {
- autocomplete().find('tbody td:eq(1)').simulate('mousedown');
- expect(changesInside[0]).toEqual([0, 0, null, 2]);
- done();
- }, 200);
- });
- it('should not change value type from `numeric` to `string` when written down value from set of suggestions #4143', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- var source = [1, 2, 3, 4, 5, 11, 14];
- syncSources.and.callFake(function (query, process) {
- process(source);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- keyDownUp('backspace');
- document.activeElement.value = '1';
- $(document.activeElement).simulate('keyup');
- setTimeout(function () {
- keyDownUp('enter');
- expect(getDataAtCell(0, 0)).toEqual(1);
- done();
- }, 200);
- });
- it('should destroy editor when value change with Enter on suggestion', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- setTimeout(function () {
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('enter');
- expect(getDataAtCell(0, 0)).toEqual('green');
- done();
- }, 200);
- });
- it('should destroy editor when pressed Enter then Esc', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- setTimeout(function () {
- expect(autocompleteEditor().is(':visible')).toBe(true);
- keyDownUp('esc');
- expect(autocompleteEditor().is(':visible')).toBe(false);
- done();
- }, 200);
- });
- it('should destroy editor when mouse double clicked then Esc', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- mouseDoubleClick(getCell(0, 0));
- setTimeout(function () {
- expect(autocompleteEditor().is(':visible')).toBe(true);
- keyDownUp('esc');
- expect(autocompleteEditor().is(':visible')).toBe(false);
- done();
- }, 200);
- });
- it('cancel editing (Esc) should restore the previous value', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- setDataAtCell(0, 0, 'black');
- selectCell(0, 0);
- keyDownUp('enter');
- setTimeout(function () {
- autocomplete().siblings('.handsontableInput').val('ye');
- keyDownUp(69); // e
- keyDownUp('esc');
- expect(getDataAtCell(0, 0)).toEqual('black');
- done();
- }, 200);
- });
- it('should destroy editor when clicked outside the table', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- mouseDoubleClick(getCell(0, 0));
- setTimeout(function () {
- expect(autocompleteEditor().is(':visible')).toBe(true);
- $('body').simulate('mousedown');
- expect(autocompleteEditor().is(':visible')).toBe(false);
- done();
- }, 200);
- });
- it('should show fillHandle element again after close editor', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.plan = function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- };
- var hot = handsontable({
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- strict: false
- }, {}]
- });
- selectCell(1, 0);
- keyDownUp('x'); // Trigger quick edit mode
- keyDownUp('enter');
- setTimeout(function () {
- expect($('#testContainer.handsontable > .handsontable .wtBorder.current.corner:visible').length).toEqual(1);
- done();
- }, 200);
- });
- });
- describe('non strict mode', function () {
- it('should allow any value in non strict mode (close editor with ENTER)', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- setTimeout(function () {
- var editor = $('.handsontableInput');
- editor.val('foo');
- keyDownUp('enter');
- expect(getDataAtCell(0, 0)).toEqual('foo');
- done();
- }, 200);
- });
- it('should allow any value in non strict mode (close editor by clicking on table)', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- setTimeout(function () {
- var editor = $('.handsontableInput');
- editor.val('foo');
- spec().$container.find('tbody tr:eq(1) td:eq(0)').simulate('mousedown');
- expect(getDataAtCell(0, 0)).toEqual('foo');
- done();
- }, 200);
- });
- it('should save the value from textarea after hitting ENTER', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- syncSources.calls.reset();
- editorInput.val('b');
- keyDownUp('b'.charCodeAt(0));
- }, 200);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['blue'], ['black']]);
- var selected = innerHot.getSelected();
- expect(selected).toBeUndefined();
- keyDownUp('enter');
- expect(getDataAtCell(0, 0)).toEqual('b');
- done();
- }, 400);
- });
- });
- describe('strict mode', function () {
- it('strict mode should NOT use value if it DOES NOT match the list (sync reponse is empty)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var onAfterChange = jasmine.createSpy('onAfterChange');
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process([]); // hardcoded empty result
- });
- handsontable({
- data: [['one', 'two'], ['three', 'four']],
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- allowInvalid: false,
- strict: true
- }, {}],
- afterValidate: onAfterValidate,
- afterChange: onAfterChange
- });
- setDataAtCell(0, 0, 'unexistent');
- setTimeout(function () {
- expect(getData()).toEqual([['one', 'two'], ['three', 'four']]);
- expect(syncSources.calls.count()).toEqual(1);
- expect(onAfterValidate.calls.count()).toEqual(1);
- expect(onAfterChange.calls.count()).toEqual(1); // 1 for loadData (it is not called after failed edit)
- done();
- }, 200);
- });
- it('strict mode should use value if it DOES match the list (sync reponse is not empty)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var onAfterChange = jasmine.createSpy('onAfterChange');
- var syncSources = jasmine.createSpy('asyncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices); // hardcoded empty result
- });
- handsontable({
- data: [['one', 'two'], ['three', 'four']],
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- allowInvalid: false,
- strict: true
- }, {}],
- afterValidate: onAfterValidate,
- afterChange: onAfterChange
- });
- setDataAtCell(0, 0, 'yellow');
- setTimeout(function () {
- expect(getData()).toEqual([['yellow', 'two'], ['three', 'four']]);
- expect(syncSources.calls.count()).toEqual(1);
- expect(onAfterValidate.calls.count()).toEqual(1);
- expect(onAfterChange.calls.count()).toEqual(2); // 1 for loadData and 1 for setDataAtCell
- done();
- }, 200);
- });
- it('strict mode should NOT use value if it DOES NOT match the list (async reponse is empty)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var onAfterChange = jasmine.createSpy('onAfterChange');
- var asyncSources = jasmine.createSpy('asyncSources');
- asyncSources.and.callFake(function (query, process) {
- setTimeout(function () {
- process([]); // hardcoded empty result
- });
- });
- handsontable({
- data: [['one', 'two'], ['three', 'four']],
- columns: [{
- type: 'autocomplete',
- source: asyncSources,
- allowInvalid: false,
- strict: true
- }, {}],
- afterValidate: onAfterValidate,
- afterChange: onAfterChange
- });
- setDataAtCell(0, 0, 'unexistent');
- setTimeout(function () {
- expect(getData()).toEqual([['one', 'two'], ['three', 'four']]);
- expect(asyncSources.calls.count()).toEqual(1);
- expect(onAfterValidate.calls.count()).toEqual(1);
- expect(onAfterChange.calls.count()).toEqual(1); // 1 for loadData (it is not called after failed edit)
- done();
- }, 200);
- });
- it('strict mode should use value if it DOES match the list (async reponse is not empty)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var onAfterChange = jasmine.createSpy('onAfterChange');
- var asyncSources = jasmine.createSpy('asyncSources');
- asyncSources.and.callFake(function (query, process) {
- setTimeout(function () {
- process(choices); // hardcoded empty result
- });
- });
- handsontable({
- data: [['one', 'two'], ['three', 'four']],
- columns: [{
- type: 'autocomplete',
- source: asyncSources,
- allowInvalid: false,
- strict: true
- }, {}],
- afterValidate: onAfterValidate,
- afterChange: onAfterChange
- });
- setDataAtCell(0, 0, 'yellow');
- setTimeout(function () {
- expect(getData()).toEqual([['yellow', 'two'], ['three', 'four']]);
- expect(asyncSources.calls.count()).toEqual(1);
- expect(onAfterValidate.calls.count()).toEqual(1);
- expect(onAfterChange.calls.count()).toEqual(2); // 1 for loadData and 1 for setDataAtCell
- done();
- }, 200);
- });
- it('strict mode mark value as invalid if it DOES NOT match the list (sync reponse is empty)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var onAfterChange = jasmine.createSpy('onAfterChange');
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process([]); // hardcoded empty result
- });
- handsontable({
- data: [['one', 'two'], ['three', 'four']],
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- allowInvalid: true,
- strict: true
- }, {}],
- afterValidate: onAfterValidate,
- afterChange: onAfterChange
- });
- expect(getCellMeta(0, 0).valid).not.toBe(false);
- expect($(getCell(0, 0)).hasClass('htInvalid')).toBe(false);
- setDataAtCell(0, 0, 'unexistent');
- setTimeout(function () {
- expect(getData()).toEqual([['unexistent', 'two'], ['three', 'four']]);
- expect(getCellMeta(0, 0).valid).toBe(false);
- expect($(getCell(0, 0)).hasClass('htInvalid')).toBe(true);
- done();
- }, 200);
- });
- it('should select the best matching option after hitting ENTER', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources,
- strict: true
- }],
- afterValidate: onAfterValidate
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- syncSources.calls.reset();
- editorInput.val('b');
- keyDownUp('b'.charCodeAt(0));
- }, 200);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['blue'], ['black']]);
- var selected = innerHot.getSelected();
- var selectedData = innerHot.getDataAtCell(selected[0], selected[1]);
- expect(selectedData).toEqual('blue');
- onAfterValidate.calls.reset();
- keyDownUp('enter');
- }, 400);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toEqual('blue');
- done();
- }, 600);
- });
- it('should select the best matching option after hitting TAB', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources,
- strict: true
- }],
- afterValidate: onAfterValidate
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- syncSources.calls.reset();
- editorInput.val('b');
- keyDownUp('b'.charCodeAt(0));
- }, 200);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['blue'], ['black']]);
- var selected = innerHot.getSelected();
- var selectedData = innerHot.getDataAtCell(selected[0], selected[1]);
- expect(selectedData).toEqual('blue');
- onAfterValidate.calls.reset();
- keyDownUp('tab');
- }, 400);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toEqual('blue');
- done();
- }, 600);
- });
- it('should mark list item corresponding to current cell value as selected', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(['red', 'dark-yellow', 'yellow', 'light-yellow', 'black']);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources,
- strict: true
- }],
- data: [['yellow'], ['red'], ['blue']]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- setTimeout(function () {
- expect(autocomplete().find('.current').text()).toEqual(getDataAtCell(0, 0));
- done();
- }, 200);
- });
- });
- describe('filtering', function () {
- it('typing in textarea should filter the lookup list', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- syncSources.calls.reset();
- editorInput.val('e');
- keyDownUp(69); // e
- }, 200);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['red'], ['yellow'], ['green'], ['blue'], ['lime'], ['white'], ['olive'], ['orange'], ['purple']]);
- syncSources.calls.reset();
- editorInput.val('ed');
- keyDownUp(68); // d
- }, 400);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['red']]);
- done();
- }, 600);
- });
- it('default filtering should be case insensitive', function (done) {
- hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: choices
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- editorInput.val('e');
- keyDownUp(69); // e
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['red'], ['yellow'], ['green'], ['blue'], ['lime'], ['white'], ['olive'], ['orange'], ['purple']]);
- editorInput.val('e');
- keyDownUp(69); // E (same as 'e')
- }, 50);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['red'], ['yellow'], ['green'], ['blue'], ['lime'], ['white'], ['olive'], ['orange'], ['purple']]);
- done();
- }, 100);
- });
- it('default filtering should be case sensitive when filteringCaseSensitive is false', function (done) {
- hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: choices,
- filteringCaseSensitive: true
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- editorInput.val('e');
- keyDownUp(69); // e
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['red'], ['yellow'], ['green'], ['blue'], ['lime'], ['white'], ['olive'], ['orange'], ['purple']]);
- editorInput.val('E');
- keyDownUp(69); // E (same as 'e')
- }, 50);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([]);
- expect(innerHot.getSourceData()).toEqual([]);
- done();
- }, 200);
- });
- it('typing in textarea should NOT filter the lookup list when filtering is disabled', function (done) {
- hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: choices,
- filter: false
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- editorInput.val('e');
- keyDownUp('e'.charCodeAt(0)); // e
- }, 20);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual(Handsontable.helper.pivot([choices]));
- editorInput.val('ed');
- keyDownUp('d'.charCodeAt(0)); // d
- }, 40);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual(Handsontable.helper.pivot([choices]));
- done();
- }, 60);
- });
- it('typing in textarea should highlight the matching phrase', function (done) {
- var choices = ['Male', 'Female'];
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.search(new RegExp(query, 'i')) != -1;
- }));
- });
- hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources,
- filter: false
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- syncSources.calls.reset();
- editorInput.val('Male');
- keyDownUp(69); // e
- }, 200);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- var autocompleteList = $(innerHot.rootElement);
- expect(autocompleteList.find('td:eq(0)').html()).toMatch(/<(strong|STRONG)>Male<\/(strong|STRONG)>/); // IE8 makes the tag names UPPERCASE
- expect(autocompleteList.find('td:eq(1)').html()).toMatch(/Fe<(strong|STRONG)>male<\/(strong|STRONG)>/);
- done();
- }, 400);
- });
- it('text in textarea should not be interpreted as regexp', function (done) {
- spyOn(Handsontable.editors.AutocompleteEditor.prototype, 'queryChoices').and.callThrough();
- var queryChoices = Handsontable.editors.AutocompleteEditor.prototype.queryChoices;
- hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: choices
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- queryChoices.calls.reset();
- editorInput.val('yellow|red');
- keyDownUp('d'.charCodeAt(0));
- }, 200);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData().length).toEqual(0);
- done();
- }, 400);
- });
- it('text in textarea should not be interpreted as regexp when highlighting the matching phrase', function (done) {
- var choices = ['Male', 'Female'];
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.search(new RegExp(query, 'i')) != -1;
- }));
- });
- hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources,
- filter: false
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- syncSources.calls.reset();
- editorInput.val('M|F');
- keyDownUp('F'.charCodeAt(0));
- }, 200);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- var autocompleteList = $(innerHot.rootElement);
- expect(autocompleteList.find('td:eq(0)').html()).toEqual('Male');
- expect(autocompleteList.find('td:eq(1)').html()).toEqual('Female');
- done();
- }, 400);
- });
- it('should allow any value if filter === false and allowInvalid === true', function (done) {
- spyOn(Handsontable.editors.AutocompleteEditor.prototype, 'queryChoices').and.callThrough();
- var queryChoices = Handsontable.editors.AutocompleteEditor.prototype.queryChoices;
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: choices,
- filter: false,
- strict: true,
- allowInvalid: true
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- queryChoices.calls.reset();
- editorInput.val('foobar');
- keyDownUp(82); // r
- }, 200);
- setTimeout(function () {
- keyDownUp(Handsontable.helper.KEY_CODES.ENTER);
- expect(getDataAtCell(0, 0)).toEqual('foobar');
- done();
- }, 400);
- });
- it('typing in textarea should highlight best choice, if strict === true', function (done) {
- var choices = ['Male', 'Female'];
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.search(new RegExp(query, 'i')) != -1;
- }));
- });
- var hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources,
- filter: false,
- strict: true
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- syncSources.calls.reset();
- editorInput.val('e');
- keyDownUp(69); // e
- }, 200);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getSelected()).toEqual([1, 0, 1, 0]);
- done();
- }, 400);
- });
- });
- it('should restore the old value when hovered over a autocomplete menu item and then clicked outside of the table', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }]
- });
- selectCell(0, 0);
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- autocomplete().find('tbody td:eq(1)').simulate('mouseenter');
- autocomplete().find('tbody td:eq(1)').simulate('mouseleave');
- spec().$container.simulate('mousedown');
- expect(getDataAtCell(0, 0)).toBeNull();
- done();
- }, 200);
- });
- it('should be able to use empty value ("")', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(['', 'BMW', 'Bentley']);
- });
- handsontable({
- data: [['one', 'two'], ['three', 'four']],
- columns: [{
- editor: 'autocomplete',
- source: syncSources,
- filter: false
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toEqual('one');
- autocomplete().find('tbody td:eq(0)').simulate('mousedown');
- expect(getDataAtCell(0, 0)).toEqual('');
- done();
- }, 200);
- });
- describe('allow html mode', function () {
- it('should allow inject html items (async mode)', function (done) {
- hot = handsontable({
- columns: [{
- type: 'autocomplete',
- source: function source(query, cb) {
- cb(['<b>foo <span>zip</span></b>', '<i>bar</i>', '<strong>baz</strong>']);
- },
- allowHtml: true
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- editorInput.val('b');
- keyDownUp('b'.charCodeAt(0));
- }, 200);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['<i>bar</i>'], ['<strong>baz</strong>']]);
- editorInput.val('bar');
- keyDownUp('a'.charCodeAt(0));
- keyDownUp('r'.charCodeAt(0));
- }, 400);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['<i>bar</i>']]);
- keyDownUp('arrow_down');
- keyDownUp('enter');
- }, 600);
- setTimeout(function () {
- expect(getCell(0, 0).querySelector('i').textContent).toBe('bar');
- done();
- }, 700);
- });
- it('should allow inject html items (sync mode)', function (done) {
- hot = handsontable({
- columns: [{
- type: 'autocomplete',
- source: ['<b>foo <span>zip</span></b>', '<i>bar</i>', '<strong>baz</strong>'],
- allowHtml: true
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- editorInput.val('b');
- keyDownUp('b'.charCodeAt(0));
- }, 200);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['<i>bar</i>'], ['<strong>baz</strong>']]);
- editorInput.val('bar');
- keyDownUp('a'.charCodeAt(0));
- keyDownUp('r'.charCodeAt(0));
- }, 400);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['<i>bar</i>']]);
- keyDownUp('arrow_down');
- keyDownUp('enter');
- }, 600);
- setTimeout(function () {
- expect(getCell(0, 0).querySelector('i').textContent).toBe('bar');
- done();
- }, 700);
- });
- });
- describe('disallow html mode', function () {
- it('should be disabled by default', function () {
- hot = handsontable({
- columns: [{
- type: 'autocomplete',
- source: function source(query, cb) {
- cb(['<b>foo <span>zip</span></b>', '<i>bar</i>', '<strong>baz</strong>']);
- },
- allowHtml: false
- }]
- });
- expect(hot.getCellMeta(0, 0).allowHtml).toBeFalsy();
- });
- it('should strip html from strings provided in source (async mode)', function (done) {
- hot = handsontable({
- columns: [{
- type: 'autocomplete',
- source: function source(query, cb) {
- cb(['<b>foo <span>zip</span></b>', '<i>bar</i>', '<strong>baz</strong>']);
- },
- allowHtml: false
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- editorInput.val('b');
- keyDownUp('b'.charCodeAt(0));
- }, 200);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['bar'], ['baz']]);
- editorInput.val('bar');
- keyDownUp('a'.charCodeAt(0));
- keyDownUp('r'.charCodeAt(0));
- }, 400);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['bar']]);
- keyDownUp('arrow_down');
- keyDownUp('enter');
- }, 600);
- setTimeout(function () {
- expect(getCell(0, 0).querySelector('i')).toBeNull();
- expect(getCell(0, 0).textContent).toMatch('bar');
- done();
- }, 700);
- });
- it('should strip html from strings provided in source (sync mode)', function (done) {
- hot = handsontable({
- columns: [{
- type: 'autocomplete',
- source: ['<b>foo <span>zip</span></b>', '<i>bar</i>', '<strong>baz</strong>'],
- allowHtml: false
- }]
- });
- selectCell(0, 0);
- var editorInput = $('.handsontableInput');
- expect(getDataAtCell(0, 0)).toBeNull();
- keyDownUp('enter');
- setTimeout(function () {
- editorInput.val('b');
- keyDownUp('b'.charCodeAt(0));
- }, 200);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['bar'], ['baz']]);
- editorInput.val('bar');
- keyDownUp('a'.charCodeAt(0));
- keyDownUp('r'.charCodeAt(0));
- }, 400);
- setTimeout(function () {
- var ac = hot.getActiveEditor();
- var innerHot = ac.htEditor;
- expect(innerHot.getData()).toEqual([['bar']]);
- keyDownUp('arrow_down');
- keyDownUp('enter');
- }, 600);
- setTimeout(function () {
- expect(getCell(0, 0).querySelector('i')).toBeNull();
- expect(getCell(0, 0).textContent).toMatch('bar');
- done();
- }, 700);
- });
- });
- describe('Autocomplete helper functions:', function () {
- describe('sortByRelevance', function () {
- it('should sort the provided array, so items more relevant to the provided value are listed first', function () {
- var choices = ['Wayne', // 0
- 'Draven', // 1
- 'Banner', // 2
- 'Stark', // 3
- 'Parker', // 4
- 'Kent', // 5
- 'Gordon', // 6
- 'Kyle', // 7
- 'Simmons' // 8
- ];
- var value = 'a';
- var sorted = Handsontable.editors.AutocompleteEditor.sortByRelevance(value, choices);
- expect(sorted).toEqual([0, 2, 4, 3, 1]);
- value = 'o';
- sorted = Handsontable.editors.AutocompleteEditor.sortByRelevance(value, choices);
- expect(sorted).toEqual([6, 8]);
- value = 'er';
- sorted = Handsontable.editors.AutocompleteEditor.sortByRelevance(value, choices);
- expect(sorted).toEqual([2, 4]);
- });
- });
- });
- it('should not modify the suggestion lists\' order, when the sortByRelevance option is set to false', function (done) {
- var choices = ['Wayne', 'Draven', 'Banner', 'Stark', 'Parker', 'Kent', 'Gordon', 'Kyle', 'Simmons'];
- var hot = handsontable({
- columns: [{
- editor: 'autocomplete',
- source: choices,
- sortByRelevance: false
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- var $editorInput = $('.handsontableInput');
- $editorInput.val('a');
- keyDownUp('a'.charCodeAt(0));
- Handsontable.dom.setCaretPosition($editorInput[0], 1);
- setTimeout(function () {
- var dropdownList = $('.autocompleteEditor tbody').first();
- var listLength = dropdownList.find('tr').size();
- expect(listLength).toBe(9);
- for (var i = 1; i <= listLength; i++) {
- expect(dropdownList.find('tr:nth-child(' + i + ') td').text()).toEqual(choices[i - 1]);
- }
- done();
- }, 30);
- });
- it('should fire one afterChange event when value is changed', function (done) {
- var onAfterChange = jasmine.createSpy('onAfterChange');
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices);
- });
- handsontable({
- columns: [{
- editor: 'autocomplete',
- source: syncSources
- }],
- afterChange: onAfterChange
- });
- selectCell(0, 0);
- keyDownUp('enter');
- setTimeout(function () {
- onAfterChange.calls.reset();
- autocomplete().find('tbody td:eq(1)').simulate('mousedown');
- expect(getDataAtCell(0, 0)).toEqual('red');
- expect(onAfterChange.calls.count()).toEqual(1);
- expect(onAfterChange).toHaveBeenCalledWith([[0, 0, null, 'red']], 'edit', undefined, undefined, undefined, undefined);
- done();
- }, 200);
- });
- it('should not affect other cell values after clicking on autocomplete cell (#1021)', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices);
- });
- handsontable({
- columns: [{}, {}, {
- editor: 'autocomplete',
- source: syncSources
- }, {}],
- data: [[null, null, 'yellow', null], [null, null, 'red', null], [null, null, 'blue', null]]
- });
- expect($(getCell(0, 2)).text()).toMatch('yellow');
- mouseDoubleClick(getCell(0, 2));
- expect($(getCell(1, 2)).text()).toMatch('red');
- mouseDoubleClick(getCell(1, 2));
- expect($(getCell(2, 2)).text()).toMatch('blue');
- mouseDoubleClick(getCell(2, 2));
- setTimeout(function () {
- expect(getDataAtCol(2)).toEqual(['yellow', 'red', 'blue']);
- done();
- }, 200);
- });
- it('should handle editor if cell data is a function', function (done) {
- spyOn(Handsontable.editors.AutocompleteEditor.prototype, 'updateChoicesList').and.callThrough();
- var updateChoicesList = Handsontable.editors.AutocompleteEditor.prototype.updateChoicesList;
- var afterValidateCallback = jasmine.createSpy('afterValidateCallbak');
- var hot = handsontable({
- data: [new Model({
- id: 1,
- name: 'Ted Right',
- address: ''
- }), new Model({
- id: 2,
- name: 'Frank Honest',
- address: ''
- }), new Model({
- id: 3,
- name: 'Joan Well',
- address: ''
- })],
- dataSchema: Model,
- colHeaders: ['ID', 'Name', 'Address'],
- columns: [{
- data: createAccessorForProperty('id'),
- type: 'autocomplete',
- source: ['1', '2', '3'],
- filter: false,
- strict: true
- }, {
- data: createAccessorForProperty('name')
- }, {
- data: createAccessorForProperty('address')
- }],
- minSpareRows: 1,
- afterValidate: afterValidateCallback
- });
- selectCell(0, 0);
- expect(hot.getActiveEditor().isOpened()).toBe(false);
- keyDownUp('enter');
- setTimeout(function () {
- expect(hot.getActiveEditor().isOpened()).toBe(true);
- afterValidateCallback.calls.reset();
- $(hot.getActiveEditor().htContainer).find('tr:eq(1) td:eq(0)').simulate('mousedown');
- }, 200);
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toEqual('2');
- done();
- }, 400);
- });
- it('should not call the `source` has been selected', function () {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process([]); // hardcoded empty result
- });
- handsontable({
- data: [['one', 'two'], ['three', 'four']],
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- allowInvalid: false,
- strict: true
- }, {}],
- cells: function cells(row, col) {
- var cellProperties = {};
- if (row === 0 && col === 0) {
- cellProperties.readOnly = true;
- }
- return cellProperties;
- }
- });
- expect(getCellMeta(0, 0).readOnly).toBe(true);
- expect(syncSources).not.toHaveBeenCalled();
- selectCell(0, 0);
- expect(syncSources).not.toHaveBeenCalled();
- expect(getCellMeta(1, 0).readOnly).toBeFalsy();
- selectCell(1, 0);
- expect(syncSources).not.toHaveBeenCalled();
- });
- it('should not call the `source` method if cell is read only and the arrow has been clicked', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process([]); // hardcoded empty result
- });
- handsontable({
- data: [['one', 'two'], ['three', 'four']],
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- allowInvalid: false,
- strict: true
- }, {}],
- cells: function cells(row, col) {
- var cellProperties = {};
- if (row === 0 && col === 0) {
- cellProperties.readOnly = true;
- }
- return cellProperties;
- }
- });
- expect(getCellMeta(0, 0).readOnly).toBe(true);
- expect(syncSources).not.toHaveBeenCalled();
- selectCell(0, 0);
- $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mousedown');
- setTimeout(function () {
- expect(syncSources).not.toHaveBeenCalled();
- syncSources.calls.reset();
- expect(getCellMeta(1, 0).readOnly).toBeFalsy();
- selectCell(1, 0);
- $(getCell(1, 0)).find('.htAutocompleteArrow').simulate('mousedown');
- }, 100);
- setTimeout(function () {
- expect(syncSources).toHaveBeenCalled();
- expect(syncSources.calls.count()).toEqual(1);
- done();
- }, 200);
- });
- it('should add a scrollbar to the autocomplete dropdown, only if number of displayed choices exceeds 10', function (done) {
- var hot = handsontable({
- data: [['', 'two', 'three'], ['four', 'five', 'six']],
- columns: [{
- type: 'autocomplete',
- source: choices,
- allowInvalid: false,
- strict: false
- }, {}, {}]
- });
- this.$container.css({
- height: 600
- });
- expect(choices.length).toBeGreaterThan(10);
- selectCell(0, 0);
- $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mousedown');
- var dropdown = hot.getActiveEditor().htContainer;
- var dropdownHolder = hot.getActiveEditor().htEditor.view.wt.wtTable.holder;
- setTimeout(function () {
- expect(dropdownHolder.scrollHeight).toBeGreaterThan(dropdownHolder.clientHeight);
- keyDownUp('esc');
- hot.getSettings().columns[0].source = hot.getSettings().columns[0].source.slice(0).splice(3);
- hot.updateSettings({});
- selectCell(0, 0);
- $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mousedown');
- }, 30);
- setTimeout(function () {
- expect(dropdownHolder.scrollHeight > dropdownHolder.clientHeight).toBe(false);
- done();
- }, 60);
- });
- it('should not close editor on scrolling', function (done) {
- var hot = handsontable({
- data: [['', 'two', 'three'], ['four', 'five', 'six']],
- columns: [{
- type: 'autocomplete',
- source: choices,
- allowInvalid: false,
- strict: false
- }, {}, {}]
- });
- expect(choices.length).toBeGreaterThan(10);
- selectCell(0, 0);
- $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mousedown');
- $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mouseup');
- var dropdown = hot.getActiveEditor().htContainer;
- hot.view.wt.wtOverlays.topOverlay.scrollTo(1);
- setTimeout(function () {
- expect($(dropdown).is(':visible')).toBe(true);
- selectCell(0, 0);
- }, 30);
- setTimeout(function () {
- $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mousedown');
- $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mouseup');
- hot.view.wt.wtOverlays.topOverlay.scrollTo(3);
- }, 80);
- setTimeout(function () {
- expect($(dropdown).is(':visible')).toBe(true);
- done();
- }, 120);
- });
- it('should keep textarea caret position, after moving the selection to the suggestion list (pressing down arrow)', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- handsontable({
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- strict: false
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- var $editorInput = $('.handsontableInput');
- $editorInput.val('an');
- keyDownUp(65); // a
- keyDownUp(78); // n
- Handsontable.dom.setCaretPosition($editorInput[0], 1);
- setTimeout(function () {
- keyDownUp('arrow_down');
- expect(Handsontable.dom.getCaretPosition($editorInput[0])).toEqual(1);
- keyDownUp('arrow_down');
- expect(Handsontable.dom.getCaretPosition($editorInput[0])).toEqual(1);
- done();
- }, 200);
- });
- it('should keep textarea selection, after moving the selection to the suggestion list (pressing down arrow)', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- handsontable({
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- strict: false
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- var $editorInput = $('.handsontableInput');
- $editorInput.val('an');
- keyDownUp(65); // a
- keyDownUp(78); // n
- Handsontable.dom.setCaretPosition($editorInput[0], 1, 2);
- setTimeout(function () {
- keyDownUp('arrow_down');
- expect(Handsontable.dom.getCaretPosition($editorInput[0])).toEqual(1);
- expect(Handsontable.dom.getSelectionEndPosition($editorInput[0])).toEqual(2);
- keyDownUp('arrow_down');
- expect(Handsontable.dom.getCaretPosition($editorInput[0])).toEqual(1);
- expect(Handsontable.dom.getSelectionEndPosition($editorInput[0])).toEqual(2);
- done();
- }, 200);
- });
- it('should jump to the sibling cell, after pressing up key in quick edit mode', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- handsontable({
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- strict: false
- }, {}]
- });
- selectCell(1, 0);
- keyDownUp('x'); // trigger quick edit mode
- var $editorInput = $('.handsontableInput');
- $editorInput.val('an');
- keyDownUp(65); // a
- keyDownUp(78); // n
- setTimeout(function () {
- keyDownUp('arrow_up');
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- done();
- }, 200);
- });
- it('should jump to the next cell, after pressing right key in quick edit mode', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.plan = function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- };
- handsontable({
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- strict: false
- }, {}]
- });
- selectCell(1, 0);
- keyDownUp('x'); // trigger quick edit mode
- var $editorInput = $('.handsontableInput');
- $editorInput.val('an');
- keyDownUp(65); // a
- keyDownUp(78); // n
- setTimeout(function () {
- keyDownUp('arrow_right');
- expect(getSelected()).toEqual([1, 1, 1, 1]);
- done();
- }, 200);
- });
- it('should jump to the next cell, after pressing left key in quick edit mode', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- handsontable({
- columns: [{}, {
- type: 'autocomplete',
- source: syncSources,
- strict: false
- }]
- });
- selectCell(1, 1);
- keyDownUp('x'); // trigger quick edit mode
- var $editorInput = $('.handsontableInput');
- $editorInput.val('an');
- keyDownUp(65); // a
- keyDownUp(78); // n
- // put caret on the end of the text to ensure that editor will be closed after hit left arrow key
- Handsontable.dom.setCaretPosition($editorInput[0], 2, 2);
- setTimeout(function () {
- keyDownUp('arrow_left');
- expect(getSelected()).toEqual([1, 0, 1, 0]);
- done();
- }, 200);
- });
- it('should jump to the next cell, after pressing down key in quick edit mode', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- handsontable({
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- strict: false
- }, {}]
- });
- selectCell(1, 0);
- keyDownUp('x'); // trigger quick edit mode
- var $editorInput = $('.handsontableInput');
- $editorInput.val('an');
- keyDownUp(65); // a
- keyDownUp(78); // n
- setTimeout(function () {
- keyDownUp('arrow_down');
- expect(getSelected()).toEqual([1, 0, 1, 0]);
- done();
- }, 200);
- });
- it('should jump to the next cell, after pressing down key in quick edit mode when no matching option list found', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- handsontable({
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- strict: false
- }, {}]
- });
- selectCell(1, 0);
- keyDownUp('x'); // trigger quick edit mode
- var $editorInput = $('.handsontableInput');
- $editorInput.val('anananan');
- keyDownUp(65); // a
- keyDownUp(78); // n
- keyDownUp(65); // a
- keyDownUp(78); // n
- keyDownUp(65); // a
- keyDownUp(78); // n
- keyDownUp(65); // a
- keyDownUp(78); // n
- setTimeout(function () {
- keyDownUp('arrow_down');
- expect(getSelected()).toEqual([2, 0, 2, 0]);
- done();
- }, 200);
- });
- it('should not jump to the next cell, after pressing down key in quick edit mode when options list was opened', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- handsontable({
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- strict: false
- }, {}]
- });
- selectCell(1, 0);
- keyDownUp('x'); // trigger quick edit mode
- var $editorInput = $('.handsontableInput');
- $editorInput.val('an');
- keyDownUp(65); // a
- keyDownUp(78); // n
- setTimeout(function () {
- keyDownUp('arrow_down');
- expect(getSelected()).toEqual([1, 0, 1, 0]);
- done();
- }, 200);
- });
- it('should select option in opened editor after pressing down key in quick edit mode', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- var hot = handsontable({
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- strict: false
- }, {}]
- });
- selectCell(1, 0);
- keyDownUp('x'); // Trigger quick edit mode
- setTimeout(function () {
- keyDownUp('arrow_down');
- expect(hot.getActiveEditor().htEditor.getSelected()).toEqual([0, 0, 0, 0]);
- keyDownUp('arrow_down');
- expect(hot.getActiveEditor().htEditor.getSelected()).toEqual([1, 0, 1, 0]);
- keyDownUp('arrow_down');
- expect(hot.getActiveEditor().htEditor.getSelected()).toEqual([2, 0, 2, 0]);
- done();
- }, 200);
- });
- it('should select option in opened editor after pressing up key in quick edit mode', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- var hot = handsontable({
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- strict: false
- }, {}]
- });
- selectCell(1, 0);
- keyDownUp('x'); // Trigger quick edit mode
- setTimeout(function () {
- hot.getActiveEditor().htEditor.selectCell(2, 0);
- expect(hot.getActiveEditor().htEditor.getSelected()).toEqual([2, 0, 2, 0]);
- keyDownUp('arrow_up');
- expect(hot.getActiveEditor().htEditor.getSelected()).toEqual([1, 0, 1, 0]);
- keyDownUp('arrow_up');
- expect(hot.getActiveEditor().htEditor.getSelected()).toEqual([0, 0, 0, 0]);
- keyDownUp('arrow_up');
- expect(hot.getActiveEditor().htEditor.getSelected()).toEqual([0, 0, 0, 0]);
- done();
- }, 200);
- });
- it('should not close editor in quick edit mode after pressing down key when last option is selected', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- var hot = handsontable({
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- strict: false
- }, {}]
- });
- selectCell(1, 0);
- keyDownUp('x'); // Trigger quick edit mode
- setTimeout(function () {
- hot.getActiveEditor().htEditor.selectCell(7, 0);
- hot.listen();
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- expect(hot.getActiveEditor().isOpened()).toBe(true);
- done();
- }, 200);
- });
- it('should close editor in quick edit mode after pressing up key when no option is selected', function (done) {
- var syncSources = jasmine.createSpy('syncSources');
- syncSources.and.callFake(function (query, process) {
- process(choices.filter(function (choice) {
- return choice.indexOf(query) != -1;
- }));
- });
- var hot = handsontable({
- columns: [{
- type: 'autocomplete',
- source: syncSources,
- strict: false
- }, {}]
- });
- selectCell(1, 0);
- keyDownUp('x'); // Trigger quick edit mode
- setTimeout(function () {
- hot.getActiveEditor().htEditor.selectCell(1, 0);
- hot.listen();
- keyDownUp('arrow_up');
- keyDownUp('arrow_up');
- keyDownUp('arrow_up');
- expect(getSelected()).toEqual([0, 0, 0, 0]);
- done();
- }, 200);
- });
- });
- /***/ }),
- /* 206 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('BaseEditor', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '" style="width: 300px; height: 200px; overflow: auto"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('ctrl + enter when editor is active', function () {
- it('should populate value from the currently active cell to every cell in the selected range', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(6, 6)
- });
- selectCell(1, 1, 2, 2);
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(2, 2)).toEqual('C3');
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- keyDown('ctrl+enter');
- expect(getDataAtCell(1, 1)).toEqual('B2');
- expect(getDataAtCell(1, 2)).toEqual('B2');
- expect(getDataAtCell(2, 1)).toEqual('B2');
- expect(getDataAtCell(2, 2)).toEqual('B2');
- loadData(Handsontable.helper.createSpreadsheetData(6, 6));
- selectCell(1, 2, 2, 1);
- expect(getDataAtCell(1, 2)).toEqual('C2');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- keyDown('ctrl+enter');
- expect(getDataAtCell(1, 1)).toEqual('C2');
- expect(getDataAtCell(1, 2)).toEqual('C2');
- expect(getDataAtCell(2, 1)).toEqual('C2');
- expect(getDataAtCell(2, 2)).toEqual('C2');
- loadData(Handsontable.helper.createSpreadsheetData(6, 6));
- selectCell(2, 2, 1, 1);
- expect(getDataAtCell(2, 2)).toEqual('C3');
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- keyDown('ctrl+enter');
- expect(getDataAtCell(1, 1)).toEqual('C3');
- expect(getDataAtCell(1, 2)).toEqual('C3');
- expect(getDataAtCell(2, 1)).toEqual('C3');
- expect(getDataAtCell(2, 2)).toEqual('C3');
- loadData(Handsontable.helper.createSpreadsheetData(6, 6));
- selectCell(2, 1, 1, 2);
- expect(getDataAtCell(2, 1)).toEqual('B3');
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- keyDown('ctrl+enter');
- expect(getDataAtCell(1, 1)).toEqual('B3');
- expect(getDataAtCell(1, 2)).toEqual('B3');
- expect(getDataAtCell(2, 1)).toEqual('B3');
- expect(getDataAtCell(2, 2)).toEqual('B3');
- });
- });
- it('should exported all editors into Handsontable.editors object', function () {
- expect(Handsontable.editors.AutocompleteEditor).toBeDefined();
- expect(Handsontable.editors.BaseEditor).toBeDefined();
- expect(Handsontable.editors.CheckboxEditor).toBeDefined();
- expect(Handsontable.editors.DateEditor).toBeDefined();
- expect(Handsontable.editors.DropdownEditor).toBeDefined();
- expect(Handsontable.editors.HandsontableEditor).toBeDefined();
- expect(Handsontable.editors.MobileEditor).toBeDefined();
- expect(Handsontable.editors.NumericEditor).toBeDefined();
- expect(Handsontable.editors.PasswordEditor).toBeDefined();
- expect(Handsontable.editors.SelectEditor).toBeDefined();
- expect(Handsontable.editors.TextEditor).toBeDefined();
- });
- });
- /***/ }),
- /* 207 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('DateEditor', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- function getDates() {
- return [['01/14/2006'], ['12/01/2008'], ['11/19/2011'], ['02/02/2004'], ['07/24/2011']];
- }
- it('should display Pikday calendar', function () {
- handsontable({
- data: getDates(),
- columns: [{
- type: 'date'
- }]
- });
- expect($('.pika-single').is(':visible')).toBe(false);
- selectCell(0, 0);
- keyDown('enter');
- expect($('.pika-single').is(':visible')).toBe(true);
- });
- it('should pass date picker config object to Pikday', function () {
- var onOpenSpy = jasmine.createSpy('open');
- var onCloseSpy = jasmine.createSpy('close');
- var hot = handsontable({
- data: getDates(),
- columns: [{
- type: 'date',
- datePickerConfig: {
- firstDay: 1,
- field: 'field', // read only - shouldn't overwrite
- trigger: 'trigger', // read only - shouldn't overwrite
- container: 'container', // read only - shouldn't overwrite
- bound: true, // read only - shouldn't overwrite
- i18n: {
- previousMonth: 'Poprzedni',
- nextMonth: 'Następny',
- months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
- weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
- weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
- },
- onOpen: onOpenSpy,
- onClose: onCloseSpy
- }
- }]
- });
- selectCell(0, 0);
- keyDown('enter');
- keyDown('esc');
- var config = hot.getActiveEditor().$datePicker.config();
- expect(config.field instanceof HTMLElement).toBe(true);
- expect(config.trigger instanceof HTMLElement).toBe(true);
- expect(config.container instanceof HTMLElement).toBe(true);
- expect(config.bound).toBe(false);
- expect(config.firstDay).toBe(1);
- expect(config.i18n.previousMonth).toBe('Poprzedni');
- expect(config.i18n.nextMonth).toBe('Następny');
- expect(onOpenSpy).toHaveBeenCalled();
- expect(onCloseSpy).toHaveBeenCalled();
- });
- it('should remove any HTML connected with Pikaday Calendar', function () {
- handsontable({
- data: getDates(),
- columns: [{
- type: 'date'
- }]
- });
- expect($('.pika-single').length).toBe(0);
- selectCell(0, 0);
- keyDown('enter');
- expect($('.pika-single').length).toBe(1);
- destroy();
- expect($('.pika-single').length).toBe(0);
- });
- it('should select date corresponding to cell value', function () {
- handsontable({
- data: getDates(),
- columns: [{
- type: 'date',
- dateFormat: 'MM/DD/YYYY'
- }]
- });
- selectCell(0, 0);
- keyDown('enter');
- var date = new Date(getDates()[0][0]);
- expect($('.pika-single').find('.pika-select-year').find(':selected').val()).toMatch(date.getFullYear().toString());
- expect($('.pika-single').find('.pika-select-month').find(':selected').val()).toMatch(date.getMonth().toString());
- expect($('.pika-single').find('.pika-table .is-selected').text()).toMatch(date.getDate().toString());
- });
- it('should save new date after clicked on calendar', function (done) {
- handsontable({
- data: getDates(),
- columns: [{
- type: 'date',
- dateFormat: 'MM/DD/YYYY'
- }]
- });
- selectCell(0, 0);
- expect(getDataAtCell(0, 0)).toMatch('01/14/2006');
- keyDown('enter');
- mouseDown($('.pika-single').find('.pika-table tbody tr:eq(0) td:eq(0) button'));
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toMatch('01/01/2006');
- done();
- }, 150);
- });
- it('should display fill handle after selected date on calendar', function (done) {
- handsontable({
- data: getDates(),
- columns: [{
- type: 'date',
- dateFormat: 'MM/DD/YYYY'
- }]
- });
- selectCell(0, 0);
- expect(getDataAtCell(0, 0)).toMatch('01/14/2006');
- keyDown('enter');
- mouseDown($('.pika-single').find('.pika-table tbody tr:eq(0) td:eq(0) button'));
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toMatch('01/01/2006');
- expect($('.htBorders .current.corner').is(':visible')).toBe(true);
- done();
- }, 150);
- });
- it('should setup in settings and display defaultDate on calendar', function (done) {
- handsontable({
- data: getDates(),
- minSpareRows: 1,
- columns: [{
- type: 'date',
- dateFormat: 'MM/DD/YYYY',
- defaultDate: '01/01/1900'
- }]
- });
- selectCell(5, 0);
- expect(getDataAtCell(5, 0)).toBe(null);
- keyDown('enter');
- var date = new Date('01/01/1900');
- expect($('.pika-single').find('.pika-select-year').find(':selected').val()).toMatch(date.getFullYear().toString());
- expect($('.pika-single').find('.pika-select-month').find(':selected').val()).toMatch(date.getMonth().toString());
- expect($('.pika-single').find('.pika-table .is-selected').text()).toMatch(date.getDate().toString());
- keyDown('enter');
- setTimeout(function () {
- expect(getDataAtCell(5, 0)).toMatch('01/01/1900');
- done();
- }, 150);
- });
- it('should close calendar after picking new date', function () {
- handsontable({
- data: getDates(),
- columns: [{
- type: 'date',
- dateFormat: 'MM/DD/YYYY'
- }]
- });
- selectCell(0, 0);
- keyDown('enter');
- expect($('.pika-single').is(':visible')).toBe(true);
- mouseDown($('.pika-single').find('.pika-table tbody tr:eq(0) td:eq(0) button'));
- expect($('.pika-single').is(':visible')).toBe(false);
- });
- it('should enable to input any value in textarea', function (done) {
- var hot = handsontable({
- data: getDates(),
- columns: [{
- type: 'date'
- }]
- });
- selectCell(0, 0);
- var editor = hot.getActiveEditor();
- editor.beginEditing();
- expect(editor.isOpened()).toBe(true);
- editor.TEXTAREA.value = 'foo';
- keyDownUp('o'.charCodeAt(0));
- expect(editor.getValue()).toEqual('foo');
- editor.finishEditing();
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toEqual('foo');
- done();
- }, 30);
- });
- it('should restore original when edited and pressed ESC ', function (done) {
- var hot = handsontable({
- data: getDates(),
- columns: [{
- type: 'date'
- }]
- });
- selectCell(0, 0);
- var editor = hot.getActiveEditor();
- editor.beginEditing();
- expect(editor.isOpened()).toBe(true);
- editor.TEXTAREA.value = 'foo';
- expect(editor.getValue()).toEqual('foo');
- keyDownUp(Handsontable.helper.KEY_CODES.ESCAPE); // cancel editing
- editor.finishEditing();
- setTimeout(function () {
- expect(getDataAtCell(0, 0)).toEqual('01/14/2006');
- done();
- }, 30);
- });
- it('should display a calendar based on a current date, even if a date in a wrong format was entered previously', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- columns: [{ type: 'date' }, { type: 'date', dateFormat: 'YYYY-MM-DD' }],
- minSpareRows: 1
- });
- setDataAtCell(4, 1, '15-11-11');
- setTimeout(function () {
- selectCell(5, 1);
- keyDown('enter');
- expect($('.pika-single').is(':visible')).toBe(true);
- mouseDown($('.pika-single').find('.pika-table tbody tr:eq(3) td:eq(3) button'));
- }, 150);
- setTimeout(function () {
- var resultDate = getDataAtCell(5, 1);
- expect(moment(resultDate).year()).toEqual(moment().year());
- expect(moment(resultDate).month()).toEqual(moment().month());
- done();
- }, 300);
- });
- it('should display Pikaday Calendar bottom of the selected cell', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- columns: [{ type: 'date' }, { type: 'date' }]
- }),
- cellOffset,
- datePickerOffset;
- selectCell(1, 1);
- keyDown('enter');
- cellOffset = $(hot.getActiveEditor().TD).offset();
- datePickerOffset = $('.pika-single').offset();
- // 23 is a height of the editor cell
- expect(cellOffset.top + 23).toBeCloseTo(datePickerOffset.top, 0);
- expect(cellOffset.left).toBeCloseTo(datePickerOffset.left, 0);
- });
- it('should display Pikaday Calendar bottom of the selected cell when table have scrolls', function () {
- var container = $('#testContainer');
- container[0].style.height = '300px';
- container[0].style.width = '200px';
- container[0].style.overflow = 'hidden';
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(30, 10),
- colWidths: 60,
- columns: [{ type: 'date' }, { type: 'date' }, { type: 'date' }, { type: 'date' }, { type: 'date' }, { type: 'date' }, { type: 'date' }]
- }),
- cellOffset,
- datePickerOffset;
- selectCell(20, 6);
- keyDown('enter');
- cellOffset = $(hot.getActiveEditor().TD).offset();
- datePickerOffset = $('.pika-single').offset();
- expect(cellOffset.top + 23).toBeCloseTo(datePickerOffset.top, 0);
- expect(cellOffset.left).toBeCloseTo(datePickerOffset.left, 0);
- });
- it('should not modify the edited date and time, when opening the editor', function () {
- var hot = handsontable({
- data: [['02/02/2015 8:00 AM']],
- columns: [{
- type: 'date',
- dateFormat: 'MM/DD/YYYY h:mm A',
- correctFormat: true,
- defaultDate: '01/01/1900',
- allowEmpty: false
- }]
- }),
- editor,
- cellValue;
- // setDataAtCell(0, 0, '02/02/2015 8:00 AM');
- cellValue = getDataAtCell(0, 0);
- selectCell(0, 0);
- keyDown('enter');
- editor = hot.getActiveEditor();
- expect(editor.TEXTAREA.value).toEqual(cellValue);
- });
- });
- /***/ }),
- /* 208 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('DropdownEditor', function () {
- var id = 'testContainer';
- var choices = ['yellow', 'red', 'orange', 'green', 'blue', 'gray', 'black', 'white', 'purple', 'lime', 'olive', 'cyan'];
- var hot;
- beforeEach(function () {
- this.$container = $('<div id="' + id + '" style="width: 300px; height: 200px; overflow: auto"></div>').appendTo('body');
- });
- afterEach(function () {
- if (hot) {
- hot = null;
- }
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('open editor', function () {
- // see https://github.com/handsontable/handsontable/issues/3380
- it('should not throw error while selecting the next cell by hitting enter key', function () {
- var spy = jasmine.createSpyObj('error', ['test']);
- var prevError = window.onerror;
- window.onerror = function (messageOrEvent, source, lineno, colno, error) {
- spy.test();
- };
- handsontable({
- columns: [{
- editor: 'dropdown',
- source: choices
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- keyDownUp('enter');
- keyDownUp('enter');
- expect(spy.test.calls.count()).toBe(0);
- window.onerror = prevError;
- });
- });
- describe('closing the editor', function () {
- it('should not close editor on scrolling', function (done) {
- hot = handsontable({
- data: [['', 'two', 'three'], ['four', 'five', 'six']],
- columns: [{
- type: 'dropdown',
- source: choices
- }, {}, {}]
- });
- selectCell(0, 0);
- $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mousedown');
- $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mouseup');
- hot.view.wt.wtOverlays.topOverlay.scrollTo(1);
- var dropdown = hot.getActiveEditor();
- setTimeout(function () {
- expect($(dropdown.htContainer).is(':visible')).toBe(true);
- selectCell(0, 0);
- }, 30);
- setTimeout(function () {
- $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mousedown');
- $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mouseup');
- hot.view.wt.wtOverlays.topOverlay.scrollTo(3);
- }, 150);
- setTimeout(function () {
- expect($(dropdown.htContainer).is(':visible')).toBe(true);
- done();
- }, 200);
- });
- });
- it('should mark all invalid values as invalid, after pasting them into dropdown-type cells', function (done) {
- hot = handsontable({
- data: [['', 'two', 'three'], ['four', 'five', 'six']],
- columns: [{
- type: 'dropdown',
- source: choices
- }, {}, {}]
- });
- populateFromArray(0, 0, [['invalid'], ['input']], null, null, 'paste');
- setTimeout(function () {
- expect(Handsontable.dom.hasClass(getCell(0, 0), 'htInvalid')).toBe(true);
- expect(Handsontable.dom.hasClass(getCell(1, 0), 'htInvalid')).toBe(true);
- done();
- }, 40);
- });
- });
- /***/ }),
- /* 209 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('HandsontableEditor', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- function getManufacturerData() {
- return [{ name: 'BMW', country: 'Germany', owner: 'Bayerische Motoren Werke AG' }, { name: 'Chrysler', country: 'USA', owner: 'Chrysler Group LLC' }, { name: 'Nissan', country: 'Japan', owner: 'Nissan Motor Company Ltd' }, { name: 'Suzuki', country: 'Japan', owner: 'Suzuki Motor Corporation' }, { name: 'Toyota', country: 'Japan', owner: 'Toyota Motor Corporation' }, { name: 'Volvo', country: 'Sweden', owner: 'Zhejiang Geely Holding Group' }];
- }
- it('should create an editor that is a Handsontable instance', function () {
- handsontable({
- columns: [{
- type: 'handsontable',
- handsontable: {
- colHeaders: ['Marque', 'Country', 'Parent company'],
- data: getManufacturerData()
- }
- }]
- });
- selectCell(2, 0);
- keyDownUp('enter');
- expect(this.$container.find('.handsontableEditor:visible').length).toEqual(1);
- });
- it('should destroy the editor when Esc is pressed', function () {
- handsontable({
- columns: [{
- type: 'handsontable',
- handsontable: {
- colHeaders: ['Marque', 'Country', 'Parent company'],
- data: getManufacturerData()
- }
- }]
- });
- selectCell(2, 0);
- keyDownUp('enter');
- keyDownUp('esc');
- expect(this.$container.find('.handsontableEditor:visible').length).toEqual(0);
- });
- // see https://github.com/handsontable/handsontable/issues/3380
- it('should not throw error while selecting the next cell by hitting enter key', function () {
- var spy = jasmine.createSpyObj('error', ['test']);
- var prevError = window.onerror;
- window.onerror = function (messageOrEvent, source, lineno, colno, error) {
- spy.test();
- };
- handsontable({
- columns: [{
- type: 'handsontable',
- handsontable: {
- data: [['Marque'], ['Country'], ['Parent company']]
- }
- }]
- });
- selectCell(0, 0);
- keyDownUp('enter');
- keyDownUp('enter');
- keyDownUp('enter');
- expect(spy.test.calls.count()).toBe(0);
- window.onerror = prevError;
- });
- it('Enter pressed in nested HT should set the value and hide the editor', function () {
- handsontable({
- columns: [{
- type: 'handsontable',
- handsontable: {
- colHeaders: ['Marque', 'Country', 'Parent company'],
- data: getManufacturerData()
- }
- }]
- });
- selectCell(2, 0);
- keyDownUp('enter');
- keyDownUp('arrow_down');
- keyDownUp('enter');
- expect(this.$container.find('.handsontableEditor:visible').length).toEqual(0);
- expect(getDataAtCell(2, 0)).toEqual('BMW');
- });
- it('should keep focus on textarea after arrow is pressed', function () {
- var hot = handsontable({
- columns: [{
- type: 'handsontable',
- handsontable: {
- colHeaders: ['Marque', 'Country', 'Parent company'],
- data: getManufacturerData()
- }
- }]
- });
- selectCell(2, 0);
- keyDownUp('enter');
- keyDownUp('arrow_down');
- expect(document.activeElement).toEqual(hot.getActiveEditor().TEXTAREA);
- });
- it('should focus the TD after HT editor is prepared and destroyed', function () {
- handsontable({
- columns: [{
- type: 'handsontable',
- handsontable: {
- colHeaders: ['Marque', 'Country', 'Parent company'],
- data: getManufacturerData()
- }
- }]
- });
- selectCell(2, 0);
- keyDownUp('arrow_down');
- keyDownUp('arrow_down');
- expect(getSelected()).toEqual([4, 0, 4, 0]);
- });
- it('should focus the TD after HT editor is prepared, finished (by keyboard) and destroyed', function () {
- var selections = [];
- handsontable({
- columns: [{
- type: 'handsontable',
- handsontable: {
- colHeaders: ['Marque', 'Country', 'Parent company'],
- data: getManufacturerData(),
- afterSelection: function afterSelection() {
- selections.push(['inner', arguments[0]]); // arguments[0] is selection start row
- }
- }
- }],
- afterSelection: function afterSelection() {
- selections.push(['outer', arguments[0]]); // arguments[0] is selection start row
- }
- });
- expect(selections.length).toBe(0);
- selectCell(1, 0);
- expect(selections[0]).toEqual(['outer', 1]);
- keyDownUp('arrow_down');
- expect(selections[1]).toEqual(['outer', 2]);
- keyDownUp('enter');
- keyDownUp('arrow_down');
- expect(selections[2]).toEqual(['inner', 0]);
- keyDownUp('esc');
- keyDownUp('arrow_down');
- expect(selections[3]).toEqual(['outer', 3]);
- expect(selections.length).toBe(4);
- });
- describe('strict mode', function () {
- it('should open editor and select cell (0, 0) in inner HOT', function () {
- var hot = handsontable({
- columns: [{
- type: 'handsontable',
- handsontable: {
- colHeaders: ['Marque', 'Country', 'Parent company'],
- data: getManufacturerData()
- },
- strict: true
- }]
- });
- selectCell(2, 0);
- keyDownUp('enter');
- var ht = hot.getActiveEditor();
- var innerHot = ht.htEditor;
- expect(innerHot.getSelected()).toEqual([0, 0, 0, 0]);
- });
- it('should hide textarea', function () {
- var hot = handsontable({
- columns: [{
- type: 'handsontable',
- handsontable: {
- colHeaders: ['Marque', 'Country', 'Parent company'],
- data: getManufacturerData()
- },
- strict: true
- }]
- });
- selectCell(2, 0);
- keyDownUp('enter');
- expect(hot.getActiveEditor().TEXTAREA.style.visibility).toEqual('hidden');
- });
- });
- describe('non strict mode', function () {
- it('should open editor and DO NOT select any cell in inner HOT', function () {
- var hot = handsontable({
- columns: [{
- type: 'handsontable',
- handsontable: {
- colHeaders: ['Marque', 'Country', 'Parent company'],
- data: getManufacturerData()
- }
- }]
- });
- selectCell(2, 0);
- keyDownUp('enter');
- var ht = hot.getActiveEditor();
- var innerHot = ht.htEditor;
- expect(innerHot.getSelected()).toBeUndefined();
- });
- it('should show textarea', function () {
- var hot = handsontable({
- columns: [{
- type: 'handsontable',
- handsontable: {
- colHeaders: ['Marque', 'Country', 'Parent company'],
- data: getManufacturerData()
- }
- }]
- });
- selectCell(2, 0);
- keyDownUp('enter');
- expect(hot.getActiveEditor().TEXTAREA.style.visibility).toEqual('visible');
- });
- });
- });
- /***/ }),
- /* 210 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- describe('editors', function () {
- var id = 'testContainer';
- var _Handsontable$editors = Handsontable.editors,
- registerEditor = _Handsontable$editors.registerEditor,
- getEditor = _Handsontable$editors.getEditor;
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should register custom editor', function () {
- var MyEditor = function (_Handsontable$editors2) {
- _inherits(MyEditor, _Handsontable$editors2);
- function MyEditor() {
- _classCallCheck(this, MyEditor);
- return _possibleConstructorReturn(this, (MyEditor.__proto__ || Object.getPrototypeOf(MyEditor)).apply(this, arguments));
- }
- _createClass(MyEditor, [{
- key: 'init',
- value: function init() {
- this.TEXTAREA = document.createElement('TEXTAREA');
- this.TEXTAREA_PARENT = document.createElement('DIV');
- this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
- this.instance.rootElement.appendChild(this.TEXTAREA_PARENT);
- }
- }, {
- key: 'getValue',
- value: function getValue() {
- return '--' + this.TEXTAREA.value + '--';
- }
- }, {
- key: 'setValue',
- value: function setValue(value) {
- this.TEXTAREA.value = value;
- }
- }, {
- key: 'open',
- value: function open() {}
- }, {
- key: 'close',
- value: function close() {}
- }, {
- key: 'focus',
- value: function focus() {
- this.TEXTAREA.focus();
- }
- }]);
- return MyEditor;
- }(Handsontable.editors.BaseEditor);
- registerEditor('myEditor', MyEditor);
- var hot = handsontable({
- data: [[1, 6, 10]],
- columns: [{
- editor: 'myEditor'
- }]
- });
- selectCell(0, 0);
- keyDown('enter');
- document.activeElement.value = 'hello';
- destroyEditor();
- expect(getDataAtCell(0, 0)).toBe('--hello--');
- });
- it('should retrieve predefined editors by its names', function () {
- expect(getEditor('autocomplete')).toBeFunction();
- expect(getEditor('base')).toBeFunction();
- expect(getEditor('checkbox')).toBeFunction();
- expect(getEditor('date')).toBeFunction();
- expect(getEditor('dropdown')).toBeFunction();
- expect(getEditor('handsontable')).toBeFunction();
- expect(getEditor('mobile')).toBeFunction();
- expect(getEditor('numeric')).toBeFunction();
- expect(getEditor('password')).toBeFunction();
- expect(getEditor('select')).toBeFunction();
- expect(getEditor('text')).toBeFunction();
- });
- it('should retrieve custom editor by its names', function () {
- var MyEditor = function MyEditor() {
- _classCallCheck(this, MyEditor);
- };
- registerEditor('myEditor', MyEditor);
- expect(getEditor('myEditor')).toBe(MyEditor);
- });
- });
- /***/ }),
- /* 211 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('noEditor', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '" style="width: 300px; height: 200px; overflow: auto"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('shouldn\'t begin editing when enterBeginsEditing equals true', function () {
- var selection;
- handsontable({
- enterBeginsEditing: true,
- editor: false
- });
- selectCell(2, 2);
- keyDown('enter');
- selection = getSelected();
- expect(selection).toEqual([2, 2, 2, 2]);
- expect(isEditorVisible()).toEqual(false);
- });
- it('shouldn\'t move down after editing', function () {
- var selection;
- handsontable({
- editor: false
- });
- selectCell(2, 2);
- keyDown('enter');
- keyDown('enter');
- selection = getSelected();
- expect(selection).toEqual([2, 2, 2, 2]);
- });
- it('shouldn\'t move down when enterBeginsEditing equals false', function () {
- var selection;
- handsontable({
- enterBeginsEditing: false,
- editor: false
- });
- selectCell(2, 2);
- keyDown('enter');
- selection = getSelected();
- expect(selection).toEqual([3, 2, 3, 2]);
- expect(isEditorVisible()).toEqual(false);
- });
- it('shouldn\'t render any value in editor', function () {
- handsontable({
- editor: false
- });
- setDataAtCell(2, 2, 'string');
- selectCell(2, 2);
- keyDown('enter');
- expect(keyProxy().length).toEqual(0);
- });
- it('shouldn\'t open editor after hitting F2', function () {
- handsontable({
- editor: false
- });
- selectCell(2, 2);
- expect(isEditorVisible()).toEqual(false);
- keyDown('f2');
- expect(isEditorVisible()).toEqual(false);
- });
- it('shouldn\'t open editor after hitting CapsLock', function () {
- handsontable({
- editor: false
- });
- selectCell(2, 2);
- expect(isEditorVisible()).toEqual(false);
- keyDown(Handsontable.helper.KEY_CODES.CAPS_LOCK);
- expect(isEditorVisible()).toEqual(false);
- });
- it('shouldn\'t open editor after double clicking on a cell', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2),
- editor: false
- });
- var cell = $(getCell(0, 0));
- var clicks = 0;
- window.scrollTo(0, cell.offset().top);
- setTimeout(function () {
- mouseDown(cell);
- mouseUp(cell);
- clicks++;
- }, 0);
- setTimeout(function () {
- mouseDown(cell);
- mouseUp(cell);
- clicks++;
- }, 100);
- setTimeout(function () {
- expect(clicks).toBe(2);
- expect(hot.getActiveEditor()).toBe(undefined);
- expect(isEditorVisible()).toBe(false);
- done();
- }, 200);
- });
- it('should not open editor after pressing a printable character', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 3),
- editor: false
- });
- selectCell(0, 0);
- expect(isEditorVisible()).toBe(false);
- this.$container.simulate('keydown', { keyCode: 'a'.charCodeAt(0) });
- expect(isEditorVisible()).toBe(false);
- });
- it('should not open editor after pressing a printable character with shift key', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 3),
- editor: false
- });
- selectCell(0, 0);
- expect(isEditorVisible()).toBe(false);
- this.$container.simulate('keydown', { keyCode: 'a'.charCodeAt(0), shiftKey: true });
- expect(isEditorVisible()).toBe(false);
- });
- it('should not not open editor after hitting ALT', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- editor: false
- });
- expect(getDataAtCell(0, 0)).toEqual('A1');
- selectCell(0, 0);
- keyDown(Handsontable.helper.KEY_CODES.ALT);
- expect(isEditorVisible()).toBe(false);
- });
- });
- /***/ }),
- /* 212 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- describe('NumericEditor', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfObjects = function arrayOfObjects() {
- return [{ id: 1, name: 'Ted', lastName: 'Right' }, { id: 2, name: 'Frank', lastName: 'Honest' }, { id: 3, name: 'Joan', lastName: 'Well' }, { id: 4, name: 'Sid', lastName: 'Strong' }, { id: 5, name: 'Jane', lastName: 'Neat' }, { id: 6, name: 'Chuck', lastName: 'Jackson' }, { id: 7, name: 'Meg', lastName: 'Jansen' }, { id: 8, name: 'Rob', lastName: 'Norris' }, { id: 9, name: 'Sean', lastName: 'O\'Hara' }, { id: 10, name: 'Eve', lastName: 'Branson' }];
- };
- it('should convert numeric value to number (object data source)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- keyDown('enter');
- document.activeElement.value = '999';
- destroyEditor();
- setTimeout(function () {
- expect(_typeof(getDataAtCell(2, 0))).toEqual('number');
- expect(getDataAtCell(2, 0)).toEqual(999);
- done();
- }, 100);
- });
- it('should apply changes to editor after validation', function (done) {
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric' }]
- });
- selectCell(0, 0);
- keyDown('delete');
- setTimeout(function () {
- expect(getActiveEditor().originalValue).toEqual('');
- done();
- }, 100);
- });
- it('should allow custom validator', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- allowInvalid: false,
- columns: [{
- data: 'id',
- type: 'numeric',
- validator: function validator(val, cb) {
- cb(parseInt(val, 10) > 100);
- }
- }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- keyDown('enter');
- document.activeElement.value = '99';
- destroyEditor();
- setTimeout(function () {
- expect(getDataAtCell(2, 0)).not.toEqual(99); // should be ignored
- document.activeElement.value = '999';
- onAfterValidate.calls.reset();
- destroyEditor();
- }, 100);
- setTimeout(function () {
- expect(getDataAtCell(2, 0)).toEqual(999);
- done();
- }, 200);
- });
- it('should convert string in format \'XX.XX\' to a float with the same value', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- keyDown('enter');
- document.activeElement.value = '99.99';
- onAfterValidate.calls.reset();
- destroyEditor();
- setTimeout(function () {
- expect(getDataAtCell(2, 0)).toEqual(parseFloat(99.99));
- done();
- }, 100);
- });
- it('should convert string in format \'XX.XX\' to a float when passing float without leading zero', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- keyDown('enter');
- document.activeElement.value = '.74';
- onAfterValidate.calls.reset();
- destroyEditor();
- setTimeout(function () {
- expect(getDataAtCell(2, 0)).toEqual(parseFloat(0.74));
- done();
- }, 100);
- });
- it('should convert string in format \'XX,XX\' (with comma as separator) to a float with the same value if the numeric locale ' + 'specifies comma as the precision delimiter (language=de)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric', language: 'de-DE' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- keyDown('enter');
- document.activeElement.value = '99,99';
- onAfterValidate.calls.reset();
- destroyEditor();
- setTimeout(function () {
- expect(getDataAtCell(2, 0)).toEqual(parseFloat(99.99));
- done();
- }, 100);
- });
- it('should display a string in a format \'$X,XXX.XX\' when using language=en, appropriate format in column settings and \'XXXX.XX\' as ' + 'an input string', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric', format: '$0,0.00', language: 'en-US' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- keyDown('enter');
- document.activeElement.value = '2456.22';
- onAfterValidate.calls.reset();
- destroyEditor();
- setTimeout(function () {
- expect(getCell(2, 0).innerHTML).toEqual('$2,456.22');
- done();
- }, 100);
- });
- it('should display a string in a format \'X.XXX,XX €\' when using language=de, appropriate format in column settings and \'XXXX,XX\' as an ' + 'input string (that comes from manual input)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric', format: '0,0.00 $', language: 'de-DE' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- keyDown('enter');
- document.activeElement.value = '2456,22';
- onAfterValidate.calls.reset();
- destroyEditor();
- setTimeout(function () {
- expect(getCell(2, 0).innerHTML).toEqual('2.456,22 €');
- done();
- }, 100);
- });
- it('should display a string in a format \'X.XXX,XX €\' when using language=de, appropriate format in column settings and \'XXXX.XX\' as an ' + 'input string (that comes from paste)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric', format: '0,0.00 $', language: 'de-DE' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- keyDown('enter');
- document.activeElement.value = '2456.22';
- onAfterValidate.calls.reset();
- destroyEditor();
- setTimeout(function () {
- expect(getCell(2, 0).innerHTML).toEqual('2.456,22 €');
- done();
- }, 100);
- });
- it('should not validate input values in different formats than \'XX.XX\' and \'XX,XX\'', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- function manuallySetValueTo(val) {
- keyDown('enter');
- document.activeElement.value = val;
- onAfterValidate.calls.reset();
- destroyEditor();
- }
- manuallySetValueTo('22.22');
- setTimeout(function () {
- expect($(getCell(2, 0)).hasClass('htInvalid')).toBe(false); // should validate alright
- manuallySetValueTo('2,000,000.22');
- }, 100);
- setTimeout(function () {
- expect($(getCell(2, 0)).hasClass('htInvalid')).toBe(true);
- manuallySetValueTo('11,11');
- }, 200);
- setTimeout(function () {
- expect($(getCell(2, 0)).hasClass('htInvalid')).toBe(false); // should validate alright
- manuallySetValueTo('one thounsand');
- }, 300);
- setTimeout(function () {
- expect($(getCell(2, 0)).hasClass('htInvalid')).toBe(true);
- manuallySetValueTo('99d99');
- }, 400);
- setTimeout(function () {
- expect($(getCell(2, 0)).hasClass('htInvalid')).toBe(true);
- done();
- }, 500);
- });
- it('should paste formatted data if source cell has format', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric', format: '0,0.00 $', language: 'de-DE' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- keyDown('enter');
- document.activeElement.value = '€123,00';
- onAfterValidate.calls.reset();
- destroyEditor();
- setTimeout(function () {
- expect(getCell(2, 0).innerHTML).toEqual('123,00 €');
- done();
- }, 100);
- });
- it('should display a string in a format \'X XXX,XX €\' when using language=de, appropriate format in column settings and \'XXXX,XX\' as an ' + 'input string and ignore not needed zeros at the end', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: [{ id: 1, name: 'Ted', lastName: 'Right', money: 0 }, { id: 2, name: 'Frank', lastName: 'Honest', money: 0 }, { id: 3, name: 'Joan', lastName: 'Well', money: 0 }, { id: 4, name: 'Sid', lastName: 'Strong', money: 0 }, { id: 5, name: 'Jane', lastName: 'Neat', money: 0 }, { id: 6, name: 'Chuck', lastName: 'Jackson', money: 0 }, { id: 7, name: 'Meg', lastName: 'Jansen', money: 0 }, { id: 8, name: 'Rob', lastName: 'Norris', money: 0 }, { id: 9, name: 'Sean', lastName: 'O\'Hara', money: 0 }, { id: 10, name: 'Eve', lastName: 'Branson', money: 0 }],
- columns: [{ data: 'id', type: 'numeric', format: '0,0.00 $', language: 'de-DE' }, { data: 'name' }, { data: 'lastName' }, { data: 'money', type: 'numeric', format: '$0,0.00', language: 'en-US' }],
- afterValidate: onAfterValidate
- });
- selectCell(2, 0);
- function manuallySetValueTo(val) {
- keyDown('enter');
- document.activeElement.value = val;
- onAfterValidate.calls.reset();
- destroyEditor();
- }
- manuallySetValueTo('2456,220');
- setTimeout(function () {
- expect(getCell(2, 0).innerHTML).toEqual('2.456,22 €');
- deselectCell();
- selectCell(2, 3);
- manuallySetValueTo('2456.220');
- }, 100);
- setTimeout(function () {
- expect(getCell(2, 3).innerHTML).toEqual('$2,456.22');
- done();
- }, 200);
- });
- it('should mark text as invalid without removing', function (done) {
- var hot = handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric', format: '0,0.00' }, { data: 'name' }, { data: 'lastName' }]
- });
- hot.setDataAtCell(0, 0, 'abc');
- setTimeout(function () {
- expect(hot.getDataAtCell(0, 0)).toEqual('abc');
- done();
- }, 200);
- });
- it('should not throw error on closing editor when column data is defined as \'length\'', function () {
- hot = handsontable({
- data: [{ length: 4 }, { length: 5 }],
- columns: [{
- data: 'length', type: 'numeric'
- }, {}, {}]
- });
- selectCell(1, 0);
- keyDown('enter');
- document.activeElement.value = '999';
- expect(function () {
- destroyEditor();
- }).not.toThrow();
- });
- describe('Cell corner is showed properly when changing focused cells #3877', function () {
- var isFocusedCellDisplayingCornerTest = function isFocusedCellDisplayingCornerTest(settings) {
- var moveFromRow = settings.moveFromRow;
- var moveFromCol = settings.moveFromCol;
- var moveToRow = settings.moveToRow;
- var moveToCol = settings.moveToCol;
- var doneFunc = settings.doneFunc;
- var $corner = settings.$container.find('.wtBorder.current.corner');
- selectCell(moveFromRow, moveFromCol);
- keyDown('enter');
- selectCell(moveToRow, moveToCol);
- setTimeout(function () {
- expect($corner.css('display')).toEqual('block');
- doneFunc();
- }, 100);
- };
- it('Moving from numeric editor to text editor', function (done) {
- handsontable({
- data: [{ id: 1, name: 'Ted', lastName: 'Right', money: 0 }],
- columns: [{ data: 'id' }, { data: 'name' }, { data: 'lastName' }, { data: 'money', type: 'numeric', format: '$0,0.00', language: 'en-US' }]
- });
- isFocusedCellDisplayingCornerTest({
- moveFromRow: 0,
- moveFromCol: 3,
- moveToRow: 0,
- moveToCol: 0,
- $container: this.$container,
- doneFunc: done
- });
- });
- it('Moving from text editor to numeric editor', function (done) {
- handsontable({
- data: [{ id: 1, name: 'Ted', lastName: 'Right', money: 0 }],
- columns: [{ data: 'id' }, { data: 'name' }, { data: 'lastName' }, { data: 'money', type: 'numeric', format: '$0,0.00', language: 'en-US' }]
- });
- isFocusedCellDisplayingCornerTest({
- moveFromRow: 0,
- moveFromCol: 1,
- moveToRow: 0,
- moveToCol: 3,
- $container: this.$container,
- doneFunc: done
- });
- });
- });
- });
- /***/ }),
- /* 213 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('PasswordEditor', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '" style="width: 300px; height: 300px;"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should display editor as password field', function () {
- handsontable({
- data: [['Joe'], ['Timothy'], ['Margaret'], ['Jerry']],
- columns: [{
- editor: Handsontable.editors.PasswordEditor
- }]
- });
- selectCell(0, 0);
- keyDown('enter');
- var editor = $('.handsontableInput');
- expect(editor.is(':visible')).toBe(true);
- expect(editor.is(':password')).toBe(true);
- });
- it('should set passwordEditor using \'password\' alias', function () {
- handsontable({
- data: [['Joe'], ['Timothy'], ['Margaret'], ['Jerry']],
- columns: [{
- editor: 'password'
- }]
- });
- selectCell(0, 0);
- keyDown('enter');
- var editor = $('.handsontableInput');
- expect(editor.is(':visible')).toBe(true);
- expect(editor.is(':password')).toBe(true);
- });
- it('should set passwordEditor using column type \'password\' ', function () {
- handsontable({
- data: [['Joe'], ['Timothy'], ['Margaret'], ['Jerry']],
- columns: [{
- type: 'password'
- }]
- });
- selectCell(0, 0);
- keyDown('enter');
- var editorHolder = $('.handsontableInputHolder');
- var editor = editorHolder.find('.handsontableInput');
- expect(editorHolder.is(':visible')).toBe(true);
- expect(editor.is(':password')).toBe(true);
- });
- it('should save values typed in passwordEditor', function () {
- handsontable({
- data: [['Joe'], ['Timothy'], ['Margaret'], ['Jerry']],
- columns: [{
- editor: 'password'
- }]
- });
- selectCell(0, 0);
- expect(getDataAtCell(0, 0)).toMatch('Joe');
- expect(getRenderedValue(0, 0)).toMatch('Joe');
- keyDown('enter');
- var editorHolder = $('.handsontableInputHolder');
- var editor = editorHolder.find('.handsontableInput');
- expect(editorHolder.is(':visible')).toBe(true);
- editor.val('Edgar');
- selectCell(1, 0); // closes editor and saves current value
- expect(editorHolder.is(':visible')).toBe(false);
- expect(getDataAtCell(0, 0)).toMatch('Edgar');
- expect(getRenderedValue(0, 0)).toMatch('Edgar');
- });
- });
- /***/ }),
- /* 214 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('SelectEditor', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should display select', function () {
- handsontable({
- columns: [{
- editor: 'select'
- }]
- });
- selectCell(0, 0);
- var editor = $('.htSelectEditor');
- expect(editor.length).toEqual(1);
- expect(editor.is('select')).toBe(true);
- expect(editor.is(':visible')).toBe(false);
- keyDown('enter');
- expect(editor.is(':visible')).toBe(true);
- expect(editor.offset()).toEqual($(getCell(0, 0)).offset());
- });
- it('should display and correctly reposition select editor while scrolling', function (done) {
- var hot = handsontable({
- width: 200,
- height: 200,
- data: Handsontable.helper.createSpreadsheetData(100, 100),
- columns: [{
- editor: 'select'
- }, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { editor: 'select' }]
- });
- var mainHolder = hot.view.wt.wtTable.holder;
- selectCell(0, 0);
- keyDown('enter');
- keyUp('enter');
- mainHolder.scrollTop = 10;
- mainHolder.scrollLeft = 20;
- var editor = $('.htSelectEditor');
- setTimeout(function () {
- expect(editor.css('top')).toEqual('-10px');
- expect(editor.css('left')).toEqual('-20px');
- done();
- }, 200);
- });
- it('should populate select with given options (array)', function () {
- var options = ['Misubishi', 'Chevrolet', 'Lamborgini'];
- handsontable({
- columns: [{
- editor: 'select',
- selectOptions: options
- }]
- });
- selectCell(0, 0);
- var editor = $('.htSelectEditor');
- keyDown('enter');
- var $options = editor.find('option');
- expect($options.length).toEqual(options.length);
- expect($options.eq(0).val()).toMatch(options[0]);
- expect($options.eq(0).html()).toMatch(options[0]);
- expect($options.eq(1).val()).toMatch(options[1]);
- expect($options.eq(1).html()).toMatch(options[1]);
- expect($options.eq(2).val()).toMatch(options[2]);
- expect($options.eq(2).html()).toMatch(options[2]);
- });
- it('should populate select with given options (object)', function () {
- var options = {
- mit: 'Misubishi',
- che: 'Chevrolet',
- lam: 'Lamborgini'
- };
- handsontable({
- columns: [{
- editor: 'select',
- selectOptions: options
- }]
- });
- selectCell(0, 0);
- var editor = $('.htSelectEditor');
- keyDown('enter');
- var $options = editor.find('option');
- expect($options.eq(0).val()).toMatch('mit');
- expect($options.eq(0).html()).toMatch(options.mit);
- expect($options.eq(1).val()).toMatch('che');
- expect($options.eq(1).html()).toMatch(options.che);
- expect($options.eq(2).val()).toMatch('lam');
- expect($options.eq(2).html()).toMatch(options.lam);
- });
- it('should populate select with given options (function:array)', function () {
- var options = function options() {
- return ['Misubishi', 'Chevrolet', 'Lamborgini'];
- };
- handsontable({
- columns: [{
- editor: 'select',
- selectOptions: options
- }]
- });
- selectCell(0, 0);
- var editor = $('.htSelectEditor');
- keyDown('enter');
- var $options = editor.find('option');
- expect($options.length).toEqual(options().length);
- expect($options.eq(0).val()).toMatch(options()[0]);
- expect($options.eq(0).html()).toMatch(options()[0]);
- expect($options.eq(1).val()).toMatch(options()[1]);
- expect($options.eq(1).html()).toMatch(options()[1]);
- expect($options.eq(2).val()).toMatch(options()[2]);
- expect($options.eq(2).html()).toMatch(options()[2]);
- });
- it('should populate select with given options (function:object)', function () {
- var options = function options() {
- return {
- mit: 'Misubishi',
- che: 'Chevrolet',
- lam: 'Lamborgini'
- };
- };
- handsontable({
- columns: [{
- editor: 'select',
- selectOptions: options
- }]
- });
- selectCell(0, 0);
- var editor = $('.htSelectEditor');
- keyDown('enter');
- var $options = editor.find('option');
- expect($options.eq(0).val()).toMatch('mit');
- expect($options.eq(0).html()).toMatch(options().mit);
- expect($options.eq(1).val()).toMatch('che');
- expect($options.eq(1).html()).toMatch(options().che);
- expect($options.eq(2).val()).toMatch('lam');
- expect($options.eq(2).html()).toMatch(options().lam);
- });
- it('should mark option matching cell value as selected', function () {
- var options = ['Misubishi', 'Chevrolet', 'Lamborgini'];
- handsontable({
- data: [['Misubishi'], ['Lamborgini'], ['Chevrolet']],
- columns: [{
- editor: 'select',
- selectOptions: options
- }]
- });
- selectCell(0, 0);
- var editor = $('.htSelectEditor');
- keyDown('enter');
- expect(editor.find('option:selected').text()).toEqual(getDataAtCell(0, 0));
- keyDown('enter');
- selectCell(1, 0);
- keyDown('enter');
- expect(editor.find('option:selected').text()).toEqual(getDataAtCell(1, 0));
- keyDown('enter');
- selectCell(2, 0);
- keyDown('enter');
- expect(editor.find('option:selected').text()).toEqual(getDataAtCell(2, 0));
- keyDown('enter');
- });
- it('should not prevent the default event action when select is clicked', function () {
- var options = function options() {
- return ['Misubishi', 'Chevrolet', 'Lamborgini'];
- };
- handsontable({
- columns: [{
- editor: 'select',
- selectOptions: options
- }]
- });
- selectCell(0, 0);
- var editor = $('.htSelectEditor');
- keyDown('enter');
- var select = editor.find('select');
- var selectMouseDownListener = jasmine.createSpy('selectMouseDownListener');
- $('body').on('mousedown', selectMouseDownListener);
- editor.mousedown();
- expect(selectMouseDownListener.calls.count()).toEqual(1);
- var event = selectMouseDownListener.calls.argsFor(0)[0];
- expect(event).toBeDefined();
- expect(event.isDefaultPrevented()).toBe(false);
- });
- });
- /***/ }),
- /* 215 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('TextEditor', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '" style="width: 300px; height: 200px; overflow: hidden;"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should begin editing when enterBeginsEditing equals true', function () {
- handsontable({
- enterBeginsEditing: true,
- editor: 'text'
- });
- selectCell(2, 2);
- keyDown('enter');
- var selection = getSelected();
- expect(selection).toEqual([2, 2, 2, 2]);
- expect(isEditorVisible()).toEqual(true);
- });
- it('should move down after editing', function () {
- handsontable({
- editor: 'text'
- });
- selectCell(2, 2);
- keyDown('enter');
- keyDown('enter');
- var selection = getSelected();
- expect(selection).toEqual([3, 2, 3, 2]);
- });
- it('should move down when enterBeginsEditing equals false', function () {
- handsontable({
- enterBeginsEditing: false
- });
- selectCell(2, 2);
- keyDown('enter');
- var selection = getSelected();
- expect(selection).toEqual([3, 2, 3, 2]);
- expect(isEditorVisible()).toEqual(false);
- });
- it('should render string in textarea', function () {
- handsontable();
- setDataAtCell(2, 2, 'string');
- selectCell(2, 2);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('string');
- });
- it('should render textarea editor in specified size at cell 0, 0 without headers', function (done) {
- var hot = handsontable();
- selectCell(0, 0);
- keyDown('enter');
- setTimeout(function () {
- expect(hot.getActiveEditor().TEXTAREA.style.height).toBe('23px');
- expect(hot.getActiveEditor().TEXTAREA.style.width).toBe('40px');
- done();
- }, 200);
- });
- it('should render textarea editor in specified size at cell 1, 0 without headers', function (done) {
- var hot = handsontable();
- selectCell(1, 1);
- keyDown('enter');
- setTimeout(function () {
- expect(hot.getActiveEditor().TEXTAREA.style.height).toBe('23px');
- done();
- }, 200);
- });
- it('should render textarea editor in specified size at cell 0, 0 with headers', function (done) {
- var hot = handsontable({
- rowHeaders: true,
- colHeaders: true
- });
- selectCell(0, 0);
- keyDown('enter');
- setTimeout(function () {
- expect(hot.getActiveEditor().TEXTAREA.style.height).toBe('23px');
- expect(hot.getActiveEditor().TEXTAREA.style.width).toBe('40px');
- expect(hot.getActiveEditor().textareaParentStyle.top).toBe('26px');
- done();
- }, 200);
- });
- it('should render textarea editor in specified size at cell 0, 0 with headers defined in columns', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetObjectData(10, 10),
- columns: [{
- data: 'prop0',
- title: 'Prop 0'
- }, {
- data: 'prop1',
- title: 'Prop 1'
- }, {
- data: 'prop2',
- title: 'Prop 2'
- }, {
- data: 'prop3',
- title: 'Prop 3'
- }]
- });
- selectCell(0, 0);
- keyDown('enter');
- setTimeout(function () {
- expect(hot.getActiveEditor().TEXTAREA.style.height).toBe('23px');
- expect(parseInt(hot.getActiveEditor().TEXTAREA.style.width, 10)).toBeAroundValue(50, 4);
- expect(hot.getActiveEditor().textareaParentStyle.top).toBe('26px');
- done();
- }, 200);
- });
- it('should hide whole editor when it is higher then header', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(50, 50),
- rowHeaders: true,
- colHeaders: true
- });
- setDataAtCell(2, 2, 'string\nstring\nstring');
- selectCell(2, 2);
- keyDown('enter');
- keyUp('enter');
- var mainHolder = hot.view.wt.wtTable.holder;
- mainHolder.scrollTop = 150;
- mainHolder.scrollLeft = 150;
- setTimeout(function () {
- expect(parseInt(hot.getActiveEditor().textareaParentStyle.top, 10)).toBeAroundValue(-77);
- expect(parseInt(hot.getActiveEditor().textareaParentStyle.left, 10)).toBeAroundValue(-1);
- done();
- }, 200);
- });
- it('should hide editor when quick navigation by click scrollbar was triggered', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(50, 50),
- rowHeaders: true,
- colHeaders: true
- });
- setDataAtCell(2, 2, 'string\nstring\nstring');
- selectCell(2, 2);
- keyDown('enter');
- keyUp('enter');
- hot.scrollViewportTo(49);
- setTimeout(function () {
- expect(hot.getActiveEditor().textareaParentStyle.display).toBe('none');
- done();
- }, 100);
- });
- it('should render textarea editor in specified height (single line)', function (done) {
- var hot = handsontable(),
- editorHeight;
- setDataAtCell(2, 2, 'first line');
- selectCell(2, 2);
- keyDown('enter');
- setTimeout(function () {
- expect(hot.getActiveEditor().TEXTAREA.style.height).toBe('23px');
- done();
- }, 200);
- });
- it('should render textarea editor in specified height (multi line)', function (done) {
- var hot = handsontable(),
- editorHeight;
- setDataAtCell(2, 2, 'first line\n second line\n third line...');
- selectCell(2, 2);
- keyDown('enter');
- setTimeout(function () {
- expect(hot.getActiveEditor().TEXTAREA.style.height).toBe('64px');
- done();
- }, 200);
- });
- it('should render number in textarea', function () {
- handsontable();
- setDataAtCell(2, 2, 13);
- selectCell(2, 2);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('13');
- });
- it('should render boolean true in textarea', function () {
- handsontable();
- setDataAtCell(2, 2, true);
- selectCell(2, 2);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('true');
- });
- it('should render boolean false in textarea', function () {
- handsontable();
- setDataAtCell(2, 2, false);
- selectCell(2, 2);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('false');
- });
- it('should render null in textarea', function () {
- handsontable();
- setDataAtCell(2, 2, null);
- selectCell(2, 2);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('');
- });
- it('should render undefined in textarea', function () {
- handsontable();
- setDataAtCell(2, 2, void 0);
- selectCell(2, 2);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('');
- });
- it('should render nested object value in textarea', function () {
- handsontable({
- data: [{
- name: {
- first: 'Tom',
- last: 'Kowalski',
- obj: {}
- }
- }, {
- name: {
- first: 'John',
- last: 'Cage',
- obj: {
- foo: 'bar'
- }
- }
- }],
- columns: [{
- data: 'name.last'
- }, {
- data: 'name.obj.foo'
- }]
- });
- selectCell(0, 0);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('Kowalski');
- selectCell(1, 1);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('bar');
- });
- it('should render nested object value in textarea after change rows order', function () {
- var hot = handsontable({
- data: [{
- name: {
- first: 'Tom',
- last: 'Kowalski',
- obj: {}
- }
- }, {
- name: {
- first: 'John',
- last: 'Cage',
- obj: {
- foo: 'bar'
- }
- }
- }],
- columns: [{
- data: 'name.last'
- }, {
- data: 'name.obj.foo'
- }],
- manualRowMove: true
- });
- hot.getPlugin('manualRowMove').moveRow(1, 0);
- hot.render();
- selectCell(0, 0);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('Cage');
- keyDown('enter');
- expect(hot.getDataAtCell(0, 0)).toEqual('Cage');
- selectCell(1, 1);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('');
- keyDown('enter');
- expect(hot.getDataAtCell(1, 1)).toEqual('');
- });
- it('should render nested object value in textarea after change columns order', function () {
- var hot = handsontable({
- data: [{
- name: {
- first: 'Tom',
- last: 'Kowalski',
- obj: {}
- }
- }, {
- name: {
- first: 'John',
- last: 'Cage',
- obj: {
- foo: 'bar'
- }
- }
- }],
- columns: [{
- data: 'name.last'
- }, {
- data: 'name.obj.foo'
- }],
- manualColumnMove: true
- });
- hot.getPlugin('manualColumnMove').moveColumn(1, 0);
- hot.render();
- selectCell(0, 0);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('');
- keyDown('enter');
- expect(hot.getDataAtCell(0, 0)).toEqual('');
- selectCell(1, 1);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('Cage');
- keyDown('enter');
- expect(hot.getDataAtCell(1, 1)).toEqual('Cage');
- });
- it('should render array value defined by columns settings in textarea', function () {
- handsontable({
- data: [['', 'Kia'], ['2012', 10], ['2013', 10]],
- columns: [{
- data: '1'
- }, {
- data: '0'
- }]
- });
- selectCell(0, 0);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('Kia');
- selectCell(1, 1);
- keyDown('enter');
- expect(keyProxy().val()).toEqual('2012');
- });
- it('should open editor after hitting F2', function () {
- handsontable();
- selectCell(2, 2);
- var editor = $('.handsontableInput');
- expect(isEditorVisible()).toEqual(false);
- keyDown('f2');
- expect(isEditorVisible()).toEqual(true);
- });
- it('should close editor after hitting ESC', function () {
- handsontable();
- selectCell(2, 2);
- var editor = $('.handsontableInput');
- expect(isEditorVisible()).toEqual(false);
- keyDown('f2');
- expect(isEditorVisible()).toEqual(true);
- keyDown('esc');
- expect(isEditorVisible()).toEqual(false);
- });
- it('should NOT open editor after hitting CapsLock', function () {
- handsontable();
- selectCell(2, 2);
- var editor = $('.handsontableInput');
- expect(isEditorVisible()).toEqual(false);
- keyDown(Handsontable.helper.KEY_CODES.CAPS_LOCK);
- expect(isEditorVisible()).toEqual(false);
- });
- it('should open editor after cancelling edit and beginning it again', function () {
- handsontable();
- selectCell(2, 2);
- expect(isEditorVisible()).toEqual(false);
- keyDown('f2');
- expect(isEditorVisible()).toEqual(true);
- keyDown('esc');
- expect(isEditorVisible()).toEqual(false);
- keyDown('f2');
- expect(isEditorVisible()).toEqual(true);
- });
- it('loadData should not destroy editor', function () {
- handsontable();
- selectCell(2, 2);
- keyDown('f2');
- loadData(getData());
- expect(isEditorVisible()).toEqual(true);
- });
- it('updateSettings should not destroy editor', function () {
- handsontable();
- selectCell(2, 2);
- keyDown('f2');
- updateSettings({
- data: getData()
- });
- expect(isEditorVisible()).toEqual(true);
- });
- it('textarea should have cell dimensions (after render)', function () {
- var data = [['a', 'b'], ['c', 'd']];
- var hot = handsontable({
- data: data,
- minRows: 4,
- minCols: 4,
- minSpareRows: 4,
- minSpareCols: 4,
- enterMoves: false
- });
- selectCell(1, 1);
- var $td = getHtCore().find('tbody tr:eq(1) td:eq(1)');
- var editor = hot.getActiveEditor();
- keyDownUp('enter');
- expect(keyProxy().width()).toEqual($td.width());
- keyDownUp('enter');
- data[1][1] = 'dddddddddddddddddddd';
- render();
- keyDownUp('enter');
- expect(keyProxy().width()).toEqual($td.width());
- });
- it('global shortcuts (like CTRL+A) should be blocked when cell is being edited', function () {
- handsontable();
- selectCell(2, 2);
- keyDownUp('enter');
- keyDown(65, {
- ctrlKey: true
- }); // CTRL+A should NOT select all table when cell is edited
- var selection = getSelected();
- expect(selection).toEqual([2, 2, 2, 2]);
- expect(isEditorVisible()).toEqual(true);
- });
- it('should open editor after double clicking on a cell', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 2)
- });
- var cell = $(getCell(0, 0));
- var clicks = 0;
- window.scrollTo(0, cell.offset().top);
- setTimeout(function () {
- mouseDown(cell);
- mouseUp(cell);
- clicks++;
- }, 0);
- setTimeout(function () {
- mouseDown(cell);
- mouseUp(cell);
- clicks++;
- }, 100);
- setTimeout(function () {
- var editor = hot.getActiveEditor();
- expect(clicks).toBe(2);
- expect(editor.isOpened()).toBe(true);
- expect(editor.isInFullEditMode()).toBe(true);
- done();
- }, 200);
- });
- it('should call editor focus() method after opening an editor', function () {
- var hot = handsontable();
- selectCell(2, 2);
- var editor = hot.getActiveEditor();
- spyOn(editor, 'focus');
- expect(editor.isOpened()).toEqual(false);
- expect(editor.focus).not.toHaveBeenCalled();
- keyDown('f2');
- expect(editor.isOpened()).toEqual(true);
- expect(editor.focus).toHaveBeenCalled();
- });
- it('editor size should not exceed the viewport after text edit', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 5),
- width: 200,
- height: 200
- });
- selectCell(2, 2);
- keyDown('enter');
- expect(isEditorVisible()).toEqual(true);
- document.activeElement.value = 'Very very very very very very very very very very very very very very very very very long text';
- keyDownUp(32); // space - trigger textarea resize
- var $textarea = $(document.activeElement);
- var $wtHider = this.$container.find('.wtHider');
- expect($textarea.offset().left + $textarea.outerWidth()).not.toBeGreaterThan($wtHider.offset().left + this.$container.outerWidth());
- expect($textarea.offset().top + $textarea.outerHeight()).not.toBeGreaterThan($wtHider.offset().top + $wtHider.outerHeight());
- });
- it('should open editor after selecting cell in another table and hitting enter', function () {
- this.$container2 = $('<div id="' + id + '-2"></div>').appendTo('body');
- var hot1 = handsontable();
- var hot2 = handsontable2.call(this);
- this.$container.find('tbody tr:eq(0) td:eq(0)').simulate('mousedown');
- this.$container.find('tbody tr:eq(0) td:eq(0)').simulate('mouseup');
- // Open editor in HOT1
- keyDown('enter');
- var editor = $('.handsontableInputHolder');
- expect(editor.is(':visible')).toBe(true);
- // Close editor in HOT1
- keyDown('enter');
- expect(editor.is(':visible')).toBe(false);
- this.$container2.find('tbody tr:eq(0) td:eq(0)').simulate('mousedown');
- this.$container2.find('tbody tr:eq(0) td:eq(0)').simulate('mouseup');
- expect(hot1.getSelected()).toBeUndefined();
- expect(hot2.getSelected()).toEqual([0, 0, 0, 0]);
- // Open editor in HOT2
- keyDown('enter');
- editor = $('.handsontableInputHolder');
- expect(editor.is(':visible')).toBe(true);
- this.$container2.handsontable('destroy');
- this.$container2.remove();
- function handsontable2(options) {
- var container = this.$container2;
- container.handsontable(options);
- container[0].focus(); // otherwise TextEditor tests do not pass in IE8
- return container.data('handsontable');
- }
- });
- it('should open editor after pressing a printable character', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 3)
- });
- selectCell(0, 0);
- var editorHolder = $('.handsontableInputHolder');
- // var editorInput = editorHolder.find('.handsontableInput');
- expect(editorHolder.is(':visible')).toBe(false);
- // var keyboardEvent = $.Event('keydown', {
- // keyCode: 'a'.charCodeAt(0)
- // });
- // this.$container.trigger(keyboardEvent);
- this.$container.simulate('keydown', {
- keyCode: 'a'.charCodeAt(0)
- });
- expect(editorHolder.is(':visible')).toBe(true);
- });
- it('should open editor after pressing a printable character with shift key', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 3)
- });
- selectCell(0, 0);
- var editorHolder = $('.handsontableInputHolder');
- expect(editorHolder.is(':visible')).toBe(false);
- /**
- * To reliably mimic SHIFT+SOME_KEY combination we have to trigger two events.
- * First we need to trigger keydown event with SHIFT keyCode (16)
- * and then trigger a keydown event with keyCode of SOME_KEY and shiftKey property set to true
- */
- // var shiftKeyboardEvent = $.Event('keydown', {
- // keyCode: 16, //shift
- // shiftKey: true
- // });
- //
- // var keyboardEvent = $.Event('keydown', {
- // keyCode: 'a'.charCodeAt(0),
- // shiftKey: true
- // });
- this.$container.simulate('keydown', {
- keyCode: 'a'.charCodeAt(0),
- shiftKey: true
- });
- // this.$container.trigger(shiftKeyboardEvent);
- // this.$container.trigger(keyboardEvent);
- expect(editorHolder.is(':visible')).toBe(true);
- });
- it('should be able to open editor after clearing cell data with DELETE', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 3)
- });
- selectCell(0, 0);
- var editorHolder = $('.handsontableInputHolder');
- expect(editorHolder.is(':visible')).toBe(false);
- this.$container.simulate('keydown', {
- keyCode: 46
- });
- this.$container.simulate('keydown', {
- keyCode: 'a'.charCodeAt(0)
- });
- expect(editorHolder.is(':visible')).toBe(true);
- });
- it('should be able to open editor after clearing cell data with BACKSPACE', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 3)
- });
- selectCell(0, 0);
- var editorHolder = $('.handsontableInputHolder');
- expect(editorHolder.is(':visible')).toBe(false);
- this.$container.simulate('keydown', {
- keyCode: 8 // backspace
- });
- this.$container.simulate('keydown', {
- keyCode: 'a'.charCodeAt(0)
- });
- expect(editorHolder.is(':visible')).toBe(true);
- });
- it('should scroll editor to a cell, if trying to edit cell that is outside of the viewport', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(20, 20),
- width: 100,
- height: 50
- });
- selectCell(0, 0);
- expect(getCell(0, 0)).not.toBeNull();
- expect(getCell(19, 19)).toBeNull();
- hot.view.scrollViewport({ row: 19, col: 19 });
- hot.render();
- expect(getCell(0, 0)).toBeNull();
- expect(getCell(19, 19)).not.toBeNull();
- keyDown('enter');
- expect(getCell(0, 0)).not.toBeNull();
- expect(getCell(19, 19)).toBeNull();
- });
- it('should open empty editor after clearing cell value width BACKSPACE', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4)
- });
- expect(getDataAtCell(0, 0)).toEqual('A1');
- selectCell(0, 0);
- keyDown(Handsontable.helper.KEY_CODES.BACKSPACE);
- expect(getDataAtCell(0, 0)).toEqual('');
- expect(hot.getActiveEditor().isOpened()).toBe(false);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- expect(hot.getActiveEditor().isOpened()).toBe(true);
- expect(hot.getActiveEditor().getValue()).toEqual('');
- });
- it('should open empty editor after clearing cell value width DELETE', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4)
- });
- expect(getDataAtCell(0, 0)).toEqual('A1');
- selectCell(0, 0);
- keyDown(Handsontable.helper.KEY_CODES.DELETE);
- expect(getDataAtCell(0, 0)).toEqual('');
- expect(hot.getActiveEditor().isOpened()).toBe(false);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- expect(hot.getActiveEditor().isOpened()).toBe(true);
- expect(hot.getActiveEditor().getValue()).toEqual('');
- });
- it('should not open editor after hitting ALT (#1239)', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4)
- });
- expect(getDataAtCell(0, 0)).toEqual('A1');
- selectCell(0, 0);
- keyDown(Handsontable.helper.KEY_CODES.ALT);
- expect(hot.getActiveEditor().isOpened()).toBe(false);
- });
- it('should open editor at the same coordinates as the edited cell', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(16, 8),
- fixedColumnsLeft: 2,
- fixedRowsTop: 2
- });
- var mainHolder = hot.view.wt.wtTable.holder;
- // corner
- selectCell(1, 1);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- var $inputHolder = $('.handsontableInputHolder');
- expect($(getCell(1, 1)).offset().left).toEqual($inputHolder.offset().left + 1);
- expect($(getCell(1, 1)).offset().top).toEqual($inputHolder.offset().top + 1);
- // top
- selectCell(1, 4);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- expect($(getCell(1, 4)).offset().left).toEqual($inputHolder.offset().left + 1);
- expect($(getCell(1, 4)).offset().top).toEqual($inputHolder.offset().top + 1);
- // left
- selectCell(4, 1);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- expect($(getCell(4, 1)).offset().left).toEqual($inputHolder.offset().left + 1);
- expect($(getCell(4, 1)).offset().top).toEqual($inputHolder.offset().top + 1);
- // non-fixed
- selectCell(4, 4);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- expect($(getCell(4, 4)).offset().left).toEqual($inputHolder.offset().left + 1);
- expect($(getCell(4, 4)).offset().top).toEqual($inputHolder.offset().top + 1);
- $(mainHolder).scrollTop(1000);
- });
- it('should open editor at the same coordinates as the edited cell after the table had been scrolled (corner)', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(16, 8),
- fixedColumnsLeft: 2,
- fixedRowsTop: 2
- });
- var $holder = $(hot.view.wt.wtTable.holder);
- $holder.scrollTop(100);
- $holder.scrollLeft(100);
- hot.render();
- // corner
- selectCell(1, 1);
- var currentCell = hot.getCell(1, 1, true);
- var left = $(currentCell).offset().left;
- var top = $(currentCell).offset().top;
- var $inputHolder = $('.handsontableInputHolder');
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- expect(left).toEqual($inputHolder.offset().left + 1);
- expect(top).toEqual($inputHolder.offset().top + 1);
- });
- it('should open editor at the same coordinates as the edited cell after the table had been scrolled (top)', function (done) {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(50, 50),
- fixedColumnsLeft: 2,
- fixedRowsTop: 2
- });
- var $holder = $(hot.view.wt.wtTable.holder);
- $holder[0].scrollTop = 500;
- setTimeout(function () {
- $holder[0].scrollLeft = 500;
- }, 100);
- setTimeout(function () {
- // top
- selectCell(1, 6);
- }, 200);
- setTimeout(function () {
- var currentCell = hot.getCell(1, 6, true);
- var left = $(currentCell).offset().left;
- var top = $(currentCell).offset().top;
- var $inputHolder = $('.handsontableInputHolder');
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- expect(left).toEqual($inputHolder.offset().left + 1);
- expect(top).toEqual($inputHolder.offset().top + 1);
- done();
- }, 300);
- });
- it('should open editor at the same coordinates as the edited cell after the table had been scrolled (left)', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(50, 50),
- fixedColumnsLeft: 2,
- fixedRowsTop: 2
- });
- var $holder = $(hot.view.wt.wtTable.holder);
- $holder.scrollTop(500);
- $holder.scrollLeft(500);
- hot.render();
- // left
- selectCell(6, 1);
- var currentCell = hot.getCell(6, 1, true);
- var left = $(currentCell).offset().left;
- var top = $(currentCell).offset().top;
- var $inputHolder = $('.handsontableInputHolder');
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- expect(left).toEqual($inputHolder.offset().left + 1);
- expect(top).toEqual($inputHolder.offset().top + 1);
- });
- it('should open editor at the same coordinates as the edited cell after the table had been scrolled (non-fixed)', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(50, 50),
- fixedColumnsLeft: 2,
- fixedRowsTop: 2
- });
- var $holder = $(hot.view.wt.wtTable.holder);
- $holder.scrollTop(500);
- $holder.scrollLeft(500);
- hot.render();
- // non-fixed
- selectCell(7, 7);
- var currentCell = hot.getCell(7, 7, true);
- var left = $(currentCell).offset().left;
- var top = $(currentCell).offset().top;
- var $inputHolder = $('.handsontableInputHolder');
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- expect(left).toEqual($inputHolder.offset().left + 1);
- expect(top).toEqual($inputHolder.offset().top + 1);
- });
- it('should display editor with the proper size, when the edited column is beyond the tables container', function () {
- this.$container.css('overflow', '');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 9)
- });
- selectCell(0, 7);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- expect(Handsontable.dom.outerWidth(hot.getActiveEditor().TEXTAREA)).toBeAroundValue(Handsontable.dom.outerWidth(hot.getCell(0, 7)));
- });
- it('should display editor with the proper size, when editing a last row after the table is scrolled to the bottom', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 8),
- minSpareRows: 1,
- height: 100
- });
- selectCell(0, 2);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- var regularHeight = Handsontable.dom.outerHeight(hot.getActiveEditor().TEXTAREA);
- selectCell(3, 2);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- // lame check, needs investigating why sometimes it leaves 2px error
- if (Handsontable.dom.outerHeight(hot.getActiveEditor().TEXTAREA) == regularHeight) {
- expect(Handsontable.dom.outerHeight(hot.getActiveEditor().TEXTAREA)).toEqual(regularHeight);
- } else {
- expect(Handsontable.dom.outerHeight(hot.getActiveEditor().TEXTAREA)).toEqual(regularHeight - 2);
- }
- });
- it('should render the text without trimming out the whitespace, if trimWhitespace is set to false', function () {
- this.$container.css('overflow', '');
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(3, 9),
- trimWhitespace: false
- });
- selectCell(0, 2);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- hot.getActiveEditor().TEXTAREA.value = ' test of whitespace ';
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- expect(getDataAtCell(0, 2).length).toEqual(37);
- });
- it('should insert new line on caret position when pressing ALT + ENTER', function () {
- var data = [['Maserati', 'Mazda'], ['Honda', 'Mini']];
- var hot = handsontable({
- data: data
- });
- selectCell(0, 0);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- var $editorInput = $('.handsontableInput');
- Handsontable.dom.setCaretPosition($editorInput[0], 2);
- $editorInput.simulate('keydown', {
- altKey: true,
- keyCode: Handsontable.helper.KEY_CODES.ENTER
- });
- expect(hot.getActiveEditor().TEXTAREA.value).toEqual('Ma\nserati');
- });
- it('should be displayed and resized properly, so it doesn\'t exceed the viewport dimensions', function () {
- var data = [['', '', '', '', ''], ['', 'The Dude abides. I don\'t know about you but I take comfort in that. It\'s good knowin\' he\'s out there. The ' + 'Dude. Takin\' \'er easy for all us sinners. Shoosh. I sure hope he makes the finals.', '', '', ''], ['', '', '', '', '']];
- var hot = handsontable({
- data: data,
- colWidths: 40,
- width: 300,
- height: 200,
- minSpareRows: 20,
- minSpareCols: 20
- });
- selectCell(1, 1);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- var $editorInput = $('.handsontableInput');
- var $editedCell = $(hot.getCell(1, 1));
- expect($editorInput.outerWidth()).toEqual(hot.view.wt.wtTable.holder.clientWidth - $editedCell.position().left + 1);
- hot.view.wt.scrollHorizontal(3);
- hot.render();
- expect($editorInput.width() + $editorInput.offset().left).toBeLessThan(hot.view.wt.wtTable.holder.clientWidth);
- });
- it('should resize editor to properly size after focus', function (done) {
- var data = [['', '', '', '', '', '', '', '', '', '', ''], ['', '', '', '', '', '', '', '', '', '', ''], ['', '', '', '', '', '', '', '', '', '', ''], ['', '', '', '', '', '', '', '', '', '', ''], ['', '', '', '', '', '', '', '', '', '', 'sadiasdoadoajdoasjdoij doi ajdoiasjdasoidasoid'], ['', '', '', '', '', '', '', '', '', '', ''], ['', '', '', '', '', '', '', '', '', '', ''], ['', '', '', '', '', '', '', '', '', '', ''], ['', '', '', '', '', '', '', '', '', '', ''], ['', '', '', '', '', '', '', '', '', '', '']];
- var hot = handsontable({
- data: data,
- colWidths: 40,
- rowHeights: 25,
- width: 500,
- height: 220
- });
- selectCell(4, 10);
- keyDown(Handsontable.helper.KEY_CODES.ENTER);
- var $editorInput = $('.handsontableInput');
- setTimeout(function () {
- expect([105, 119]).toEqual(jasmine.arrayContaining([$editorInput.height()]));
- done();
- }, 150);
- });
- });
- /***/ }),
- /* 216 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- __webpack_require__(85);
- __webpack_require__(102);
- __webpack_require__(111);
- __webpack_require__(112);
- __webpack_require__(96);
- __webpack_require__(110);
- __webpack_require__(93);
- __webpack_require__(94);
- __webpack_require__(95);
- __webpack_require__(84);
- __webpack_require__(107);
- __webpack_require__(105);
- __webpack_require__(103);
- __webpack_require__(108);
- __webpack_require__(109);
- __webpack_require__(104);
- __webpack_require__(106);
- __webpack_require__(97);
- __webpack_require__(98);
- __webpack_require__(99);
- __webpack_require__(101);
- __webpack_require__(100);
- __webpack_require__(82);
- __webpack_require__(83);
- __webpack_require__(78);
- __webpack_require__(81);
- __webpack_require__(80);
- __webpack_require__(79);
- __webpack_require__(51);
- __webpack_require__(87);
- __webpack_require__(88);
- __webpack_require__(90);
- __webpack_require__(89);
- __webpack_require__(86);
- __webpack_require__(92);
- __webpack_require__(91);
- __webpack_require__(113);
- __webpack_require__(116);
- __webpack_require__(114);
- __webpack_require__(115);
- __webpack_require__(118);
- __webpack_require__(117);
- __webpack_require__(120);
- __webpack_require__(119);
- __webpack_require__(122);
- __webpack_require__(121).install();
- var regExp = new RegExp( false ? __ENV_ARGS__.testPathPattern : '.*', 'i');
- [__webpack_require__(124), __webpack_require__(123)].forEach(function (req) {
- req.keys().forEach(function (key) {
- if (regExp.test(key)) {
- req(key);
- }
- });
- });
- __webpack_require__(75);
- /***/ }),
- /* 217 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('Public API', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('Plugins', function () {
- it('should expose static method for registering external plugins', function () {
- expect(Handsontable.plugins.registerPlugin).toBeFunction();
- });
- it('should expose BasePlugin class', function () {
- expect(Handsontable.plugins.BasePlugin).toBeFunction();
- });
- it('should expose all registered plugin classes', function () {
- expect(Handsontable.plugins.AutoColumnSize).toBeFunction();
- expect(Handsontable.plugins.AutoRowSize).toBeFunction();
- expect(Handsontable.plugins.ColumnSorting).toBeFunction();
- expect(Handsontable.plugins.Comments).toBeFunction();
- expect(Handsontable.plugins.ContextMenu).toBeFunction();
- expect(Handsontable.plugins.ContextMenuCopyPaste).toBeFunction();
- expect(Handsontable.plugins.DragToScroll).toBeFunction();
- expect(Handsontable.plugins.ManualColumnFreeze).toBeFunction();
- expect(Handsontable.plugins.ManualColumnResize).toBeFunction();
- expect(Handsontable.plugins.ManualRowResize).toBeFunction();
- expect(Handsontable.plugins.MultipleSelectionHandles).toBeFunction();
- expect(Handsontable.plugins.TouchScroll).toBeFunction();
- });
- });
- describe('Editors', function () {
- it('should expose static method for registering external editors', function () {
- expect(Handsontable.editors.registerEditor).toBeFunction();
- });
- it('should expose static method for retrieving registered editors', function () {
- expect(Handsontable.editors.getEditor).toBeFunction();
- });
- it('should expose BaseEditor class', function () {
- expect(Handsontable.editors.BaseEditor).toBeFunction();
- });
- it('should expose all registered editor classes', function () {
- expect(Handsontable.editors.AutocompleteEditor).toBeFunction();
- expect(Handsontable.editors.CheckboxEditor).toBeFunction();
- expect(Handsontable.editors.DateEditor).toBeFunction();
- expect(Handsontable.editors.DropdownEditor).toBeFunction();
- expect(Handsontable.editors.HandsontableEditor).toBeFunction();
- expect(Handsontable.editors.MobileEditor).toBeFunction();
- expect(Handsontable.editors.NumericEditor).toBeFunction();
- expect(Handsontable.editors.PasswordEditor).toBeFunction();
- expect(Handsontable.editors.SelectEditor).toBeFunction();
- expect(Handsontable.editors.TextEditor).toBeFunction();
- });
- });
- describe('Renderers', function () {
- it('should expose static method for registering external renderers', function () {
- expect(Handsontable.renderers.registerRenderer).toBeFunction();
- });
- it('should expose static method for retrieving registered renderers', function () {
- expect(Handsontable.renderers.getRenderer).toBeFunction();
- });
- it('should expose BaseRenderer class', function () {
- expect(Handsontable.renderers.BaseRenderer).toBeFunction();
- });
- it('should expose all registered renderer functions', function () {
- expect(Handsontable.renderers.AutocompleteRenderer).toBeFunction();
- expect(Handsontable.renderers.CheckboxRenderer).toBeFunction();
- expect(Handsontable.renderers.HtmlRenderer).toBeFunction();
- expect(Handsontable.renderers.NumericRenderer).toBeFunction();
- expect(Handsontable.renderers.PasswordRenderer).toBeFunction();
- expect(Handsontable.renderers.TextRenderer).toBeFunction();
- });
- });
- describe('Validators', function () {
- it('should expose static method for registering external validators', function () {
- expect(Handsontable.validators.registerValidator).toBeFunction();
- });
- it('should expose static method for retrieving registered validators', function () {
- expect(Handsontable.validators.getValidator).toBeFunction();
- });
- it('should expose all registered validator functions', function () {
- expect(Handsontable.validators.AutocompleteValidator).toBeFunction();
- expect(Handsontable.validators.DateValidator).toBeFunction();
- expect(Handsontable.validators.NumericValidator).toBeFunction();
- expect(Handsontable.validators.TimeValidator).toBeFunction();
- });
- });
- describe('CellTypes', function () {
- it('should expose static method for registering external cell types', function () {
- expect(Handsontable.cellTypes.registerCellType).toBeFunction();
- });
- it('should expose static method for retrieving registered cell types', function () {
- expect(Handsontable.cellTypes.getCellType).toBeFunction();
- });
- it('should expose all registered cell type objects', function () {
- expect(Handsontable.cellTypes.autocomplete.editor).toBe(Handsontable.editors.AutocompleteEditor);
- expect(Handsontable.cellTypes.autocomplete.renderer).toBe(Handsontable.renderers.AutocompleteRenderer);
- expect(Handsontable.cellTypes.autocomplete.validator).toBe(Handsontable.validators.AutocompleteValidator);
- expect(Handsontable.cellTypes.checkbox.editor).toBe(Handsontable.editors.CheckboxEditor);
- expect(Handsontable.cellTypes.checkbox.renderer).toBe(Handsontable.renderers.CheckboxRenderer);
- expect(Handsontable.cellTypes.checkbox.validator).not.toBeDefined();
- expect(Handsontable.cellTypes.date.editor).toBe(Handsontable.editors.DateEditor);
- expect(Handsontable.cellTypes.date.renderer).toBe(Handsontable.renderers.AutocompleteRenderer);
- expect(Handsontable.cellTypes.date.validator).toBe(Handsontable.validators.DateValidator);
- expect(Handsontable.cellTypes.dropdown.editor).toBe(Handsontable.editors.DropdownEditor);
- expect(Handsontable.cellTypes.dropdown.renderer).toBe(Handsontable.renderers.AutocompleteRenderer);
- expect(Handsontable.cellTypes.dropdown.validator).toBe(Handsontable.validators.AutocompleteValidator);
- expect(Handsontable.cellTypes.handsontable.editor).toBe(Handsontable.editors.HandsontableEditor);
- expect(Handsontable.cellTypes.handsontable.renderer).toBe(Handsontable.renderers.AutocompleteRenderer);
- expect(Handsontable.cellTypes.handsontable.validator).not.toBeDefined();
- expect(Handsontable.cellTypes.numeric.editor).toBe(Handsontable.editors.NumericEditor);
- expect(Handsontable.cellTypes.numeric.renderer).toBe(Handsontable.renderers.NumericRenderer);
- expect(Handsontable.cellTypes.numeric.validator).toBe(Handsontable.validators.NumericValidator);
- expect(Handsontable.cellTypes.password.editor).toBe(Handsontable.editors.PasswordEditor);
- expect(Handsontable.cellTypes.password.renderer).toBe(Handsontable.renderers.PasswordRenderer);
- expect(Handsontable.cellTypes.password.validator).not.toBeDefined();
- expect(Handsontable.cellTypes.text.editor).toBe(Handsontable.editors.TextEditor);
- expect(Handsontable.cellTypes.text.renderer).toBe(Handsontable.renderers.TextRenderer);
- expect(Handsontable.cellTypes.text.validator).not.toBeDefined();
- expect(Handsontable.cellTypes.time.editor).toBe(Handsontable.editors.TextEditor);
- expect(Handsontable.cellTypes.time.renderer).toBe(Handsontable.renderers.TextRenderer);
- expect(Handsontable.cellTypes.time.validator).toBe(Handsontable.validators.TimeValidator);
- });
- });
- });
- /***/ }),
- /* 218 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('AutocompleteRenderer', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should contain down arrow glyph', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- type: 'autocomplete',
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 2, 'string');
- setTimeout(function () {
- var html = getCell(2, 2).innerHTML;
- expect(html).toContain('string');
- expect(html).toContain('\u25BC');
- done();
- }, 100);
- });
- it('should open cell editor after clicking on arrow glyph', function () {
- var hot = handsontable({
- type: 'autocomplete'
- });
- selectCell(0, 0);
- expect(hot.getActiveEditor().isOpened()).toBe(false);
- $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mousedown');
- expect(hot.getActiveEditor().isOpened()).toBe(true);
- });
- it('should open cell editor after clicking on arrow glyph, after the table has been destroyed and reinitialized (#1367)', function () {
- var hot = handsontable({
- type: 'autocomplete'
- });
- destroy();
- hot = handsontable({
- type: 'autocomplete'
- });
- selectCell(0, 0);
- expect(hot.getActiveEditor().isOpened()).toBe(false);
- $(getCell(0, 0)).find('.htAutocompleteArrow').simulate('mousedown');
- expect(hot.getActiveEditor().isOpened()).toBe(true);
- });
- });
- /***/ }),
- /* 219 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('CellDecorator', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfObjects = function arrayOfObjects() {
- return [{ id: 1, name: 'Ted', lastName: 'Right' }, { id: 2, name: 'Frank', lastName: 'Honest' }, { id: 3, name: 'Joan', lastName: 'Well' }];
- };
- it('should add an appropriate class name to every cell, if wordWrap=false is set to the whole table', function () {
- var hot = handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id' }, { data: 'name' }, { data: 'lastName' }],
- wordWrap: false
- });
- var cols = countCols(),
- rows = countRows();
- for (var i = 0; i < cols; i++) {
- for (var j = 0; j < rows; j++) {
- expect($(getCell(i, j)).hasClass(hot.getSettings().noWordWrapClassName)).toBe(true);
- }
- }
- });
- it('should add an appropriate class name to every cell in a column, if wordWrap=false is set to the column settings', function () {
- var hot = handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id' }, { data: 'name', wordWrap: false }, { data: 'lastName' }]
- });
- var rows = countRows();
- for (var i = 0; i < rows; i++) {
- expect($(getCell(i, 1)).hasClass(hot.getSettings().noWordWrapClassName)).toBe(true);
- }
- for (var _i = 0; _i < rows; _i++) {
- expect($(getCell(_i, 0)).hasClass(hot.getSettings().noWordWrapClassName)).toBe(false); // no class added to other columns
- expect($(getCell(_i, 2)).hasClass(hot.getSettings().noWordWrapClassName)).toBe(false);
- }
- });
- it('should add an appropriate class to a cell, if wordWrap=false is set to a single cell', function () {
- var hot = handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id' }, { data: 'name' }, { data: 'lastName' }]
- });
- expect($(getCell(1, 1)).hasClass(hot.getSettings().noWordWrapClassName)).toBe(false);
- getCellMeta(1, 1).wordWrap = false;
- render();
- expect($(getCell(1, 1)).hasClass(hot.getSettings().noWordWrapClassName)).toBe(true);
- });
- it('should set "white-space" css parameter to "nowrap" if htNoWrap class is added to a cell', function () {
- var hot = handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id' }, { data: 'name' }, { data: 'lastName' }]
- });
- expect(window.getComputedStyle(getCell(1, 1)).whiteSpace).not.toEqual('nowrap');
- getCellMeta(1, 1).wordWrap = false;
- render();
- expect(window.getComputedStyle(getCell(1, 1)).whiteSpace).toEqual('nowrap');
- });
- it('should not add cell `htInvalid` class when trying to add not proper value', function (done) {
- var hot = handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id' }, { data: 'name' }, { data: 'salary', type: 'numeric', allowInvalid: false }]
- });
- setDataAtCell(0, 2, 'non-numeric value');
- setTimeout(function () {
- expect($(getCell(0, 2)).hasClass(hot.getSettings().invalidCellClassName)).toBe(false);
- done();
- }, 200);
- });
- });
- /***/ }),
- /* 220 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('CheckboxRenderer', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '" style="width: 300px; height: 200px;"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should render values as checkboxes', function () {
- handsontable({
- data: [[true], [false], [true]],
- columns: [{ type: 'checkbox' }]
- });
- expect($(getRenderedValue(0, 0)).is(':checkbox')).toBe(true);
- expect($(getRenderedValue(1, 0)).is(':checkbox')).toBe(true);
- expect($(getRenderedValue(2, 0)).is(':checkbox')).toBe(true);
- });
- it('should render check checkboxes for cell which value is true', function () {
- handsontable({
- data: [[true], [false], [true]],
- columns: [{ type: 'checkbox' }]
- });
- expect($(getRenderedContent(0, 0)).prop('checked')).toBe(true);
- expect($(getRenderedContent(1, 0)).prop('checked')).toBe(false);
- expect($(getRenderedContent(2, 0)).prop('checked')).toBe(true);
- });
- it('should use templates to check appropriate checkboxes', function () {
- handsontable({
- data: [['yes'], ['no'], ['yes']],
- columns: [{
- type: 'checkbox',
- checkedTemplate: 'yes',
- uncheckedTemplate: 'no'
- }]
- });
- expect($(getRenderedContent(0, 0)).prop('checked')).toBe(true);
- expect($(getRenderedContent(1, 0)).prop('checked')).toBe(false);
- expect($(getRenderedContent(2, 0)).prop('checked')).toBe(true);
- });
- it('should select cell after checkbox click', function () {
- var hot = handsontable({
- data: [[true], [false], [true]],
- columns: [{ type: 'checkbox' }]
- });
- hot.selectCell(0, 0);
- this.$container.find(':checkbox').eq(2).simulate('mousedown');
- expect(hot.getSelected()).toEqual([2, 0, 2, 0]);
- });
- it('should select cell after label click', function () {
- var hot = handsontable({
- data: [[true], [false], [true]],
- columns: [{ type: 'checkbox', label: { position: 'before', value: 'Sure? ' } }]
- });
- hot.selectCell(0, 0);
- this.$container.find('td label').eq(2).simulate('mousedown');
- expect(hot.getSelected()).toEqual([2, 0, 2, 0]);
- });
- it('should reverse selection in checkboxes', function () {
- handsontable({
- data: [[true], [false], [true]],
- columns: [{ type: 'checkbox' }]
- });
- this.$container.find(':checkbox').eq(0).simulate('click');
- this.$container.find(':checkbox').eq(1).simulate('click');
- this.$container.find(':checkbox').eq(2).simulate('click');
- expect(getData()).toEqual([[false], [true], [false]]);
- });
- it('shouldn\'t uncheck checkboxes', function () {
- handsontable({
- data: [[true], [true], [true]],
- columns: [{ type: 'checkbox', readOnly: true }]
- });
- this.$container.find(':checkbox').trigger('click');
- expect(getData()).toEqual([[true], [true], [true]]);
- });
- it('should check single box after hitting space', function () {
- handsontable({
- data: [[true], [true], [true]],
- columns: [{ type: 'checkbox' }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- var checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(true);
- expect(checkboxes.eq(1).prop('checked')).toBe(true);
- expect(checkboxes.eq(2).prop('checked')).toBe(true);
- expect(getData()).toEqual([[true], [true], [true]]);
- selectCell(0, 0);
- // this.$container.find(':checkbox').eq(0).simulate('click');
- // this.$container.simulate('keydown',{
- // keyCode: 32
- // });
- keyDown('space');
- checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(false);
- expect(checkboxes.eq(1).prop('checked')).toBe(true);
- expect(checkboxes.eq(2).prop('checked')).toBe(true);
- expect(getData()).toEqual([[false], [true], [true]]);
- expect(afterChangeCallback.calls.count()).toEqual(1);
- expect(afterChangeCallback).toHaveBeenCalledWith([[0, 0, true, false]], 'edit', undefined, undefined, undefined, undefined);
- });
- it('should not check single box after hitting space, if cell is readOnly', function () {
- handsontable({
- data: [[true], [true], [true]],
- columns: [{ type: 'checkbox', readOnly: true }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- var checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(true);
- expect(checkboxes.eq(1).prop('checked')).toBe(true);
- expect(checkboxes.eq(2).prop('checked')).toBe(true);
- expect(getData()).toEqual([[true], [true], [true]]);
- selectCell(0, 0);
- keyDown('space');
- checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(true);
- expect(checkboxes.eq(1).prop('checked')).toBe(true);
- expect(checkboxes.eq(2).prop('checked')).toBe(true);
- expect(getData()).toEqual([[true], [true], [true]]);
- expect(afterChangeCallback).not.toHaveBeenCalled();
- });
- it('should not check single box after hitting space, if last column is readOnly (#3562)', function () {
- handsontable({
- data: [[true, true], [false, false], [true, true]],
- columns: [{ type: 'checkbox' }, { type: 'checkbox', readOnly: true }]
- });
- selectCell(0, 0);
- keyDown('space');
- selectCell(0, 1);
- keyDown('space');
- selectCell(1, 0);
- keyDown('space');
- selectCell(1, 1);
- keyDown('space');
- var checkboxes = this.$container.find(':checkbox');
- // column 0
- expect(checkboxes.eq(0).prop('checked')).toBe(false);
- expect(checkboxes.eq(2).prop('checked')).toBe(true);
- expect(checkboxes.eq(4).prop('checked')).toBe(true);
- // column 1
- expect(checkboxes.eq(1).prop('checked')).toBe(true);
- expect(checkboxes.eq(3).prop('checked')).toBe(false);
- expect(checkboxes.eq(5).prop('checked')).toBe(true);
- expect(getData()).toEqual([[false, true], [true, false], [true, true]]);
- });
- it('should change checkboxes values properly when data contains null or/and undefined', function () {
- handsontable({
- data: [[null], [undefined]],
- colHeaders: true,
- columns: [{
- type: 'checkbox'
- }]
- });
- selectCell(0, 0, 1, 0);
- keyDown('space');
- expect(getDataAtCol(0)).toEqual([true, true]);
- selectCell(0, 0, 1, 0);
- keyDown('space');
- expect(getDataAtCol(0)).toEqual([false, false]);
- });
- it('should change checkboxes values for cells below the viewport (hot initialized by startRows) #4037', function () {
- handsontable({
- startRows: 200,
- colHeaders: true,
- columns: [{
- type: 'checkbox'
- }]
- });
- selectCell(0, 0, 199, 0);
- keyDown('space');
- expect(getDataAtCell(199, 0)).toEqual(true);
- });
- it('should reverse checkboxes state after hitting space, when multiple cells are selected', function () {
- var hot = handsontable({
- data: [[true], [false], [true]],
- columns: [{ type: 'checkbox' }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- var checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(true);
- expect(checkboxes.eq(1).prop('checked')).toBe(false);
- expect(checkboxes.eq(2).prop('checked')).toBe(true);
- expect(getData()).toEqual([[true], [false], [true]]);
- selectCell(0, 0, 2, 0);
- keyDown('space');
- checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(false);
- expect(checkboxes.eq(1).prop('checked')).toBe(true);
- expect(checkboxes.eq(2).prop('checked')).toBe(false);
- expect(getData()).toEqual([[false], [true], [false]]);
- expect(afterChangeCallback.calls.count()).toEqual(1);
- expect(afterChangeCallback).toHaveBeenCalledWith([[0, 0, true, false], [1, 0, false, true], [2, 0, true, false]], 'edit', undefined, undefined, undefined, undefined);
- });
- it('should reverse checkboxes state after hitting space, when multiple cells are selected and selStart > selEnd', function () {
- handsontable({
- data: [[true], [false], [true]],
- columns: [{ type: 'checkbox' }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- var checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(true);
- expect(checkboxes.eq(1).prop('checked')).toBe(false);
- expect(checkboxes.eq(2).prop('checked')).toBe(true);
- expect(getData()).toEqual([[true], [false], [true]]);
- selectCell(2, 0, 0, 0); // selStart = [2,0], selEnd = [0,0]
- keyDown('space');
- checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(false);
- expect(checkboxes.eq(1).prop('checked')).toBe(true);
- expect(checkboxes.eq(2).prop('checked')).toBe(false);
- expect(getData()).toEqual([[false], [true], [false]]);
- expect(afterChangeCallback.calls.count()).toEqual(1);
- expect(afterChangeCallback).toHaveBeenCalledWith([[0, 0, true, false], [1, 0, false, true], [2, 0, true, false]], 'edit', undefined, undefined, undefined, undefined);
- });
- it('should open cell editors of cell that does not have checkboxRenderer (#1199)', function () {
- var hot = handsontable({
- data: [[true, 'B0'], [true, 'B1'], [true, 'B2']],
- columns: [{ type: 'checkbox' }, { type: 'text' }]
- });
- selectCell(0, 1);
- expect(hot.getActiveEditor().isOpened()).toBe(false);
- keyDown('space');
- expect(hot.getActiveEditor().isOpened()).toBe(true);
- });
- it('double click on checkbox cell should invert the value', function () {
- handsontable({
- data: [[true], [false], [true]],
- columns: [{ type: 'checkbox' }]
- });
- selectCell(0, 0);
- mouseDoubleClick(getCell(0, 0));
- expect(getDataAtCell(0, 0)).toBe(false);
- mouseDoubleClick(getCell(0, 0));
- expect(getDataAtCell(0, 0)).toBe(true);
- mouseDoubleClick(getCell(0, 0));
- expect(getDataAtCell(0, 0)).toBe(false);
- });
- it('should change checkbox state from checked to unchecked after hitting ENTER', function () {
- handsontable({
- data: [[true], [true], [true]],
- columns: [{ type: 'checkbox' }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- var checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(true);
- expect(checkboxes.eq(1).prop('checked')).toBe(true);
- expect(checkboxes.eq(2).prop('checked')).toBe(true);
- expect(getData()).toEqual([[true], [true], [true]]);
- selectCell(0, 0);
- keyDown('enter');
- checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(false);
- expect(checkboxes.eq(1).prop('checked')).toBe(true);
- expect(checkboxes.eq(2).prop('checked')).toBe(true);
- expect(getData()).toEqual([[false], [true], [true]]);
- expect(afterChangeCallback.calls.count()).toEqual(1);
- expect(afterChangeCallback).toHaveBeenCalledWith([[0, 0, true, false]], 'edit', undefined, undefined, undefined, undefined);
- });
- it('should change checkbox state from checked to unchecked after hitting ENTER using custom check/uncheck templates', function () {
- handsontable({
- data: [['yes'], ['yes'], ['no']],
- columns: [{
- type: 'checkbox',
- checkedTemplate: 'yes',
- uncheckedTemplate: 'no'
- }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- var checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(true);
- expect(checkboxes.eq(1).prop('checked')).toBe(true);
- expect(checkboxes.eq(2).prop('checked')).toBe(false);
- expect(getData()).toEqual([['yes'], ['yes'], ['no']]);
- selectCell(0, 0);
- keyDown('enter');
- checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(false);
- expect(checkboxes.eq(1).prop('checked')).toBe(true);
- expect(checkboxes.eq(2).prop('checked')).toBe(false);
- expect(getData()).toEqual([['no'], ['yes'], ['no']]);
- expect(afterChangeCallback.calls.count()).toEqual(1);
- expect(afterChangeCallback).toHaveBeenCalledWith([[0, 0, 'yes', 'no']], 'edit', undefined, undefined, undefined, undefined);
- });
- it('should change checkbox state from checked to unchecked after hitting ENTER using custom check/uncheck templates in numeric format', function () {
- handsontable({
- data: [[1], [1], [0]],
- columns: [{
- type: 'checkbox',
- checkedTemplate: 1,
- uncheckedTemplate: 0
- }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- var checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(true);
- expect(checkboxes.eq(1).prop('checked')).toBe(true);
- expect(checkboxes.eq(2).prop('checked')).toBe(false);
- expect(getData()).toEqual([[1], [1], [0]]);
- selectCell(0, 0);
- keyDown('enter');
- checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(false);
- expect(checkboxes.eq(1).prop('checked')).toBe(true);
- expect(checkboxes.eq(2).prop('checked')).toBe(false);
- expect(getData()).toEqual([[0], [1], [0]]);
- expect(afterChangeCallback.calls.count()).toEqual(1);
- expect(afterChangeCallback).toHaveBeenCalledWith([[0, 0, 1, 0]], 'edit', undefined, undefined, undefined, undefined);
- });
- it('should change checkbox state to unchecked after hitting DELETE', function () {
- handsontable({
- data: [[true], [false], [true]],
- columns: [{ type: 'checkbox' }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- var checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(true);
- expect(checkboxes.eq(1).prop('checked')).toBe(false);
- expect(checkboxes.eq(2).prop('checked')).toBe(true);
- expect(getData()).toEqual([[true], [false], [true]]);
- selectCell(0, 0);
- keyDown('delete');
- selectCell(0, 1);
- keyDown('delete');
- checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(false);
- expect(checkboxes.eq(1).prop('checked')).toBe(false);
- expect(checkboxes.eq(2).prop('checked')).toBe(true);
- expect(getData()).toEqual([[false], [false], [true]]);
- expect(afterChangeCallback.calls.count()).toEqual(2);
- expect(afterChangeCallback).toHaveBeenCalledWith([[0, 0, true, false]], 'edit', undefined, undefined, undefined, undefined);
- });
- it('should change checkbox notte to unchecked after hitting BACKSPACE', function () {
- handsontable({
- data: [[true], [false], [true]],
- columns: [{ type: 'checkbox' }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- var checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(true);
- expect(checkboxes.eq(1).prop('checked')).toBe(false);
- expect(checkboxes.eq(2).prop('checked')).toBe(true);
- expect(getData()).toEqual([[true], [false], [true]]);
- selectCell(0, 0);
- keyDown('backspace');
- selectCell(0, 1);
- keyDown('backspace');
- checkboxes = this.$container.find(':checkbox');
- expect(checkboxes.eq(0).prop('checked')).toBe(false);
- expect(checkboxes.eq(1).prop('checked')).toBe(false);
- expect(checkboxes.eq(2).prop('checked')).toBe(true);
- expect(getData()).toEqual([[false], [false], [true]]);
- expect(afterChangeCallback.calls.count()).toEqual(2);
- expect(afterChangeCallback).toHaveBeenCalledWith([[0, 0, true, false]], 'edit', undefined, undefined, undefined, undefined);
- });
- it('should change notkbox state to unchecked after hitting DELETE (from #bad-value# state)', function () {
- handsontable({
- data: [['foo'], ['bar']],
- columns: [{ type: 'checkbox' }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- expect(getDataAtCell(0, 0)).toBe('foo');
- expect(getDataAtCell(1, 0)).toBe('bar');
- selectCell(0, 0);
- keyDown('delete');
- selectCell(1, 0);
- keyDown('delete');
- expect(getDataAtCell(0, 0)).toBe(false);
- expect(getDataAtCell(1, 0)).toBe(false);
- expect(getData()).toEqual([[false], [false]]);
- expect(afterChangeCallback.calls.count()).toEqual(2);
- expect(afterChangeCallback).toHaveBeenCalledWith([[0, 0, 'foo', false]], 'edit', undefined, undefined, undefined, undefined);
- });
- it('should change checkbox note to unchecked after hitting BACKSPACE (from #bad-value# state)', function () {
- handsontable({
- data: [['foo'], ['bar']],
- columns: [{ type: 'checkbox' }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- expect(getDataAtCell(0, 0)).toBe('foo');
- expect(getDataAtCell(1, 0)).toBe('bar');
- selectCell(0, 0);
- keyDown('backspace');
- selectCell(1, 0);
- keyDown('backspace');
- expect(getDataAtCell(0, 0)).toBe(false);
- expect(getDataAtCell(1, 0)).toBe(false);
- expect(getData()).toEqual([[false], [false]]);
- expect(afterChangeCallback.calls.count()).toEqual(2);
- expect(afterChangeCallback).toHaveBeenCalledWith([[0, 0, 'foo', false]], 'edit', undefined, undefined, undefined, undefined);
- });
- it('shouldn\'t change checkbo notate after hitting other keys then DELETE or BACKSPACE (from #bad-value# state)', function () {
- handsontable({
- data: [['foo'], ['bar']],
- columns: [{ type: 'checkbox' }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- expect(getDataAtCell(0, 0)).toBe('foo');
- selectCell(0, 0);
- keyDown('space');
- selectCell(0, 0);
- keyDown('c');
- expect(getDataAtCell(0, 0)).toBe('foo');
- expect(getData()).toEqual([['foo'], ['bar']]);
- expect(afterChangeCallback.calls.count()).toEqual(0);
- });
- it('should not change checkbox state after hitting other keys then SPACE, ENTER, DELETE or BACKSPACE', function () {
- handsontable({
- data: [[false], [true], [true]],
- columns: [{ type: 'checkbox' }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- selectCell(0, 0);
- keyDown('space');
- expect(getDataAtCell(0, 0)).toBe(true);
- selectCell(0, 0);
- keyDown('c');
- expect(getDataAtCell(0, 0)).toBe(true);
- expect(afterChangeCallback.calls.count()).toEqual(1);
- });
- it('should add label on the beginning of a checkbox element', function () {
- handsontable({
- data: [{ checked: true, label: 'myLabel' }, { checked: false, label: 'myLabel' }],
- columns: [{ type: 'checkbox', data: 'checked', label: { position: 'before', property: 'label' } }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- selectCell(0, 0);
- keyDown('space');
- expect(getDataAtCell(0, 0)).toBe(false);
- expect(getDataAtCell(1, 0)).toBe(false);
- expect(afterChangeCallback.calls.count()).toEqual(1);
- expect(getCell(0, 0).querySelector('label').firstChild.textContent).toEqual('myLabel');
- });
- it('should add label on the end of a checkbox element', function () {
- handsontable({
- data: [{ checked: true, label: 'myLabel' }, { checked: false, label: 'myLabel' }],
- columns: [{ type: 'checkbox', data: 'checked', label: { position: 'after', property: 'label' } }]
- });
- var afterChangeCallback = jasmine.createSpy('afterChangeCallback');
- addHook('afterChange', afterChangeCallback);
- selectCell(0, 0);
- keyDown('space');
- expect(getDataAtCell(0, 0)).toBe(false);
- expect(getDataAtCell(1, 0)).toBe(false);
- expect(afterChangeCallback.calls.count()).toEqual(1);
- expect(getCell(0, 0).querySelector('label').lastChild.textContent).toEqual('myLabel');
- });
- it('should not add label when value is incorrect (#bad-value)', function () {
- handsontable({
- data: [{ checked: 1, label: 'myLabel' }, { checked: 0, label: 'myLabel' }],
- columns: [{ type: 'checkbox', data: 'checked', label: { position: 'after', property: 'label' } }]
- });
- expect(getCell(0, 0).querySelector('label')).toBe(null);
- });
- it('by default should add label on the end of a checkbox element', function () {
- handsontable({
- data: [{ checked: true, label: { test: 'Baz' } }, { checked: false, label: { test: 'Baz' } }],
- columns: [{ type: 'checkbox', data: 'checked', label: { property: 'label.test' } }]
- });
- expect(getCell(0, 0).querySelector('label').lastChild.textContent).toEqual('Baz');
- });
- it('should add label with text filled from `value` label setting (passed as string)', function () {
- handsontable({
- data: [{ checked: true }, { checked: false }],
- columns: [{ type: 'checkbox', data: 'checked', label: { value: 'myLabel' } }]
- });
- expect(getCell(0, 0).querySelector('label').lastChild.textContent).toEqual('myLabel');
- });
- it('should add label with text filled from `value` label setting (passed as function)', function () {
- var labelFunction = jasmine.createSpy();
- labelFunction.and.returnValue('myLabel');
- handsontable({
- autoRowSize: false,
- autoColumnSize: false,
- data: [{ checked: true }, { checked: false }],
- columns: [{ type: 'checkbox', data: 'checked', label: { value: labelFunction } }]
- });
- expect(labelFunction.calls.count()).toBe(2);
- expect(labelFunction.calls.argsFor(0)).toEqual([0, 0, 'checked', true]);
- expect(labelFunction.calls.argsFor(1)).toEqual([1, 0, 'checked', false]);
- expect(getCell(0, 0).querySelector('label').lastChild.textContent).toEqual('myLabel');
- });
- describe('CheckboxRenderer with ContextMenu', function () {
- it('should add class name `htRight` after set align in contextMenu', function (done) {
- handsontable({
- startRows: 1,
- startCols: 1,
- contextMenu: ['alignment'],
- cells: function cells() {
- return {
- type: 'checkbox'
- };
- },
- height: 100
- });
- selectCell(0, 0);
- contextMenu();
- var menu = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator');
- menu.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + menu.text()).find('tbody td').eq(2);
- contextSubMenu.simulate('mousedown');
- contextSubMenu.simulate('mouseup');
- expect($('.handsontable.ht_master .htRight').length).toBe(1);
- done();
- }, 500);
- });
- });
- });
- /***/ }),
- /* 221 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('HTMLRenderer', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '" style="width: 300px; height: 200px;"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should not fill empty rows with null values', function () {
- handsontable({
- data: [['a', 'b', 'c', 'd', 'e', 'f']],
- colHeaders: true,
- rowHeaders: true,
- minSpareRows: 5,
- renderer: 'html'
- });
- expect($('.handsontable table tr:last-child td:eq(0)').html()).toEqual('');
- expect($('.handsontable table tr:last-child td:eq(1)').html()).toEqual('');
- expect($('.handsontable table tr:last-child td:eq(2)').html()).toEqual('');
- expect($('.handsontable table tr:last-child td:eq(3)').html()).toEqual('');
- expect($('.handsontable table tr:last-child td:eq(4)').html()).toEqual('');
- expect($('.handsontable table tr:last-child td:eq(5)').html()).toEqual('');
- });
- });
- /***/ }),
- /* 222 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('renderers', function () {
- var id = 'testContainer';
- var _Handsontable$rendere = Handsontable.renderers,
- registerRenderer = _Handsontable$rendere.registerRenderer,
- getRenderer = _Handsontable$rendere.getRenderer;
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should register custom renderer', function () {
- registerRenderer('myRenderer', function (hot, td, row, col, prop, value, cellProperties) {
- td.innerHTML = '--' + value + '--';
- });
- var hot = handsontable({
- data: [[1, 6, 10]],
- columns: [{
- renderer: 'myRenderer'
- }]
- });
- expect(getCell(0, 0).innerHTML).toBe('--1--');
- });
- it('should retrieve predefined renderers by its names', function () {
- expect(getRenderer('autocomplete')).toBeFunction();
- expect(getRenderer('base')).toBeFunction();
- expect(getRenderer('checkbox')).toBeFunction();
- expect(getRenderer('html')).toBeFunction();
- expect(getRenderer('numeric')).toBeFunction();
- expect(getRenderer('password')).toBeFunction();
- expect(getRenderer('text')).toBeFunction();
- });
- it('should retrieve custom renderer by its names', function () {
- var spy = jasmine.createSpy();
- registerRenderer('myRenderer', spy);
- getRenderer('myRenderer')(1, 2, 3, 4, 5, 6);
- expect(spy).toHaveBeenCalledWith(1, 2, 3, 4, 5, 6);
- });
- });
- /***/ }),
- /* 223 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('NumericRenderer', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should render formatted number', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- cells: function cells() {
- return {
- type: 'numeric',
- format: '$0,0.00'
- };
- },
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 2, '1000.234');
- setTimeout(function () {
- expect(getCell(2, 2).innerHTML).toEqual('$1,000.23');
- done();
- }, 200);
- });
- it('should render signed number', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- cells: function cells() {
- return {
- type: 'numeric',
- format: '$0,0.00'
- };
- },
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 2, '-1000.234');
- setTimeout(function () {
- expect(getCell(2, 2).innerHTML).toEqual('-$1,000.23');
- done();
- }, 200);
- });
- it('should try to render string as numeral', function (done) {
- handsontable({
- cells: function cells() {
- return {
- type: 'numeric',
- format: '$0,0.00'
- };
- }
- });
- setDataAtCell(2, 2, '123 simple test');
- setTimeout(function () {
- expect(getCell(2, 2).innerHTML).toEqual('$123.00');
- done();
- }, 100);
- });
- it('should add class names `htNumeric` and `htRight` to the cell if it renders a number', function () {
- var DIV = document.createElement('DIV');
- var instance = new Handsontable(DIV, {});
- var TD = document.createElement('TD');
- TD.className = 'someClass';
- Handsontable.renderers.NumericRenderer(instance, TD, 0, 0, 0, 123, {});
- expect(TD.className).toEqual('someClass htRight htNumeric');
- instance.destroy();
- });
- it('should add class names `htNumeric` and `htRight` to the cell if it renders a numeric string', function () {
- var DIV = document.createElement('DIV');
- var instance = new Handsontable(DIV, {});
- var TD = document.createElement('TD');
- TD.className = 'someClass';
- Handsontable.renderers.NumericRenderer(instance, TD, 0, 0, 0, '123', {});
- expect(TD.className).toEqual('someClass htRight htNumeric');
- instance.destroy();
- });
- it('should not add class name `htNumeric` to the cell if it renders a text', function () {
- var DIV = document.createElement('DIV');
- var instance = new Handsontable(DIV, {});
- var TD = document.createElement('TD');
- TD.className = 'someClass';
- Handsontable.renderers.NumericRenderer(instance, TD, 0, 0, 0, 'abc', {});
- expect(TD.className).toEqual('someClass');
- instance.destroy();
- });
- it('should add class name `htDimmed` to a read only cell', function () {
- var DIV = document.createElement('DIV');
- var instance = new Handsontable(DIV, {});
- var TD = document.createElement('TD');
- Handsontable.renderers.NumericRenderer(instance, TD, 0, 0, 0, 123, { readOnly: true, readOnlyCellClassName: 'htDimmed' });
- expect(TD.className).toContain('htDimmed');
- instance.destroy();
- });
- describe('NumericRenderer with ContextMenu', function () {
- it('should change class name from default `htRight` to `htLeft` after set align in contextMenu', function (done) {
- handsontable({
- startRows: 1,
- startCols: 1,
- contextMenu: ['alignment'],
- cells: function cells() {
- return {
- type: 'numeric',
- format: '$0,0.00'
- };
- },
- height: 100
- });
- setDataAtCell(0, 0, '1000');
- selectCell(0, 0);
- contextMenu();
- var menu = $('.htContextMenu .ht_master .htCore').find('tbody td').not('.htSeparator');
- menu.simulate('mouseover');
- setTimeout(function () {
- var contextSubMenu = $('.htContextMenuSub_' + menu.text()).find('tbody td').eq(0);
- contextSubMenu.simulate('mousedown');
- contextSubMenu.simulate('mouseup');
- expect($('.handsontable.ht_master .htLeft:not(.htRight)').length).toBe(1);
- done();
- }, 500);
- });
- });
- });
- /***/ }),
- /* 224 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('passwordRenderer', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should render strings as a sequence of asterisks', function () {
- handsontable({
- data: [['Joe'], ['Timothy'], ['Margaret'], ['Jerry']],
- columns: [{
- renderer: Handsontable.renderers.PasswordRenderer
- }]
- });
- expect(getRenderedValue(0, 0)).toMatch(/^[*]+$/ig);
- expect(getRenderedValue(1, 0)).toMatch(/^[*]+$/ig);
- expect(getRenderedValue(2, 0)).toMatch(/^[*]+$/ig);
- expect(getRenderedValue(3, 0)).toMatch(/^[*]+$/ig);
- });
- it('should render numbers as a sequence of asterisks ', function () {
- handsontable({
- data: [[1], [1234], [9090], [0]],
- columns: [{
- renderer: Handsontable.renderers.PasswordRenderer
- }]
- });
- expect(getRenderedValue(0, 0)).toMatch(/^[*]+$/ig);
- expect(getRenderedValue(1, 0)).toMatch(/^[*]+$/ig);
- expect(getRenderedValue(2, 0)).toMatch(/^[*]+$/ig);
- expect(getRenderedValue(3, 0)).toMatch(/^[*]+$/ig);
- });
- it('should be possible to set passwordRenderer with column \'type\' parameter', function () {
- handsontable({
- data: [['Joe'], ['Timothy'], ['Margaret'], ['Jerry']],
- columns: [{
- type: 'password'
- }]
- });
- expect(getRenderedValue(0, 0)).toMatch(/^[*]+$/ig);
- expect(getRenderedValue(1, 0)).toMatch(/^[*]+$/ig);
- expect(getRenderedValue(2, 0)).toMatch(/^[*]+$/ig);
- expect(getRenderedValue(3, 0)).toMatch(/^[*]+$/ig);
- });
- it('should be possible to set passwordRenderer using alias \'password\'', function () {
- handsontable({
- data: [['Joe'], ['Timothy'], ['Margaret'], ['Jerry']],
- columns: [{
- renderer: 'password'
- }]
- });
- expect(getRenderedValue(0, 0)).toMatch(/^[*]+$/ig);
- expect(getRenderedValue(1, 0)).toMatch(/^[*]+$/ig);
- expect(getRenderedValue(2, 0)).toMatch(/^[*]+$/ig);
- expect(getRenderedValue(3, 0)).toMatch(/^[*]+$/ig);
- });
- it('should render strings as a sequence of asterisks, of width matching the original value width', function () {
- handsontable({
- data: [['Joe'], ['Timothy'], ['Margaret'], ['Jerry']],
- columns: [{
- renderer: Handsontable.renderers.PasswordRenderer
- }]
- });
- expect(getRenderedValue(0, 0).length).toEqual(getDataAtCell(0, 0).length);
- expect(getRenderedValue(1, 0).length).toEqual(getDataAtCell(1, 0).length);
- expect(getRenderedValue(2, 0).length).toEqual(getDataAtCell(2, 0).length);
- expect(getRenderedValue(3, 0).length).toEqual(getDataAtCell(3, 0).length);
- });
- it('should render strings as a sequence of asterisks, of fixed width', function () {
- handsontable({
- data: [['Joe'], ['Timothy'], ['Margaret'], ['Jerry']],
- columns: [{
- renderer: Handsontable.renderers.PasswordRenderer,
- hashLength: 10
- }]
- });
- expect(getRenderedValue(0, 0).length).toEqual(10);
- expect(getRenderedValue(1, 0).length).toEqual(10);
- expect(getRenderedValue(2, 0).length).toEqual(10);
- expect(getRenderedValue(3, 0).length).toEqual(10);
- });
- it('should render strings as a sequence of custom symbols', function () {
- handsontable({
- data: [[1, 'Joe'], [2, 'Timothy'], [3, 'Margaret'], [4, 'Jerry']],
- columns: [{
- renderer: Handsontable.renderers.PasswordRenderer,
- hashSymbol: '#'
- }, {
- renderer: Handsontable.renderers.PasswordRenderer,
- hashSymbol: 'x'
- }]
- });
- expect(getRenderedValue(0, 0)).toMatch(/^[#]+$/ig);
- expect(getRenderedValue(1, 0)).toMatch(/^[#]+$/ig);
- expect(getRenderedValue(2, 0)).toMatch(/^[#]+$/ig);
- expect(getRenderedValue(3, 0)).toMatch(/^[#]+$/ig);
- expect(getRenderedValue(0, 1)).toMatch(/^[x]+$/ig);
- expect(getRenderedValue(1, 1)).toMatch(/^[x]+$/ig);
- expect(getRenderedValue(2, 1)).toMatch(/^[x]+$/ig);
- expect(getRenderedValue(3, 1)).toMatch(/^[x]+$/ig);
- });
- });
- /***/ }),
- /* 225 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('TextRenderer', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should render string', function () {
- handsontable();
- setDataAtCell(2, 2, 'string');
- expect(getCell(2, 2).innerHTML).toEqual('string');
- });
- it('should render number', function () {
- handsontable();
- setDataAtCell(2, 2, 13);
- expect(getCell(2, 2).innerHTML).toEqual('13');
- });
- it('should render boolean true', function () {
- handsontable();
- setDataAtCell(2, 2, true);
- expect(getCell(2, 2).innerHTML).toEqual('true');
- });
- it('should render boolean false', function () {
- handsontable();
- setDataAtCell(2, 2, false);
- expect(getCell(2, 2).innerHTML).toEqual('false');
- });
- it('should render null', function () {
- handsontable();
- setDataAtCell(2, 2, null);
- expect(getCell(2, 2).innerHTML).toEqual('');
- });
- it('should render undefined', function () {
- handsontable();
- /* eslint-disable wrap-iife */
- setDataAtCell(2, 2, function () {}());
- expect(getCell(2, 2).innerHTML).toEqual('');
- });
- it('should add class name `htDimmed` to a read only cell', function () {
- var DIV = document.createElement('DIV');
- var instance = new Handsontable.Core(DIV, {});
- var TD = document.createElement('TD');
- TD.className = 'someClass';
- Handsontable.renderers.TextRenderer(instance, TD, 0, 0, 0, '', { readOnly: true, readOnlyCellClassName: 'htDimmed' });
- expect(TD.className).toEqual('someClass htDimmed');
- instance.destroy();
- });
- it('should render a multiline string', function () {
- handsontable();
- setDataAtCell(1, 2, 'a b');
- setDataAtCell(2, 2, 'a\nb');
- expect($(getCell(2, 2)).height()).toBeGreaterThan($(getCell(1, 2)).height());
- });
- it('should wrap text when column width is limited', function () {
- handsontable({
- colWidths: [100]
- });
- setDataAtCell(0, 0, 'short text');
- setDataAtCell(1, 0, 'long long long long long long long text');
- expect($(getCell(1, 0)).height()).toBeGreaterThan($(getCell(0, 0)).height());
- });
- });
- /***/ }),
- /* 226 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('settings', function () {
- describe('colWidths', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('defined in constructor', function () {
- it('should consider colWidths provided as number', function () {
- handsontable({
- colWidths: 123
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider colWidths provided as string', function () {
- handsontable({
- colWidths: '123'
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider colWidths provided as array of numbers', function () {
- handsontable({
- colWidths: [123]
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider colWidths provided as array of strings', function () {
- handsontable({
- colWidths: ['123']
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider colWidth provided as function that returns number', function () {
- handsontable({
- colWidths: function colWidths(index) {
- if (index === 0) {
- return 123;
- }
- return 50;
- }
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider colWidth provided as function that returns string', function () {
- handsontable({
- colWidths: function colWidths(index) {
- if (index === 0) {
- return '123';
- }
- return '50';
- }
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- });
- describe('defined in updateSettings', function () {
- it('should consider colWidths provided as number', function () {
- handsontable();
- updateSettings({
- colWidths: 123
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider colWidths provided as string', function () {
- handsontable();
- updateSettings({
- colWidths: '123'
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider colWidths provided as array of numbers', function () {
- handsontable();
- updateSettings({
- colWidths: [123]
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider colWidths provided as array of strings', function () {
- handsontable();
- updateSettings({
- colWidths: ['123']
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider colWidth provided as function that returns number', function () {
- handsontable();
- updateSettings({
- colWidths: function colWidths(index) {
- if (index === 0) {
- return 123;
- }
- return 50;
- }
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider colWidth provided as function that returns string', function () {
- handsontable();
- updateSettings({
- colWidths: function colWidths(index) {
- if (index === 0) {
- return '123';
- }
- return '50';
- }
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- });
- describe('defined in columns', function () {
- it('should consider width provided as number', function () {
- handsontable({
- columns: [{
- width: 123
- }]
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider width provided as string', function () {
- handsontable({
- columns: [{
- width: '123'
- }]
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider width provided as array of numbers', function () {
- handsontable({
- columns: [{
- width: [123]
- }]
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider width provided as array of strings', function () {
- handsontable({
- columns: [{
- width: ['123']
- }]
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider width provided as function that returns number', function () {
- handsontable({
- columns: [{
- width: function width(index) {
- if (index === 0) {
- return 123;
- }
- return 50;
- }
- }]
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider width provided as function that returns string', function () {
- handsontable({
- columns: [{
- width: function width(index) {
- if (index === 0) {
- return '123';
- }
- return '50';
- }
- }]
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- });
- describe('defined in cells', function () {
- it('should consider width provided as number', function () {
- handsontable({
- cells: function cells(row, col) {
- if (col === 0) {
- this.width = 123;
- }
- }
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- it('should consider width provided as string', function () {
- handsontable({
- cells: function cells(row, col) {
- if (col === 0) {
- this.width = '123';
- }
- }
- });
- expect(colWidth(this.$container, 0)).toBe(123);
- });
- });
- });
- });
- /***/ }),
- /* 227 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('settings', function () {
- describe('columns', function () {
- var id = 'testContainer';
- var arrayOfArrays = function arrayOfArrays() {
- return [['', 'Kia', 'Nissan', 'Toyota', 'Honda'], ['2008', 10, 11, 12, 13], ['2009', 20, 11, 14, 13], ['2010', 30, 15, 12, 13]];
- };
- var arrayOfObjects = function arrayOfObjects() {
- return [{ id: 1, name: 'Ted', lastName: 'Right', date: '01/01/2015' }, { id: 2, name: 'Frank', lastName: 'Honest', date: '01/01/15' }, { id: 3, name: 'Joan', lastName: 'Well', date: '41/01/2015' }, { id: 4, name: 'Sid', lastName: 'Strong', date: '01/51/2015' }, { id: 5, name: 'Jane', lastName: 'Neat', date: '01/01/2015' }, { id: 6, name: 'Chuck', lastName: 'Jackson', date: '01/01/15' }, { id: 7, name: 'Meg', lastName: 'Jansen', date: '41/01/2015' }, { id: 8, name: 'Rob', lastName: 'Norris', date: '01/51/2015' }, { id: 9, name: 'Sean', lastName: 'O\'Hara', date: '01/01/2015' }, { id: 10, name: 'Eve', lastName: 'Branson', date: '01/01/15' }];
- };
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('as an array of objects', function () {
- it('should not throw exception when passed columns array is empty (data source as array of arrays)', function () {
- var hot = handsontable({
- data: arrayOfArrays(),
- columns: [{ data: 0 }, { data: 1 }, { data: 2 }]
- });
- expect(function () {
- hot.updateSettings({ columns: [] });
- }).not.toThrow();
- });
- it('should not throw exception when passed columns array is empty (data source as array of objects)', function () {
- var hot = handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id' }, { data: 'name' }, { data: 'lastName' }]
- });
- expect(function () {
- hot.updateSettings({ columns: [] });
- }).not.toThrow();
- });
- });
- describe('as a function', function () {
- describe('init', function () {
- it('should render only these columns which are not `null`', function () {
- var hot = handsontable({
- data: arrayOfArrays(),
- columns: function columns(column) {
- return [1, 2].indexOf(column) > -1 ? {} : null;
- }
- });
- expect(hot.getData()[0].length).toEqual(2);
- });
- it('should properly bind default data when is not defined (data source as array of arrays)', function () {
- var hot = handsontable({
- data: arrayOfArrays(),
- columns: function columns(column) {
- return [1, 2].indexOf(column) > -1 ? {} : null;
- }
- });
- expect(hot.getDataAtCell(0, 0)).toEqual('');
- expect(hot.getDataAtCell(0, 1)).toEqual('Kia');
- });
- it('should properly bind default data when is not defined (data source as array of objects)', function () {
- var hot = handsontable({
- data: arrayOfObjects(),
- columns: function columns(column) {
- return [1, 2].indexOf(column) > -1 ? {} : null;
- }
- });
- expect(hot.getDataAtCell(0, 0)).toEqual(null);
- expect(hot.getDataAtCell(0, 1)).toEqual(null);
- });
- it('should properly bind defined data (data source as array of arrays)', function () {
- var hot = handsontable({
- data: arrayOfArrays(),
- columns: function columns(column) {
- return [1, 2].indexOf(column) > -1 ? { data: column + 1 } : null;
- }
- });
- expect(hot.getDataAtCell(0, 0)).toEqual('Nissan');
- expect(hot.getDataAtCell(0, 1)).toEqual('Toyota');
- });
- it('should properly bind defined data (data source as array of objects)', function () {
- var hot = handsontable({
- data: arrayOfObjects(),
- columns: function columns(column) {
- var keys = ['id', 'name', 'lastName'];
- return [1, 2].indexOf(column) > -1 ? { data: keys[column - 1] } : null;
- }
- });
- expect(hot.getDataAtCell(0, 0)).toEqual(1);
- expect(hot.getDataAtCell(0, 1)).toEqual('Ted');
- });
- });
- describe('updateSettings', function () {
- it('should not throw exception when passed columns function without return anything (data source as array of arrays) when columns is a function', function () {
- var hot = handsontable({
- data: arrayOfArrays(),
- columns: function columns(column) {
- return [0, 1, 2].indexOf(column) > -1 ? { data: column } : null;
- }
- });
- expect(function () {
- hot.updateSettings({
- columns: function columns() {}
- });
- }).not.toThrow();
- });
- it('should not throw exception when passed columns function without return anything (data source as array of objects) when columns is a function', function () {
- var hot = handsontable({
- data: arrayOfObjects(),
- columns: function columns(column) {
- var keys = ['id', 'name', 'lasName'];
- return [0, 1, 2].indexOf(column) > -1 ? { data: keys[column] } : null;
- }
- });
- expect(function () {
- hot.updateSettings({
- columns: function columns() {}
- });
- }).not.toThrow();
- });
- });
- describe('editors', function () {
- it('should properly bind defined editors', function () {
- handsontable({
- data: [['Joe'], ['Timothy'], ['Margaret'], ['Jerry']],
- columns: function columns(column) {
- return column === 0 ? { editor: Handsontable.editors.PasswordEditor } : null;
- }
- });
- selectCell(0, 0);
- keyDown('enter');
- var editor = $('.handsontableInput');
- expect(editor.is(':visible')).toBe(true);
- expect(editor.is(':password')).toBe(true);
- });
- });
- describe('renderers', function () {
- it('should properly bind defined renderer', function () {
- handsontable({
- data: [[true], [false], [true]],
- columns: function columns(column) {
- return column === 0 ? { type: 'checkbox' } : null;
- }
- });
- expect($(getRenderedValue(0, 0)).is(':checkbox')).toBe(true);
- expect($(getRenderedValue(1, 0)).is(':checkbox')).toBe(true);
- expect($(getRenderedValue(2, 0)).is(':checkbox')).toBe(true);
- });
- });
- describe('validators', function () {
- it('should properly bind defined validator', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: function columns(column) {
- var settings = [{ data: 'date', type: 'date' }, { data: 'name' }, { data: 'lastName' }];
- return [0, 1, 2].indexOf(column) > -1 ? settings[column] : null;
- },
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, '');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '', 0, 'date', undefined, undefined);
- done();
- }, 100);
- });
- });
- });
- });
- });
- /***/ }),
- /* 228 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('settings', function () {
- describe('copyable', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('by default, CTRL+C should NOT copy the password value', function () {
- handsontable({
- data: [['Joe', 'Secret', 'Jack']],
- columns: [{}, {
- type: 'password'
- }, {}]
- });
- expect(getCopyableText(0, 0, 0, 2)).toMatch('Joe\t\tJack');
- });
- it('with copyable=true, CTRL+C should copy the password value', function () {
- handsontable({
- data: [['Joe', 'Secret', 'Jack']],
- columns: [{}, {
- type: 'password',
- copyable: true
- }, {}]
- });
- expect(getCopyableText(0, 0, 0, 2)).toMatch('Joe\tSecret\tJack');
- });
- it('with copyable=false, CTRL+C should NOT copy the password value', function () {
- handsontable({
- data: [['Joe', 'Secret', 'Jack']],
- columns: [{}, {
- type: 'password',
- copyable: false
- }, {}]
- });
- expect(getCopyableText(0, 0, 0, 2)).toMatch('Joe\t\tJack');
- });
- });
- });
- /***/ }),
- /* 229 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('settings', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('currentHeaderClassName', function () {
- it('should apply default currentHeaderClassName to cells in row where there is a selection', function () {
- handsontable({
- rowHeaders: true,
- colHeaders: true,
- data: Handsontable.helper.createSpreadsheetData(5, 7)
- });
- selectCell(2, 2);
- expect(this.$container.find('.ht_master th.ht__highlight').length).toEqual(2);
- });
- it('should apply default currentHeaderClassName from cells after deselection', function () {
- handsontable({
- rowHeaders: true,
- colHeaders: true,
- data: Handsontable.helper.createSpreadsheetData(5, 7)
- });
- selectCell(2, 2);
- deselectCell();
- expect(this.$container.find('.ht_master th.ht__highlight').length).toEqual(0);
- });
- it('should apply custom currentHeaderClassName to cells in row where there is a selection', function () {
- handsontable({
- rowHeaders: true,
- colHeaders: true,
- data: Handsontable.helper.createSpreadsheetData(5, 7),
- currentHeaderClassName: 'currentHeaderClassName'
- });
- selectCell(2, 2);
- expect(this.$container.find('.ht_master th.currentHeaderClassName').length).toEqual(2);
- });
- });
- });
- /***/ }),
- /* 230 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('settings', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('currentRowClassName', function () {
- it('should apply currentRowClassName to cells in row where there is a selection', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 7),
- currentRowClassName: 'currentRowClassName'
- });
- selectCell(2, 2);
- expect(this.$container.find('td.currentRowClassName').length).toEqual(6);
- });
- it('should apply currentRowClassName from cells after deselection', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 7),
- currentRowClassName: 'currentRowClassName'
- });
- selectCell(2, 2);
- deselectCell();
- expect(this.$container.find('td.currentRowClassName').length).toEqual(0);
- });
- });
- describe('currentColClassName', function () {
- it('should apply currentColClassName to cells in row where there is a selection', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 7),
- currentColClassName: 'currentColClassName'
- });
- selectCell(2, 2);
- expect(this.$container.find('td.currentColClassName').length).toEqual(4);
- });
- it('should remove currentColClassName from cells after deselection', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(5, 7),
- currentColClassName: 'currentColClassName'
- });
- selectCell(2, 2);
- deselectCell();
- expect(this.$container.find('td.currentColClassName').length).toEqual(0);
- });
- });
- });
- /***/ }),
- /* 231 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('settings', function () {
- describe('editor', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('defined in constructor', function () {
- it('should use text editor by default', function () {
- var textEditorPrototype = Handsontable.editors.TextEditor.prototype;
- spyOn(textEditorPrototype, 'init').and.callThrough();
- handsontable();
- selectCell(0, 0);
- expect(textEditorPrototype.init).toHaveBeenCalled();
- });
- it('should use editor from predefined string', function () {
- var textEditorPrototype = Handsontable.editors.TextEditor.prototype;
- var checkboxEditorPrototype = Handsontable.editors.CheckboxEditor.prototype;
- spyOn(textEditorPrototype, 'init');
- spyOn(checkboxEditorPrototype, 'init');
- handsontable({
- columns: [{
- editor: 'checkbox'
- }]
- });
- selectCell(0, 0);
- expect(textEditorPrototype.init).not.toHaveBeenCalled();
- expect(checkboxEditorPrototype.init).toHaveBeenCalled();
- });
- it('should use editor from predefined string when columns is a function', function () {
- var textEditorPrototype = Handsontable.editors.TextEditor.prototype;
- var checkboxEditorPrototype = Handsontable.editors.CheckboxEditor.prototype;
- spyOn(textEditorPrototype, 'init');
- spyOn(checkboxEditorPrototype, 'init');
- handsontable({
- columns: function columns(column) {
- return column === 0 ? { editor: 'checkbox' } : null;
- }
- });
- selectCell(0, 0);
- expect(textEditorPrototype.init).not.toHaveBeenCalled();
- expect(checkboxEditorPrototype.init).toHaveBeenCalled();
- });
- it('should use editor class passed directly', function () {
- var customEditor = jasmine.createSpy('customEditor');
- customEditor.and.callFake(function () {
- this.prepare = function () {};
- });
- handsontable({
- columns: [{
- editor: customEditor
- }]
- });
- selectCell(0, 0);
- expect(customEditor).toHaveBeenCalled();
- });
- it('should use editor class passed directly when columns is a function', function () {
- var customEditor = jasmine.createSpy('customEditor');
- customEditor.and.callFake(function () {
- this.prepare = function () {};
- });
- handsontable({
- columns: function columns(column) {
- return column === 0 ? { editor: customEditor } : null;
- }
- });
- selectCell(0, 0);
- expect(customEditor).toHaveBeenCalled();
- });
- it('should use editor from custom string', function () {
- var customEditor = jasmine.createSpy('customEditor');
- customEditor.and.callFake(function () {
- this.prepare = function () {};
- });
- Handsontable.editors.registerEditor('myEditor', customEditor);
- handsontable({
- columns: [{
- editor: 'myEditor'
- }]
- });
- selectCell(0, 0);
- expect(customEditor).toHaveBeenCalled();
- });
- it('should use editor from custom string when columns is a function', function () {
- var customEditor = jasmine.createSpy('customEditor');
- customEditor.and.callFake(function () {
- this.prepare = function () {};
- });
- Handsontable.editors.registerEditor('myEditor', customEditor);
- handsontable({
- columns: function columns(column) {
- return column === 0 ? { editor: 'myEditor' } : null;
- }
- });
- selectCell(0, 0);
- expect(customEditor).toHaveBeenCalled();
- });
- });
- });
- });
- /***/ }),
- /* 232 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('settings', function () {
- describe('fixedColumnsLeft', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('defined in constructor', function () {
- it('should show columns headers', function () {
- handsontable({
- fixedColumnsLeft: 3
- });
- expect(getLeftClone().find('tbody tr:eq(0) td').length).toEqual(3);
- });
- it('should show columns headers when headers are enabled', function () {
- handsontable({
- rowHeaders: true,
- colHeaders: true,
- fixedColumnsLeft: 2
- });
- expect(getLeftClone().find('thead tr th').length).toEqual(3);
- expect(getLeftClone().find('tbody tr:eq(0) td').length).toEqual(2);
- });
- });
- describe('defined in updateSettings', function () {
- it('should increase fixed columns', function () {
- handsontable({
- fixedColumnsLeft: 2
- });
- updateSettings({
- fixedColumnsLeft: 4
- });
- expect(getLeftClone().find('tbody tr:eq(0) td').length).toEqual(4);
- });
- it('should decrease fixed columns', function () {
- handsontable({
- fixedColumnsLeft: 4
- });
- updateSettings({
- fixedColumnsLeft: 2
- });
- expect(getLeftClone().find('tbody tr:eq(0) td').length).toEqual(2);
- });
- it('should create fixed columns when they are disabled eariler', function () {
- handsontable({
- fixedColumnsLeft: 0
- });
- updateSettings({
- fixedColumnsLeft: 2
- });
- expect(getLeftClone().find('tbody tr:eq(0) td').length).toEqual(2);
- });
- it('should disable fixed columns', function () {
- handsontable({
- fixedColumnsLeft: 2
- });
- updateSettings({
- fixedColumnsLeft: 0
- });
- expect(getLeftClone().find('tbody tr:eq(0) td').length).toEqual(2);
- expect(getLeftClone().width()).toBe(0);
- });
- it('should not throw errors while scrolling horizontally when fixed columns was set', function (done) {
- var spy = jasmine.createSpyObj('error', ['test']);
- var prevError = window.onerror;
- window.onerror = function (messageOrEvent, source, lineno, colno, error) {
- spy.test();
- };
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(50, 50),
- width: 200,
- height: 200,
- colHeaders: true
- });
- updateSettings({
- fixedColumnsLeft: 2
- });
- setTimeout(function () {
- hot.scrollViewportTo(30, 30);
- }, 100);
- setTimeout(function () {
- expect(spy.test.calls.count()).toBe(0);
- done();
- window.onerror = prevError;
- }, 200);
- });
- });
- });
- });
- /***/ }),
- /* 233 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('settings', function () {
- describe('fixedRowsTop', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('defined in constructor', function () {
- it('should show rows headers', function () {
- handsontable({
- fixedRowsTop: 3
- });
- expect(getTopClone().find('tbody tr').length).toEqual(3);
- });
- it('should show rows headers when headers are enabled', function () {
- handsontable({
- rowHeaders: true,
- colHeaders: true,
- fixedRowsTop: 2
- });
- expect(getTopClone().find('thead tr').length).toEqual(1);
- expect(getTopClone().find('tbody tr').length).toEqual(2);
- });
- });
- describe('defined in updateSettings', function () {
- it('should increase fixed rows', function () {
- handsontable({
- fixedRowsTop: 2
- });
- updateSettings({
- fixedRowsTop: 4
- });
- expect(getTopClone().find('tbody tr').length).toEqual(4);
- });
- it('should decrease fixed rows', function () {
- handsontable({
- fixedRowsTop: 4
- });
- updateSettings({
- fixedRowsTop: 2
- });
- expect(getTopClone().find('tbody tr').length).toEqual(2);
- });
- it('should create fixed rows when they are disabled eariler', function () {
- handsontable({
- fixedRowsTop: 0
- });
- updateSettings({
- fixedRowsTop: 2
- });
- expect(getTopClone().find('tbody tr').length).toEqual(2);
- });
- it('should disable fixed rows', function () {
- handsontable({
- fixedRowsTop: 2
- });
- updateSettings({
- fixedRowsTop: 0
- });
- expect(getTopClone().find('tbody tr').length).toEqual(2);
- expect(getLeftClone().height()).toBe(0);
- });
- it('should not throw errors while scrolling vertically when fixed rows was set', function (done) {
- var spy = jasmine.createSpyObj('error', ['test']);
- var prevError = window.onerror;
- window.onerror = function (messageOrEvent, source, lineno, colno, error) {
- spy.test();
- };
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(50, 50),
- width: 200,
- height: 200,
- rowHeaders: true
- });
- updateSettings({
- fixedRowsTop: 2
- });
- setTimeout(function () {
- hot.scrollViewportTo(30, 30);
- }, 100);
- setTimeout(function () {
- expect(spy.test.calls.count()).toBe(0);
- done();
- window.onerror = prevError;
- }, 200);
- });
- });
- });
- });
- /***/ }),
- /* 234 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('settings', function () {
- describe('fragmentSelection', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- /**
- * Returns current text selection or false if there is no text selection
- * @returns {*}
- */
- function getSelected() {
- /* eslint-disable no-else-return */
- var text = '';
- // IE8
- if (window.getSelection && window.getSelection().toString() && $(window.getSelection()).attr('type') != 'Caret') {
- text = window.getSelection();
- return text.toString();
- } else {
- // standards
- var selection = document.selection && document.selection.createRange();
- if (!(typeof selection === 'undefined') && selection.text && selection.text.toString()) {
- text = selection.text;
- return text.toString();
- }
- }
- return false;
- }
- /**
- * Selects a <fromEl> node at as many siblings as given in the <cells> value
- * Note: IE8 fallback assumes that a node contains exactly one word
- * @param fromEl
- * @param siblings
- */
- function selectElementText(fromEl, siblings) {
- var doc = window.document;
- var sel;
- var range;
- if (window.getSelection && doc.createRange) {
- // standards
- sel = window.getSelection();
- range = doc.createRange();
- range.setStartBefore(fromEl, 0);
- while (siblings > 1) {
- fromEl = fromEl.nextSibling;
- siblings--;
- }
- range.setEndAfter(fromEl, 0);
- sel.removeAllRanges();
- sel.addRange(range);
- } else if (doc.body.createTextRange) {
- // IE8
- range = doc.body.createTextRange();
- range.moveToElementText(fromEl);
- range.moveEnd('word', siblings + 1);
- range.select();
- }
- }
- describe('constructor', function () {
- it('should disallow fragmentSelection when set to false', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- fragmentSelection: false
- });
- selectElementText(this.$container.find('tr:eq(0) td:eq(1)')[0], 3);
- mouseDown(this.$container.find('tr:eq(0) td:eq(3)'));
- mouseUp(this.$container.find('tr:eq(0) td:eq(3)'));
- var sel = getSelected();
- expect(sel).toEqual(false);
- });
- it('should allow fragmentSelection when set to true', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- fragmentSelection: true
- });
- selectElementText(this.$container.find('td')[1], 3);
- mouseDown(this.$container.find('tr:eq(0) td:eq(3)'));
- mouseUp(this.$container.find('tr:eq(0) td:eq(3)'));
- var sel = getSelected();
- sel = sel.replace(/\s/g, ''); // tabs and spaces between <td>s are inconsistent in browsers, so let's ignore them
- expect(sel).toEqual('B1C1D1');
- });
- it('should allow fragmentSelection from one cell when set to `cell`', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- fragmentSelection: 'cell'
- });
- selectElementText(this.$container.find('td')[1], 1);
- mouseDown(this.$container.find('tr:eq(0) td:eq(1)'));
- mouseOver(this.$container.find('tr:eq(0) td:eq(1)'));
- mouseMove(this.$container.find('tr:eq(0) td:eq(1)'));
- mouseUp(this.$container.find('tr:eq(0) td:eq(1)'));
- expect(getSelected().replace(/\s/g, '')).toEqual('B1');
- });
- it('should disallow fragmentSelection from one cell when set to `cell` and when user selects adjacent cell', function () {
- var hot = handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- fragmentSelection: 'cell'
- });
- selectElementText(this.$container.find('td')[1], 1);
- mouseDown(this.$container.find('tr:eq(0) td:eq(1)'));
- mouseOver(this.$container.find('tr:eq(0) td:eq(2)'));
- mouseMove(this.$container.find('tr:eq(0) td:eq(2)'));
- mouseUp(this.$container.find('tr:eq(0) td:eq(2)'));
- expect(getSelected()).toEqual(false);
- });
- it('should disallow fragmentSelection of Handsontable chrome (anything that is not table) when set to false', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- fragmentSelection: false
- });
- var $div = $('<div style="position: absolute; top: 0; left: 0">Text</div>');
- this.$container.append($div);
- selectElementText($div[0], 1);
- mouseDown($div);
- var sel = getSelected();
- expect(sel).toEqual(false);
- });
- it('should disallow fragmentSelection of Handsontable chrome (anything that is not table) when set to true', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- fragmentSelection: true
- });
- var $div = $('<div style="position: absolute; top: 0; left: 0">Text</div>');
- this.$container.append($div);
- selectElementText($div[0], 1);
- mouseDown($div);
- var sel = getSelected();
- expect(sel).toEqual(false);
- });
- });
- describe('dynamic', function () {
- it('should disallow fragmentSelection when set to false', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- fragmentSelection: true
- });
- updateSettings({ fragmentSelection: false });
- selectElementText(this.$container.find('tr:eq(0) td:eq(1)')[0], 3);
- mouseDown(this.$container.find('tr:eq(0) td:eq(3)'));
- mouseUp(this.$container.find('tr:eq(0) td:eq(3)'));
- var sel = getSelected();
- expect(sel).toEqual(false);
- });
- it('should allow fragmentSelection when set to true', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(4, 4),
- fragmentSelection: false
- });
- updateSettings({ fragmentSelection: true });
- selectElementText(this.$container.find('td')[1], 3);
- mouseDown(this.$container.find('tr:eq(0) td:eq(3)'));
- mouseUp(this.$container.find('tr:eq(0) td:eq(3)'));
- var sel = getSelected();
- sel = sel.replace(/\s/g, ''); // tabs and spaces between <td>s are inconsistent in browsers, so let's ignore them
- expect(sel).toEqual('B1C1D1');
- });
- });
- });
- });
- /***/ }),
- /* 235 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('settings', function () {
- describe('maxCols', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('works on init', function () {
- it('should show data properly when `maxCols` is set to 0', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- maxCols: 0
- });
- expect(getSourceDataAtRow(0).length).toEqual(10);
- expect(countSourceCols()).toEqual(10);
- expect(getData().length).toEqual(0);
- expect(getDataAtRow(0)).toEqual([]);
- expect(countCols()).toEqual(0);
- expect(countEmptyCols()).toEqual(0);
- expect(getDataAtCol(0)).toEqual([]);
- expect(getDataAtCol(1)).toEqual([]);
- });
- it('should show data properly when `maxCols` is set to value > 0', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- maxCols: 5
- });
- expect(getSourceDataAtRow(0).length).toEqual(10);
- expect(countSourceCols()).toEqual(10);
- expect(getData()[0].length).toEqual(5);
- expect(getDataAtRow(0).length).toEqual(5);
- expect(countCols()).toEqual(5);
- expect(countEmptyCols()).toEqual(0);
- expect(getDataAtCol(6)).toEqual([]);
- });
- it('should show data properly when `maxCols` is set to infinity value', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- maxCols: Infinity
- });
- expect(getSourceDataAtRow(0).length).toEqual(10);
- expect(countSourceCols()).toEqual(10);
- expect(getData()[0].length).toEqual(10);
- expect(getDataAtRow(0).length).toEqual(10);
- expect(countCols()).toEqual(10);
- expect(countEmptyCols()).toEqual(0);
- expect(getDataAtCol(0)).toEqual(['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10']);
- });
- describe('when `columns` property was set', function () {
- it('should show data properly when `maxCols` is set to value > 0', function () {
- handsontable({
- columns: [{ type: 'text' }, { type: 'text' }, { type: 'text' }, { type: 'text' }, { type: 'text' }],
- minRows: 10,
- maxCols: 2
- });
- expect(getSourceDataAtRow(0).length).toEqual(5);
- expect(countSourceCols()).toEqual(5);
- expect(getData()[0].length).toEqual(2);
- expect(getDataAtRow(0).length).toEqual(2);
- expect(countCols()).toEqual(2);
- expect(getDataAtCol(3)).toEqual([]);
- });
- });
- });
- describe('update settings works', function () {
- it('should show data properly after maxCols is updated to 0', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10)
- });
- updateSettings({
- maxCols: 0
- });
- expect(getSourceDataAtRow(0).length).toEqual(10);
- expect(countSourceCols()).toEqual(10);
- expect(getData().length).toEqual(0);
- expect(getDataAtRow(0)).toEqual([]);
- expect(countCols()).toEqual(0);
- expect(getDataAtCol(0)).toEqual([]);
- expect(getDataAtCol(1)).toEqual([]);
- });
- it('should show data properly after maxCols is updated to value > 0 -> test no. 1', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10)
- });
- updateSettings({
- maxCols: 2
- });
- expect(getSourceDataAtRow(0).length).toEqual(10);
- expect(countSourceCols()).toEqual(10);
- expect(getData()[0].length).toEqual(2);
- expect(getDataAtRow(0).length).toEqual(2);
- expect(countCols()).toEqual(2);
- expect(countEmptyCols()).toEqual(0);
- expect(getDataAtCol(3)).toEqual([]);
- });
- it('should show data properly after maxCols is updated to value > 0 -> test no. 2', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- maxCols: 5
- });
- updateSettings({
- maxCols: 2
- });
- expect(getSourceDataAtRow(0).length).toEqual(10);
- expect(countSourceCols()).toEqual(10);
- expect(getData()[0].length).toEqual(2);
- expect(getDataAtRow(0).length).toEqual(2);
- expect(countCols()).toEqual(2);
- expect(countEmptyCols()).toEqual(0);
- expect(getDataAtCol(3)).toEqual([]);
- });
- it('should show data properly after maxCols is updated to value > 0 -> test no. 3', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- maxCols: 2
- });
- updateSettings({
- maxCols: 5
- });
- expect(getSourceDataAtRow(0).length).toEqual(10);
- expect(countSourceCols()).toEqual(10);
- expect(getData()[0].length).toEqual(5);
- expect(getDataAtRow(0).length).toEqual(5);
- expect(countCols()).toEqual(5);
- expect(countEmptyCols()).toEqual(0);
- expect(getDataAtCol(6)).toEqual([]);
- });
- it('should show data properly after maxCols is updated to infinity value -> test no. 1', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10)
- });
- updateSettings({
- maxCols: Infinity
- });
- expect(getSourceDataAtRow(0).length).toEqual(10);
- expect(countSourceCols()).toEqual(10);
- expect(getData()[0].length).toEqual(10);
- expect(getDataAtRow(0).length).toEqual(10);
- expect(countCols()).toEqual(10);
- expect(countEmptyCols()).toEqual(0);
- expect(getDataAtCol(0)).toEqual(['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10']);
- });
- it('should show data properly after maxCols is updated to infinity value -> test no. 2', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- maxCols: 2
- });
- updateSettings({
- maxCols: Infinity
- });
- expect(getSourceDataAtRow(0).length).toEqual(10);
- expect(countSourceCols()).toEqual(10);
- expect(getData()[0].length).toEqual(10);
- expect(getDataAtRow(0).length).toEqual(10);
- expect(countCols()).toEqual(10);
- expect(countEmptyCols()).toEqual(0);
- expect(getDataAtCol(0)).toEqual(['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10']);
- });
- describe('works when `columns` property was set', function () {
- it('should show data properly when `maxCols` is updated to value > 0', function () {
- handsontable({
- columns: [{ type: 'text' }, { type: 'text' }, { type: 'text' }, { type: 'text' }, { type: 'text' }],
- minRows: 10
- });
- updateSettings({
- maxCols: 2
- });
- expect(getSourceDataAtRow(0).length).toEqual(5);
- expect(countSourceCols()).toEqual(5);
- expect(getData()[0].length).toEqual(2);
- expect(getDataAtRow(0).length).toEqual(2);
- expect(countCols()).toEqual(2);
- expect(getDataAtCol(0).length).toEqual(10);
- });
- });
- });
- });
- });
- /***/ }),
- /* 236 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('settings', function () {
- describe('maxRows', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('works on init', function () {
- it('should show data properly when `maxRows` is set to 0', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- maxRows: 0
- });
- expect(getSourceDataAtCol(0).length).toEqual(10);
- expect(countSourceRows()).toEqual(10);
- expect(getData().length).toEqual(0);
- expect(getDataAtCol(0)).toEqual([]);
- expect(countRows()).toEqual(0);
- expect(countEmptyRows()).toEqual(0);
- expect(getDataAtRow(0)).toEqual([]);
- expect(getDataAtRow(1)).toEqual([]);
- });
- it('should show data properly when `maxRows` is set to value > 0', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- maxRows: 5
- });
- expect(getSourceDataAtCol(0).length).toEqual(10);
- expect(countSourceRows()).toEqual(10);
- expect(getData().length).toEqual(5);
- expect(getDataAtCol(0).length).toEqual(5);
- expect(countRows()).toEqual(5);
- expect(countEmptyRows()).toEqual(0);
- expect(getDataAtRow(6)).toEqual([]);
- });
- it('should show data properly when `maxRows` is set to infinity value', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- maxRows: Infinity
- });
- expect(getSourceDataAtCol(0).length).toEqual(10);
- expect(countSourceRows()).toEqual(10);
- expect(getData().length).toEqual(10);
- expect(getDataAtCol(0).length).toEqual(10);
- expect(countRows()).toEqual(10);
- expect(countEmptyRows()).toEqual(0);
- expect(getDataAtRow(0)).toEqual(['A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1', 'H1', 'I1', 'J1']);
- });
- });
- describe('update settings works', function () {
- it('should show data properly after maxRows is updated to 0', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10)
- });
- updateSettings({
- maxRows: 0
- });
- expect(getSourceDataAtCol(0).length).toEqual(10);
- expect(countSourceRows()).toEqual(10);
- expect(getData().length).toEqual(0);
- expect(getDataAtCol(0)).toEqual([]);
- expect(countRows()).toEqual(0);
- expect(countEmptyRows()).toEqual(0);
- expect(getDataAtRow(0)).toEqual([]);
- expect(getDataAtRow(1)).toEqual([]);
- });
- it('should show data properly after maxRows is updated to value > 0 -> test no. 1', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10)
- });
- updateSettings({
- maxRows: 2
- });
- expect(getSourceDataAtCol(0).length).toEqual(10);
- expect(countSourceRows()).toEqual(10);
- expect(getData().length).toEqual(2);
- expect(getDataAtCol(0).length).toEqual(2);
- expect(countRows()).toEqual(2);
- expect(countEmptyRows()).toEqual(0);
- expect(getDataAtRow(3)).toEqual([]);
- });
- it('should show data properly after maxRows is updated to value > 0 -> test no. 2', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- maxRows: 5
- });
- updateSettings({
- maxRows: 2
- });
- expect(getSourceDataAtCol(0).length).toEqual(10);
- expect(countSourceRows()).toEqual(10);
- expect(getData().length).toEqual(2);
- expect(getDataAtCol(0).length).toEqual(2);
- expect(countRows()).toEqual(2);
- expect(countEmptyRows()).toEqual(0);
- expect(getDataAtRow(3)).toEqual([]);
- });
- it('should show data properly after maxRows is updated to value > 0 -> test no. 3', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- maxRows: 2
- });
- updateSettings({
- maxRows: 5
- });
- expect(getSourceDataAtCol(0).length).toEqual(10);
- expect(countSourceRows()).toEqual(10);
- expect(getData().length).toEqual(5);
- expect(getDataAtCol(0).length).toEqual(5);
- expect(countRows()).toEqual(5);
- expect(countEmptyRows()).toEqual(0);
- expect(getDataAtRow(6)).toEqual([]);
- });
- it('should show data properly after maxRows is updated to infinity value -> test no. 1', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10)
- });
- updateSettings({
- maxRows: Infinity
- });
- expect(getSourceDataAtCol(0).length).toEqual(10);
- expect(countSourceRows()).toEqual(10);
- expect(getData().length).toEqual(10);
- expect(getDataAtCol(0).length).toEqual(10);
- expect(countRows()).toEqual(10);
- expect(countEmptyRows()).toEqual(0);
- expect(getDataAtRow(0)).toEqual(['A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1', 'H1', 'I1', 'J1']);
- });
- it('should show data properly after maxRows is updated to infinity value -> test no. 2', function () {
- handsontable({
- data: Handsontable.helper.createSpreadsheetData(10, 10),
- maxRows: 2
- });
- updateSettings({
- maxRows: Infinity
- });
- expect(getSourceDataAtCol(0).length).toEqual(10);
- expect(countSourceRows()).toEqual(10);
- expect(getData().length).toEqual(10);
- expect(getDataAtCol(0).length).toEqual(10);
- expect(countRows()).toEqual(10);
- expect(countEmptyRows()).toEqual(0);
- expect(getDataAtRow(0)).toEqual(['A1', 'B1', 'C1', 'D1', 'E1', 'F1', 'G1', 'H1', 'I1', 'J1']);
- });
- });
- });
- });
- /***/ }),
- /* 237 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('settings', function () {
- describe('renderer', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('defined in constructor', function () {
- it('should use text renderer by default', function () {
- var originalTextRenderer = Handsontable.cellTypes.text.renderer;
- spyOn(Handsontable.cellTypes.text, 'renderer');
- Handsontable.renderers.registerRenderer('text', Handsontable.cellTypes.text.renderer);
- handsontable();
- expect(Handsontable.cellTypes.text.renderer).toHaveBeenCalled();
- Handsontable.renderers.registerRenderer('text', originalTextRenderer);
- });
- it('should use renderer from predefined string', function () {
- var originalTextRenderer = Handsontable.renderers.TextRenderer;
- spyOn(Handsontable.renderers, 'TextRenderer');
- Handsontable.renderers.registerRenderer('text', Handsontable.renderers.TextRenderer);
- var originalCheckboxRenderer = Handsontable.renderers.CheckboxRenderer;
- spyOn(Handsontable.renderers, 'CheckboxRenderer');
- Handsontable.renderers.registerRenderer('checkbox', Handsontable.renderers.CheckboxRenderer);
- handsontable({
- columns: [{
- renderer: 'checkbox'
- }]
- });
- expect(Handsontable.renderers.TextRenderer).not.toHaveBeenCalled();
- expect(Handsontable.renderers.CheckboxRenderer).toHaveBeenCalled();
- Handsontable.renderers.registerRenderer('text', originalTextRenderer);
- Handsontable.renderers.registerRenderer('checkbox', originalCheckboxRenderer);
- });
- it('should use renderer from predefined string when columns is a function', function () {
- var originalTextRenderer = Handsontable.renderers.TextRenderer;
- spyOn(Handsontable.renderers, 'TextRenderer');
- Handsontable.renderers.registerRenderer('text', Handsontable.renderers.TextRenderer);
- var originalCheckboxRenderer = Handsontable.renderers.CheckboxRenderer;
- spyOn(Handsontable.renderers, 'CheckboxRenderer');
- Handsontable.renderers.registerRenderer('checkbox', Handsontable.renderers.CheckboxRenderer);
- handsontable({
- columns: function columns(column) {
- return column === 0 ? { renderer: 'checkbox' } : null;
- }
- });
- expect(Handsontable.renderers.TextRenderer).not.toHaveBeenCalled();
- expect(Handsontable.renderers.CheckboxRenderer).toHaveBeenCalled();
- Handsontable.renderers.registerRenderer('text', originalTextRenderer);
- Handsontable.renderers.registerRenderer('checkbox', originalCheckboxRenderer);
- });
- it('should use renderer from custom function', function () {
- var called = false;
- function myRenderer() {
- called = true;
- }
- handsontable({
- columns: [{
- renderer: myRenderer
- }]
- });
- expect(called).toBe(true);
- });
- it('should use renderer from custom function when columns is a function', function () {
- var called = false;
- function myRenderer() {
- called = true;
- }
- handsontable({
- columns: function columns(column) {
- return column === 0 ? { renderer: myRenderer } : null;
- }
- });
- expect(called).toBe(true);
- });
- it('should use renderer from custom string', function () {
- var myRenderer = jasmine.createSpy('myRenderer');
- Handsontable.renderers.registerRenderer('myRenderer', myRenderer);
- handsontable({
- columns: [{
- renderer: 'myRenderer'
- }]
- });
- expect(myRenderer).toHaveBeenCalled();
- });
- it('should use renderer from custom string when columns is a function', function () {
- var myRenderer = jasmine.createSpy('myRenderer');
- Handsontable.renderers.registerRenderer('myRenderer', myRenderer);
- handsontable({
- columns: function columns(column) {
- return column === 0 ? { renderer: 'myRenderer' } : null;
- }
- });
- expect(myRenderer).toHaveBeenCalled();
- });
- });
- it('should call renderer with cellProperties.row, cellProperties.col matching row and col arguments', function () {
- var rendererSpy = jasmine.createSpy('rendererSpy').and.callThrough();
- var cellPropertiesCache = [];
- rendererSpy.and.callFake(function (instance, TD, row, col, prop, value, cellProperties) {
- cellPropertiesCache.push({
- row: cellProperties.row,
- col: cellProperties.col
- });
- });
- handsontable({
- renderer: rendererSpy
- });
- for (var i = 0, len = rendererSpy.calls.count(); i < len; i++) {
- var args = rendererSpy.calls.argsFor(i);
- var row = args[2];
- var col = args[3];
- var cellProperties = cellPropertiesCache[i];
- expect(row).toEqual(cellProperties.row);
- expect(col).toEqual(cellProperties.col);
- }
- });
- it('should call cells function before passing cellProperties to renderer', function () {
- var rendererSpy = jasmine.createSpy('rendererSpy').and.callThrough();
- var cellPropertiesCache = [];
- rendererSpy.and.callFake(function (instance, TD, row, col, prop, value, cellProperties) {
- cellPropertiesCache.push({
- cellsRow: cellProperties.cellsRow,
- cellsCol: cellProperties.cellsCol
- });
- });
- handsontable({
- renderer: rendererSpy,
- cells: function cells(row, col) {
- return {
- cellsRow: row,
- cellsCol: col
- };
- }
- });
- for (var i = 0, len = rendererSpy.calls.count(); i < len; i++) {
- var args = rendererSpy.calls.argsFor(i);
- var row = args[2];
- var col = args[3];
- var cellProperties = cellPropertiesCache[i];
- expect(row).toEqual(cellProperties.cellsRow);
- expect(col).toEqual(cellProperties.cellsCol);
- }
- });
- });
- });
- /***/ }),
- /* 238 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('settings', function () {
- describe('tableClassName', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should add class name every table element inside handsontable wrapper element (as string, without overlays)', function () {
- var hot = handsontable({
- colHeaders: false,
- rowHeaders: false,
- tableClassName: 'foo'
- });
- var possibleCounts = [3, 4]; // 3 for non-pro, 4 for pro (bottom overlay)
- // all overlays is created anyway but without left-top corner
- expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.foo').length)).toBeGreaterThan(-1);
- });
- it('should add class name every table element inside handsontable wrapper element (as string, with overlays)', function () {
- var hot = handsontable({
- colHeaders: true,
- rowHeaders: true,
- tableClassName: 'foo'
- });
- var possibleCounts = [4, 5]; // 4 for non-pro, 5 for pro (bottom overlay)
- expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.foo').length)).toBeGreaterThan(-1);
- });
- it('should add class name every table element inside handsontable wrapper element (as string with spaces, without overlays)', function () {
- var hot = handsontable({
- colHeaders: false,
- rowHeaders: false,
- tableClassName: 'foo bar'
- });
- var possibleCounts = [3, 4]; // 3 for non-pro, 4 for pro (bottom overlay)
- // all overlays is created anyway but without left-top corner
- expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.foo').length)).toBeGreaterThan(-1);
- expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.bar').length)).toBeGreaterThan(-1);
- });
- it('should add class name every table element inside handsontable wrapper element (as string with spaces, with overlays)', function () {
- var hot = handsontable({
- colHeaders: true,
- rowHeaders: true,
- tableClassName: 'foo bar'
- });
- var possibleCounts = [4, 5]; // 4 for non-pro, 5 for pro (bottom overlay)
- expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.foo').length)).toBeGreaterThan(-1);
- expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.bar').length)).toBeGreaterThan(-1);
- });
- it('should add class name every table element inside handsontable wrapper element (as array, without overlays)', function () {
- var hot = handsontable({
- colHeaders: false,
- rowHeaders: false,
- tableClassName: ['foo', 'bar', 'baz']
- });
- var possibleCounts = [3, 4]; // 3 for non-pro, 4 for pro (bottom overlay)
- expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.foo').length)).toBeGreaterThan(-1);
- expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.bar').length)).toBeGreaterThan(-1);
- expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.baz').length)).toBeGreaterThan(-1);
- });
- it('should add class name every table element inside handsontable wrapper element (as array, with overlays)', function () {
- var hot = handsontable({
- colHeaders: true,
- rowHeaders: true,
- tableClassName: ['foo', 'bar', 'baz']
- });
- var possibleCounts = [4, 5]; // 4 for non-pro, 5 for pro (bottom overlay)
- expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.foo').length)).toBeGreaterThan(-1);
- expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.bar').length)).toBeGreaterThan(-1);
- expect(possibleCounts.indexOf(hot.rootElement.querySelectorAll('table.baz').length)).toBeGreaterThan(-1);
- });
- });
- });
- /***/ }),
- /* 239 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('GhostTable', function () {
- var hotSettings = {
- data: [['A', '1', 'A\nB\nC'], ['B', '2', 'A-----B-------C'], ['C', '3', 'A---\n--B-------C']]
- };
- var gt;
- beforeEach(function () {
- this.$container = $('<div id="testContainer"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- if (gt) {
- gt.clean();
- gt = null;
- }
- });
- describe('row', function () {
- it('should throw exception if we try to add column after added row', function () {
- var hot = handsontable(hotSettings);
- var exception = false;
- var samples = new Map();
- gt = new Handsontable.__GhostTable(hot);
- gt.addRow(0, samples);
- try {
- gt.addColumn(0, samples);
- } catch (ex) {
- exception = true;
- }
- expect(exception).toBe(true);
- });
- it('should create container element only for first row', function () {
- var hot = handsontable(hotSettings);
- var samples = new Map();
- gt = new Handsontable.__GhostTable(hot);
- spyOn(gt, 'createContainer').and.callThrough();
- gt.addRow(0, samples);
- gt.addRow(0, samples);
- gt.addRow(0, samples);
- gt.addRow(1, samples);
- gt.addRow(2, samples);
- expect(gt.createContainer.calls.count()).toBe(1);
- expect(gt.createContainer.calls.mostRecent().args).toEqual(['handsontable']);
- });
- it('should add row to rows collection after call `addRow` method', function () {
- var hot = handsontable(hotSettings);
- var samples = new Map();
- gt = new Handsontable.__GhostTable(hot);
- expect(gt.rows.length).toBe(0);
- samples.clear();
- samples.set(0, { strings: [{ value: 'Foo', row: 0 }, { value: 'Foo Bar', row: 0 }] });
- gt.addRow(0, samples);
- expect(gt.rows.length).toBe(1);
- expect(gt.rows[0].row).toBe(0);
- expect(gt.rows[0].table.className).toBe('htCore');
- expect(gt.rows[0].table.nodeName).toBe('TABLE');
- expect(gt.rows[0].table.querySelectorAll('colgroup > col').length).toBe(2);
- expect(gt.rows[0].table.querySelector('tbody > tr > td').innerHTML).toBe('Foo');
- samples.clear();
- samples.set(0, { strings: [{ value: 'Bar', row: 1 }, { value: 'Baz1234', row: 1 }] });
- gt.addRow(1, samples);
- expect(gt.rows.length).toBe(2);
- expect(gt.rows[1].row).toBe(1);
- expect(gt.rows[1].table.className).toBe('htCore');
- expect(gt.rows[1].table.nodeName).toBe('TABLE');
- expect(gt.rows[1].table.querySelectorAll('colgroup > col').length).toBe(2);
- expect(gt.rows[1].table.querySelector('tbody > tr > td').innerHTML).toBe('Bar');
- });
- it('should get valid heights', function () {
- var hot = handsontable(hotSettings);
- var heightSpy = jasmine.createSpy();
- var samples = new Map();
- gt = new Handsontable.__GhostTable(hot);
- samples.clear();
- samples.set(0, { strings: [{ value: 'Foo', row: 0 }, { value: 'Foo.....Bar', row: 0 }] });
- gt.addRow(0, samples);
- samples.clear();
- samples.set(0, { strings: [{ value: 'Foo\nBar\nsqw', row: 1 }] });
- gt.addRow(1, samples);
- samples.clear();
- samples.set(0, { strings: [{ value: 'Foo', row: 0 }, { value: 'Foo Bar', row: 0 }] });
- gt.addRow(2, samples);
- gt.getHeights(heightSpy);
- expect(heightSpy.calls.count()).toBe(3);
- expect(heightSpy.calls.argsFor(0)[0]).toBe(0);
- expect(heightSpy.calls.argsFor(0)[1]).toBe(23);
- expect(heightSpy.calls.argsFor(1)[0]).toBe(1);
- expect(heightSpy.calls.argsFor(1)[1]).toBe(64);
- expect(heightSpy.calls.argsFor(2)[0]).toBe(2);
- expect(heightSpy.calls.argsFor(2)[1]).toBe(43);
- });
- });
- describe('column', function () {
- it('should throw exception if we try to add row after added column', function () {
- var hot = handsontable(hotSettings);
- var exception = false;
- var samples = new Map();
- gt = new Handsontable.__GhostTable(hot);
- gt.addColumn(0, samples);
- try {
- gt.addRow(0, samples);
- } catch (ex) {
- exception = true;
- }
- expect(exception).toBe(true);
- });
- it('should create container element only for first column', function () {
- var hot = handsontable(hotSettings);
- var samples = new Map();
- gt = new Handsontable.__GhostTable(hot);
- spyOn(gt, 'createContainer').and.callThrough();
- gt.addColumn(0, samples);
- gt.addColumn(0, samples);
- gt.addColumn(0, samples);
- gt.addColumn(1, samples);
- gt.addColumn(2, samples);
- expect(gt.createContainer.calls.count()).toBe(1);
- expect(gt.createContainer.calls.mostRecent().args).toEqual(['handsontable']);
- });
- it('should add column to columns collection after call `addColumn` method', function () {
- var hot = handsontable(hotSettings);
- var samples = new Map();
- gt = new Handsontable.__GhostTable(hot);
- expect(gt.columns.length).toBe(0);
- samples.clear();
- samples.set(0, { strings: [{ value: 'Foo', col: 0 }, { value: 'Foo Bar', col: 0 }] });
- gt.addColumn(0, samples);
- expect(gt.columns.length).toBe(1);
- expect(gt.columns[0].col).toBe(0);
- expect(gt.columns[0].table.className).toBe('htCore');
- expect(gt.columns[0].table.style.width).toBe('auto');
- expect(gt.columns[0].table.style.tableLayout).toBe('auto');
- expect(gt.columns[0].table.nodeName).toBe('TABLE');
- expect(gt.columns[0].table.querySelectorAll('thead > tr > th').length).toBe(1);
- expect(gt.columns[0].table.querySelector('tbody > tr > td').innerHTML).toBe('Foo');
- samples.clear();
- samples.set(0, { strings: [{ value: 'Bar', row: 1 }, { value: 'Baz1234', row: 1 }] });
- gt.addColumn(1, samples);
- expect(gt.columns.length).toBe(2);
- expect(gt.columns[1].col).toBe(1);
- expect(gt.columns[1].table.className).toBe('htCore');
- expect(gt.columns[1].table.nodeName).toBe('TABLE');
- expect(gt.columns[1].table.querySelectorAll('thead > tr > th').length).toBe(1);
- expect(gt.columns[1].table.querySelector('tbody > tr > td').innerHTML).toBe('Bar');
- });
- it('should get valid widths', function () {
- var hot = handsontable(hotSettings);
- var widthSpy = jasmine.createSpy();
- var samples = new Map();
- gt = new Handsontable.__GhostTable(hot);
- samples.clear();
- samples.set(0, { strings: [{ value: 'Foo', col: 0 }, { value: 'Foo.....Bar', col: 0 }] });
- gt.addColumn(0, samples);
- samples.clear();
- samples.set(0, { strings: [{ value: 'Foo\nBar\nsqw', col: 1 }] });
- gt.addColumn(1, samples);
- samples.clear();
- samples.set(0, { strings: [{ value: 'Foo', col: 0 }, { value: 'Foo Bar', col: 0 }] });
- gt.addColumn(2, samples);
- gt.getWidths(widthSpy);
- expect(widthSpy.calls.count()).toBe(3);
- expect(widthSpy.calls.argsFor(0)[0]).toBe(0);
- expect(widthSpy.calls.argsFor(0)[1]).toBeAroundValue(87, 4);
- expect(widthSpy.calls.argsFor(1)[0]).toBe(1);
- expect(widthSpy.calls.argsFor(1)[1]).toBeAroundValue(41, 4);
- expect(widthSpy.calls.argsFor(2)[0]).toBe(2);
- expect(widthSpy.calls.argsFor(2)[1]).toBeAroundValue(68, 4);
- });
- });
- it('should reset internal state after call `clean` method', function () {
- var hot = handsontable(hotSettings);
- var samples = new Map();
- gt = new Handsontable.__GhostTable(hot);
- gt.addColumn(0, samples);
- gt.rows.push({});
- gt.getWidths(function () {});
- expect(gt.columns.length).toBe(1);
- expect(gt.samples).toBeDefined();
- expect(gt.injected).toBe(true);
- expect(gt.container).toBeDefined();
- expect(document.querySelector('.htGhostTable')).toBeDefined();
- gt.clean();
- expect(gt.columns.length).toBe(0);
- expect(gt.samples).toBe(null);
- expect(gt.injected).toBe(false);
- expect(gt.container).toBe(null);
- expect(document.querySelector('.htGhostTable')).toBe(null);
- });
- it('should be detected as vertical if at least one row is added', function () {
- var hot = handsontable(hotSettings);
- var samples = new Map();
- var gt = new Handsontable.__GhostTable(hot);
- gt.addRow(0, samples);
- expect(gt.isVertical()).toBe(true);
- expect(gt.isHorizontal()).toBe(false);
- });
- it('should be detected as horizontal if at least one column is added', function () {
- var hot = handsontable(hotSettings);
- var samples = new Map();
- var gt = new Handsontable.__GhostTable(hot);
- gt.addColumn(0, samples);
- expect(gt.isVertical()).toBe(false);
- expect(gt.isHorizontal()).toBe(true);
- });
- });
- /***/ }),
- /* 240 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('autocompleteValidator', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- describe('allowEmpty', function () {
- it('should validate empty cells positively (by default)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: [['some', 'sample', 'data']],
- columns: [{
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }, {
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }, {
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, '');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '', 0, 0, undefined, undefined);
- done();
- }, 100);
- });
- it('should validate empty cells positively when allowEmpty is set to true', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: [['some', 'sample', 'data']],
- columns: [{
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }, {
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }, {
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }],
- allowEmpty: true,
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, '');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '', 0, 0, undefined, undefined);
- done();
- }, 100);
- });
- it('should validate empty cells negatively when allowEmpty is set to false', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: [['some', 'sample', 'data']],
- columns: [{
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }, {
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }, {
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }],
- allowEmpty: false,
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, '');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '', 0, 0, undefined, undefined);
- done();
- }, 100);
- });
- it('should respect the allowEmpty property for a single column', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: [['some', 'sample', 'data']],
- columns: [{
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }, {
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true,
- allowEmpty: false
- }, {
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, '');
- setDataAtCell(0, 1, '');
- setDataAtCell(0, 2, '');
- setTimeout(function () {
- expect(onAfterValidate.calls.argsFor(0)).toEqual([true, '', 0, 0, undefined, undefined]);
- expect(onAfterValidate.calls.argsFor(1)).toEqual([false, '', 0, 1, undefined, undefined]);
- expect(onAfterValidate.calls.argsFor(2)).toEqual([true, '', 0, 2, undefined, undefined]);
- done();
- }, 100);
- });
- it('should work for null and undefined values in cells', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: [['some', 'sample', 'data']],
- columns: [{
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }, {
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }, {
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }],
- allowEmpty: false,
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, null);
- setDataAtCell(0, 1, void 0);
- setDataAtCell(0, 2, '');
- setTimeout(function () {
- expect(onAfterValidate.calls.argsFor(0)).toEqual([false, null, 0, 0, undefined, undefined]);
- expect(onAfterValidate.calls.argsFor(1)).toEqual([false, void 0, 0, 1, undefined, undefined]);
- expect(onAfterValidate.calls.argsFor(2)).toEqual([false, '', 0, 2, undefined, undefined]);
- done();
- }, 100);
- });
- });
- describe('strict mode', function () {
- it('sshould validate negatively when chars have different size', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- var hot = handsontable({
- data: [['some', 'sample', 'data']],
- columns: [{
- type: 'autocomplete',
- source: ['some', 'sample', 'data'],
- strict: true
- }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, 'Some');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, 'Some', 0, 0, undefined, undefined);
- done();
- }, 100);
- });
- });
- });
- /***/ }),
- /* 241 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('dateValidator', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfObjects = function arrayOfObjects() {
- return [{ date: '01/01/2015', name: 'Ted', lastName: 'Right' }, { date: '01/01/15', name: 'Frank', lastName: 'Honest' }, { date: '41/01/2015', name: 'Joan', lastName: 'Well' }, { date: '01/51/2015', name: 'Sid', lastName: 'Strong' }];
- };
- it('should validate an empty string (default behavior)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, '');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '', 0, 'date', undefined, undefined);
- done();
- }, 100);
- });
- it('should rewrite an ISO 8601 string to the correct format if a date-string in different format is provided', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date', dateFormat: 'MM/DD/YYYY', correctFormat: true }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '2016-03-18');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '2016-03-18', 1, 'date', undefined, undefined);
- }, 100);
- setTimeout(function () {
- expect(getDataAtCell(1, 0)).toEqual('03/18/2016');
- done();
- }, 130);
- });
- it('should not positively validate a non-date string', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, 'wat');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, 'wat', 0, 'date', undefined, undefined);
- done();
- }, 100);
- });
- it('should not positively validate a incorrect date string', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, '33/01/2014');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '33/01/2014', 0, 'date', undefined, undefined);
- done();
- }, 100);
- });
- it('should not positively validate a date string in wrong format', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '01/01/15');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '01/01/15', 1, 'date', undefined, undefined);
- done();
- }, 100);
- });
- it('should not positively validate a date string in wrong format (if custom format is provided)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date', dateFormat: 'DD/MM/YY' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '01/01/2015');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '01/01/2015', 1, 'date', undefined, undefined);
- done();
- }, 100);
- });
- it('should positively validate a date string in correct format', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '01/01/2015');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '01/01/2015', 1, 'date', undefined, undefined);
- done();
- }, 100);
- });
- it('should positively validate a date string in correct format (if custom format is provided)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date', dateFormat: 'DD/MM/YY' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '23/03/15');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '23/03/15', 1, 'date', undefined, undefined);
- done();
- }, 100);
- });
- describe('allowEmpty', function () {
- it('should not validate an empty string when allowEmpty is set as `false`', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date', dateFormat: 'DD/MM/YY', allowEmpty: false }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '', 1, 'date', undefined, undefined);
- done();
- }, 100);
- });
- it('should not validate `null` when allowEmpty is set as `false`', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date', dateFormat: 'DD/MM/YY', allowEmpty: false }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, null);
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, null, 1, 'date', undefined, undefined);
- done();
- }, 100);
- });
- it('should not validate `undefined` when allowEmpty is set as `false`', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date', dateFormat: 'DD/MM/YY', allowEmpty: false }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, void 0);
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, void 0, 1, 'date', undefined, undefined);
- done();
- }, 100);
- });
- });
- describe('correctFormat', function () {
- it('should not make any changes to entered string if correctFormat is not set', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date', dateFormat: 'MM/DD/YY' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '11/23/2013');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '11/23/2013', 1, 'date', undefined, undefined);
- done();
- }, 100);
- });
- it('should not make any changes to entered string if correctFormat is set to false', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date', dateFormat: 'MM/DD/YY', correctFormat: false }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '11/23/2013');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '11/23/2013', 1, 'date', undefined, undefined);
- done();
- }, 100);
- });
- it('should rewrite the string to the correct format if a date-string in different format is provided', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date', dateFormat: 'MM/DD/YYYY', correctFormat: true }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '1/10/15');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '1/10/15', 1, 'date', undefined, undefined);
- }, 100);
- setTimeout(function () {
- expect(getDataAtCell(1, 0)).toEqual('01/10/2015');
- done();
- }, 130);
- });
- it('should rewrite the string to the correct format if a date-string in different format is provided (for non-default format)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date', dateFormat: 'DD.MM.YYYY', correctFormat: true }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '5.3.2016');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '5.3.2016', 1, 'date', undefined, undefined);
- }, 100);
- setTimeout(function () {
- expect(getDataAtCell(1, 0)).toEqual('05.03.2016');
- done();
- }, 130);
- });
- it('should not try to correct format of non-date strings', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'date', type: 'date', dateFormat: 'DD/MM/YY', correctFormat: true }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, 'test non-date string');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, 'test non-date string', 1, 'date', undefined, undefined);
- done();
- }, 100);
- });
- });
- });
- /***/ }),
- /* 242 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
- describe('validators', function () {
- var id = 'testContainer';
- var _Handsontable$validat = Handsontable.validators,
- registerValidator = _Handsontable$validat.registerValidator,
- getValidator = _Handsontable$validat.getValidator;
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should register custom validator', _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
- var onAfterValidate, hot;
- return regeneratorRuntime.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- registerValidator('myValidator', function (value, cb) {
- cb(value === 10);
- });
- onAfterValidate = jasmine.createSpy('onAfterValidate');
- hot = handsontable({
- data: [[1, 6, 10]],
- columns: [{
- validator: 'myValidator'
- }],
- afterValidate: onAfterValidate
- });
- hot.setDataAtCell(1, 0, 10);
- _context.next = 6;
- return sleep(100);
- case 6:
- expect(onAfterValidate).toHaveBeenCalledWith(true, 10, 1, 0, undefined, undefined);
- hot.setDataAtCell(2, 0, 2);
- _context.next = 10;
- return sleep(100);
- case 10:
- expect(onAfterValidate).toHaveBeenCalledWith(false, 2, 2, 0, undefined, undefined);
- case 11:
- case 'end':
- return _context.stop();
- }
- }
- }, _callee, undefined);
- })));
- it('should retrieve predefined validators by its names', function () {
- expect(getValidator('autocomplete')).toBeFunction();
- expect(getValidator('date')).toBeFunction();
- expect(getValidator('numeric')).toBeFunction();
- expect(getValidator('time')).toBeFunction();
- });
- it('should retrieve custom validator by its names', function () {
- registerValidator('myValidator', function (value, cb) {
- cb(value === 10);
- });
- getValidator('myValidator')(2, function (isValid) {
- expect(isValid).toBe(false);
- });
- getValidator('myValidator')('10', function (isValid) {
- expect(isValid).toBe(false);
- });
- getValidator('myValidator')(10, function (isValid) {
- expect(isValid).toBe(true);
- });
- });
- });
- /***/ }),
- /* 243 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('numericValidator', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfObjects = function arrayOfObjects() {
- return [{ id: 1, name: 'Ted', lastName: 'Right' }, { id: 2, name: 'Frank', lastName: 'Honest' }, { id: 3, name: 'Joan', lastName: 'Well' }, { id: 4, name: 'Sid', lastName: 'Strong' }, { id: 5, name: 'Jane', lastName: 'Neat' }, { id: 6, name: 'Chuck', lastName: 'Jackson' }, { id: 7, name: 'Meg', lastName: 'Jansen' }, { id: 8, name: 'Rob', lastName: 'Norris' }, { id: 9, name: 'Sean', lastName: 'O\'Hara' }, { id: 10, name: 'Eve', lastName: 'Branson' }];
- };
- it('should validate an empty string (default behavior)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, '');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '', 2, 'id', undefined, undefined);
- done();
- }, 100);
- });
- it('should not validate non numeric string', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, 'test');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, 'test', 2, 'id', undefined, undefined);
- done();
- }, 100);
- });
- it('should validate numeric string', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, '123');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, 123, 2, 'id', undefined, undefined);
- done();
- }, 100);
- });
- it('should validate signed numeric string', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, '-123');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, -123, 2, 'id', undefined, undefined);
- done();
- }, 100);
- });
- describe('allowEmpty', function () {
- it('should not validate an empty string when allowEmpty is set as `false`', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric', allowEmpty: false }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, '');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '', 2, 'id', undefined, undefined);
- done();
- }, 100);
- });
- it('should not validate `null` when allowEmpty is set as `false`', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric', allowEmpty: false }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, null);
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, null, 2, 'id', undefined, undefined);
- done();
- }, 100);
- });
- it('should not validate `undefined` when allowEmpty is set as `false`', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric', allowEmpty: false }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, void 0);
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, void 0, 2, 'id', undefined, undefined);
- done();
- }, 100);
- });
- it('should validate 0 when allowEmpty is set as `false`', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'id', type: 'numeric', allowEmpty: false }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(2, 0, 0);
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, 0, 2, 'id', undefined, undefined);
- done();
- }, 100);
- });
- it('should add / remove `htInvalid` class properly when validating non-numeric data', function (done) {
- var hot = handsontable({
- data: [{ id: 1, name: 'Ted', salary: 10000 }, { id: 2, name: 'Frank', salary: '5300' }, { id: 3, name: 'Joan', salary: 'non-numeric value' }],
- columns: [{ data: 'id' }, { data: 'name' }, { data: 'salary', type: 'numeric', allowInvalid: false }]
- });
- hot.validateCells();
- setTimeout(function () {
- expect($(getCell(1, 2)).hasClass(hot.getSettings().invalidCellClassName)).toBe(false);
- expect($(getCell(2, 2)).hasClass(hot.getSettings().invalidCellClassName)).toBe(true);
- setDataAtCell(2, 2, 8000);
- }, 200);
- setTimeout(function () {
- expect($(getCell(2, 2)).hasClass(hot.getSettings().invalidCellClassName)).toBe(false);
- done();
- }, 400);
- });
- });
- });
- /***/ }),
- /* 244 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- describe('timeValidator', function () {
- var id = 'testContainer';
- beforeEach(function () {
- this.$container = $('<div id="' + id + '"></div>').appendTo('body');
- });
- afterEach(function () {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- var arrayOfObjects = function arrayOfObjects() {
- return [{ time: '4:10:05 am', name: 'Ted', lastName: 'Right' }, { time: '17:15:25', name: 'Frank', lastName: 'Honest' }, { time: '14:65:45 am', name: 'Joan', lastName: 'Well' }, { time: '33:25:05', name: 'Sid', lastName: 'Strong' }];
- };
- it('should validate an empty string (default behavior)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, '');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '', 0, 'time', undefined, undefined);
- done();
- }, 100);
- });
- it('should not positively validate a non-date format', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, 'nd');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, 'nd', 0, 'time', undefined, undefined);
- done();
- }, 100);
- });
- it('should not positively validate a incorrect time string', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(0, 0, '30:10:25');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '30:10:25', 0, 'time', undefined, undefined);
- done();
- }, 100);
- });
- it('should not positively validate a time string in not default format', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '20:20:01');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '20:20:01', 1, 'time', undefined, undefined);
- done();
- }, 100);
- });
- it('should not positively validate a time string in wrong format (if custom format is provided)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time', timeFormat: 'HH:mm:ss' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '5:10:15 am');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '5:10:15 am', 1, 'time', undefined, undefined);
- done();
- }, 100);
- });
- it('should positively validate a date string in correct format (if custom format is provided)', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time', timeFormat: 'HH:mm:ss' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '16:32:03');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '16:32:03', 1, 'time', undefined, undefined);
- done();
- }, 100);
- });
- describe('allowEmpty', function () {
- it('should not validate an empty string when allowEmpty is set as `false`', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time', dateFormat: 'HH:mm', allowEmpty: false }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '', 1, 'time', undefined, undefined);
- done();
- }, 100);
- });
- it('should not validate `null` when allowEmpty is set as `false`', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time', dateFormat: 'HH:mm', allowEmpty: false }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, null);
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, null, 1, 'time', undefined, undefined);
- done();
- }, 100);
- });
- it('should not validate `undefined` when allowEmpty is set as `false`', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time', dateFormat: 'HH:mm', allowEmpty: false }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, void 0);
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, void 0, 1, 'time', undefined, undefined);
- done();
- }, 100);
- });
- });
- describe('correctFormat', function () {
- it('should not make any changes to entered string if correctFormat is not set', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time', timeFormat: 'h:mm:ss a' }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '13:00:00');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '13:00:00', 1, 'time', undefined, undefined);
- done();
- }, 100);
- });
- it('should not make any changes to entered string if correctFormat is set to false', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time', timeFormat: 'h:mm:ss a', correctFormat: false }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '13:00:00');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, '13:00:00', 1, 'time', undefined, undefined);
- done();
- }, 100);
- });
- it('should rewrite the string to the correct format if a time-string in different format is provided', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time', timeFormat: 'h:mm:ss a', correctFormat: true }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '16:35:01');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '16:35:01', 1, 'time', undefined, undefined);
- }, 100);
- setTimeout(function () {
- expect(getDataAtCell(1, 0)).toEqual('4:35:01 pm');
- done();
- }, 130);
- });
- it('should rewrite the string to the correct format if a time in micro-timestamp format is provided', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time', timeFormat: 'HH:mm:ss', correctFormat: true }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- var currentDateTime = new Date();
- setDataAtCell(1, 0, currentDateTime.getTime()); // timestamp in milliseconds
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, currentDateTime.getTime(), 1, 'time', undefined, undefined);
- }, 100);
- setTimeout(function () {
- var addLeadingZero = function addLeadingZero(number) {
- return number < 10 ? '0' + number : number;
- };
- expect(getDataAtCell(1, 0)).toEqual(addLeadingZero(currentDateTime.getHours()) + ':' + addLeadingZero(currentDateTime.getMinutes()) + ':' + addLeadingZero(currentDateTime.getSeconds()));
- done();
- }, 130);
- });
- it('should rewrite the string to the correct format if a time in ISO8601 format is provided', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time', timeFormat: 'HH:mm:ss', correctFormat: true }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- var currentDateTime = new Date();
- setDataAtCell(1, 0, currentDateTime.toISOString()); // ISO-formatted datetime, sth like '2016-02-19T12:40:04.983Z'
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, currentDateTime.toISOString(), 1, 'time', undefined, undefined);
- }, 100);
- setTimeout(function () {
- var addLeadingZero = function addLeadingZero(number) {
- return number < 10 ? '0' + number : number;
- };
- expect(getDataAtCell(1, 0)).toEqual(addLeadingZero(currentDateTime.getHours()) + ':' + addLeadingZero(currentDateTime.getMinutes()) + ':' + addLeadingZero(currentDateTime.getSeconds()));
- done();
- }, 130);
- });
- it('should rewrite one and two-digit number to the correct format at hours', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time', timeFormat: 'hh:mm:ss a', correctFormat: true }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '19');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '19', 1, 'time', undefined, undefined);
- }, 100);
- setTimeout(function () {
- expect(getDataAtCell(1, 0)).toEqual('07:00:00 pm');
- done();
- }, 130);
- });
- it('should rewrite one and two-digit number to the correct format at minutes', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time', timeFormat: 'mm:ss', correctFormat: true }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, '57');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(true, '57', 1, 'time', undefined, undefined);
- }, 100);
- setTimeout(function () {
- expect(getDataAtCell(1, 0)).toEqual('57:00');
- done();
- }, 130);
- });
- it('should not try to correct format of non-date strings', function (done) {
- var onAfterValidate = jasmine.createSpy('onAfterValidate');
- handsontable({
- data: arrayOfObjects(),
- columns: [{ data: 'time', type: 'time', timeFormat: 'HH:mm:ss', correctFormat: true }, { data: 'name' }, { data: 'lastName' }],
- afterValidate: onAfterValidate
- });
- setDataAtCell(1, 0, 'test non-time string');
- setTimeout(function () {
- expect(onAfterValidate).toHaveBeenCalledWith(false, 'test non-time string', 1, 'time', undefined, undefined);
- done();
- }, 100);
- });
- });
- });
- /***/ }),
- /* 245 */,
- /* 246 */
- /***/ (function(module, exports) {
- /**
- * slice() reference.
- */
- var slice = Array.prototype.slice;
- /**
- * Expose `co`.
- */
- module.exports = co['default'] = co.co = co;
- /**
- * Wrap the given generator `fn` into a
- * function that returns a promise.
- * This is a separate function so that
- * every `co()` call doesn't create a new,
- * unnecessary closure.
- *
- * @param {GeneratorFunction} fn
- * @return {Function}
- * @api public
- */
- co.wrap = function (fn) {
- createPromise.__generatorFunction__ = fn;
- return createPromise;
- function createPromise() {
- return co.call(this, fn.apply(this, arguments));
- }
- };
- /**
- * Execute the generator function or a generator
- * and return a promise.
- *
- * @param {Function} fn
- * @return {Promise}
- * @api public
- */
- function co(gen) {
- var ctx = this;
- var args = slice.call(arguments, 1)
- // we wrap everything in a promise to avoid promise chaining,
- // which leads to memory leak errors.
- // see https://github.com/tj/co/issues/180
- return new Promise(function(resolve, reject) {
- if (typeof gen === 'function') gen = gen.apply(ctx, args);
- if (!gen || typeof gen.next !== 'function') return resolve(gen);
- onFulfilled();
- /**
- * @param {Mixed} res
- * @return {Promise}
- * @api private
- */
- function onFulfilled(res) {
- var ret;
- try {
- ret = gen.next(res);
- } catch (e) {
- return reject(e);
- }
- next(ret);
- }
- /**
- * @param {Error} err
- * @return {Promise}
- * @api private
- */
- function onRejected(err) {
- var ret;
- try {
- ret = gen.throw(err);
- } catch (e) {
- return reject(e);
- }
- next(ret);
- }
- /**
- * Get the next value in the generator,
- * return a promise.
- *
- * @param {Object} ret
- * @return {Promise}
- * @api private
- */
- function next(ret) {
- if (ret.done) return resolve(ret.value);
- var value = toPromise.call(ctx, ret.value);
- if (value && isPromise(value)) return value.then(onFulfilled, onRejected);
- return onRejected(new TypeError('You may only yield a function, promise, generator, array, or object, '
- + 'but the following object was passed: "' + String(ret.value) + '"'));
- }
- });
- }
- /**
- * Convert a `yield`ed value into a promise.
- *
- * @param {Mixed} obj
- * @return {Promise}
- * @api private
- */
- function toPromise(obj) {
- if (!obj) return obj;
- if (isPromise(obj)) return obj;
- if (isGeneratorFunction(obj) || isGenerator(obj)) return co.call(this, obj);
- if ('function' == typeof obj) return thunkToPromise.call(this, obj);
- if (Array.isArray(obj)) return arrayToPromise.call(this, obj);
- if (isObject(obj)) return objectToPromise.call(this, obj);
- return obj;
- }
- /**
- * Convert a thunk to a promise.
- *
- * @param {Function}
- * @return {Promise}
- * @api private
- */
- function thunkToPromise(fn) {
- var ctx = this;
- return new Promise(function (resolve, reject) {
- fn.call(ctx, function (err, res) {
- if (err) return reject(err);
- if (arguments.length > 2) res = slice.call(arguments, 1);
- resolve(res);
- });
- });
- }
- /**
- * Convert an array of "yieldables" to a promise.
- * Uses `Promise.all()` internally.
- *
- * @param {Array} obj
- * @return {Promise}
- * @api private
- */
- function arrayToPromise(obj) {
- return Promise.all(obj.map(toPromise, this));
- }
- /**
- * Convert an object of "yieldables" to a promise.
- * Uses `Promise.all()` internally.
- *
- * @param {Object} obj
- * @return {Promise}
- * @api private
- */
- function objectToPromise(obj){
- var results = new obj.constructor();
- var keys = Object.keys(obj);
- var promises = [];
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- var promise = toPromise.call(this, obj[key]);
- if (promise && isPromise(promise)) defer(promise, key);
- else results[key] = obj[key];
- }
- return Promise.all(promises).then(function () {
- return results;
- });
- function defer(promise, key) {
- // predefine the key in the result
- results[key] = undefined;
- promises.push(promise.then(function (res) {
- results[key] = res;
- }));
- }
- }
- /**
- * Check if `obj` is a promise.
- *
- * @param {Object} obj
- * @return {Boolean}
- * @api private
- */
- function isPromise(obj) {
- return 'function' == typeof obj.then;
- }
- /**
- * Check if `obj` is a generator.
- *
- * @param {Mixed} obj
- * @return {Boolean}
- * @api private
- */
- function isGenerator(obj) {
- return 'function' == typeof obj.next && 'function' == typeof obj.throw;
- }
- /**
- * Check if `obj` is a generator function.
- *
- * @param {Mixed} obj
- * @return {Boolean}
- * @api private
- */
- function isGeneratorFunction(obj) {
- var constructor = obj.constructor;
- if (!constructor) return false;
- if ('GeneratorFunction' === constructor.name || 'GeneratorFunction' === constructor.displayName) return true;
- return isGenerator(constructor.prototype);
- }
- /**
- * Check for plain object.
- *
- * @param {Mixed} val
- * @return {Boolean}
- * @api private
- */
- function isObject(val) {
- return Object == val.constructor;
- }
- /***/ }),
- /* 247 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
- var toObject = __webpack_require__(19)
- , toIndex = __webpack_require__(34)
- , toLength = __webpack_require__(9);
- module.exports = [].copyWithin || function copyWithin(target/*= 0*/, start/*= 0, end = @length*/){
- var O = toObject(this)
- , len = toLength(O.length)
- , to = toIndex(target, len)
- , from = toIndex(start, len)
- , end = arguments.length > 2 ? arguments[2] : undefined
- , count = Math.min((end === undefined ? len : toIndex(end, len)) - from, len - to)
- , inc = 1;
- if(from < to && to < from + count){
- inc = -1;
- from += count - 1;
- to += count - 1;
- }
- while(count-- > 0){
- if(from in O)O[to] = O[from];
- else delete O[to];
- to += inc;
- from += inc;
- } return O;
- };
- /***/ }),
- /* 248 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
- var toObject = __webpack_require__(19)
- , toIndex = __webpack_require__(34)
- , toLength = __webpack_require__(9);
- module.exports = function fill(value /*, start = 0, end = @length */){
- var O = toObject(this)
- , length = toLength(O.length)
- , aLen = arguments.length
- , index = toIndex(aLen > 1 ? arguments[1] : undefined, length)
- , end = aLen > 2 ? arguments[2] : undefined
- , endPos = end === undefined ? length : toIndex(end, length);
- while(endPos > index)O[index++] = value;
- return O;
- };
- /***/ }),
- /* 249 */
- /***/ (function(module, exports, __webpack_require__) {
- var isObject = __webpack_require__(3)
- , isArray = __webpack_require__(59)
- , SPECIES = __webpack_require__(1)('species');
- module.exports = function(original){
- var C;
- if(isArray(original)){
- C = original.constructor;
- // cross-realm fallback
- if(typeof C == 'function' && (C === Array || isArray(C.prototype)))C = undefined;
- if(isObject(C)){
- C = C[SPECIES];
- if(C === null)C = undefined;
- }
- } return C === undefined ? Array : C;
- };
- /***/ }),
- /* 250 */
- /***/ (function(module, exports, __webpack_require__) {
- // 9.4.2.3 ArraySpeciesCreate(originalArray, length)
- var speciesConstructor = __webpack_require__(249);
- module.exports = function(original, length){
- return new (speciesConstructor(original))(length);
- };
- /***/ }),
- /* 251 */
- /***/ (function(module, exports, __webpack_require__) {
- // all enumerable object keys, includes symbols
- var getKeys = __webpack_require__(17)
- , gOPS = __webpack_require__(32)
- , pIE = __webpack_require__(23);
- module.exports = function(it){
- var result = getKeys(it)
- , getSymbols = gOPS.f;
- if(getSymbols){
- var symbols = getSymbols(it)
- , isEnum = pIE.f
- , i = 0
- , key;
- while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))result.push(key);
- } return result;
- };
- /***/ }),
- /* 252 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- // 21.2.5.3 get RegExp.prototype.flags
- var anObject = __webpack_require__(4);
- module.exports = function(){
- var that = anObject(this)
- , result = '';
- if(that.global) result += 'g';
- if(that.ignoreCase) result += 'i';
- if(that.multiline) result += 'm';
- if(that.unicode) result += 'u';
- if(that.sticky) result += 'y';
- return result;
- };
- /***/ }),
- /* 253 */
- /***/ (function(module, exports, __webpack_require__) {
- var isObject = __webpack_require__(3)
- , setPrototypeOf = __webpack_require__(68).set;
- module.exports = function(that, target, C){
- var P, S = target.constructor;
- if(S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf){
- setPrototypeOf(that, P);
- } return that;
- };
- /***/ }),
- /* 254 */
- /***/ (function(module, exports) {
- // fast apply, http://jsperf.lnkit.com/fast-apply/5
- module.exports = function(fn, args, that){
- var un = that === undefined;
- switch(args.length){
- case 0: return un ? fn()
- : fn.call(that);
- case 1: return un ? fn(args[0])
- : fn.call(that, args[0]);
- case 2: return un ? fn(args[0], args[1])
- : fn.call(that, args[0], args[1]);
- case 3: return un ? fn(args[0], args[1], args[2])
- : fn.call(that, args[0], args[1], args[2]);
- case 4: return un ? fn(args[0], args[1], args[2], args[3])
- : fn.call(that, args[0], args[1], args[2], args[3]);
- } return fn.apply(that, args);
- };
- /***/ }),
- /* 255 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- var create = __webpack_require__(43)
- , descriptor = __webpack_require__(18)
- , setToStringTag = __webpack_require__(24)
- , IteratorPrototype = {};
- // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
- __webpack_require__(13)(IteratorPrototype, __webpack_require__(1)('iterator'), function(){ return this; });
- module.exports = function(Constructor, NAME, next){
- Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)});
- setToStringTag(Constructor, NAME + ' Iterator');
- };
- /***/ }),
- /* 256 */
- /***/ (function(module, exports, __webpack_require__) {
- var getKeys = __webpack_require__(17)
- , toIObject = __webpack_require__(8);
- module.exports = function(object, el){
- var O = toIObject(object)
- , keys = getKeys(O)
- , length = keys.length
- , index = 0
- , key;
- while(length > index)if(O[key = keys[index++]] === el)return key;
- };
- /***/ }),
- /* 257 */
- /***/ (function(module, exports, __webpack_require__) {
- var global = __webpack_require__(2)
- , macrotask = __webpack_require__(49).set
- , Observer = global.MutationObserver || global.WebKitMutationObserver
- , process = global.process
- , Promise = global.Promise
- , isNode = __webpack_require__(16)(process) == 'process';
- module.exports = function(){
- var head, last, notify;
- var flush = function(){
- var parent, fn;
- if(isNode && (parent = process.domain))parent.exit();
- while(head){
- fn = head.fn;
- head = head.next;
- try {
- fn();
- } catch(e){
- if(head)notify();
- else last = undefined;
- throw e;
- }
- } last = undefined;
- if(parent)parent.enter();
- };
- // Node.js
- if(isNode){
- notify = function(){
- process.nextTick(flush);
- };
- // browsers with MutationObserver
- } else if(Observer){
- var toggle = true
- , node = document.createTextNode('');
- new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new
- notify = function(){
- node.data = toggle = !toggle;
- };
- // environments with maybe non-completely correct, but existent Promise
- } else if(Promise && Promise.resolve){
- var promise = Promise.resolve();
- notify = function(){
- promise.then(flush);
- };
- // for other environments - macrotask based on:
- // - setImmediate
- // - MessageChannel
- // - window.postMessag
- // - onreadystatechange
- // - setTimeout
- } else {
- notify = function(){
- // strange IE + webpack dev server bug - use .call(global)
- macrotask.call(global, flush);
- };
- }
- return function(fn){
- var task = {fn: fn, next: undefined};
- if(last)last.next = task;
- if(!head){
- head = task;
- notify();
- } last = task;
- };
- };
- /***/ }),
- /* 258 */
- /***/ (function(module, exports, __webpack_require__) {
- var dP = __webpack_require__(5)
- , anObject = __webpack_require__(4)
- , getKeys = __webpack_require__(17);
- module.exports = __webpack_require__(6) ? Object.defineProperties : function defineProperties(O, Properties){
- anObject(O);
- var keys = getKeys(Properties)
- , length = keys.length
- , i = 0
- , P;
- while(length > i)dP.f(O, P = keys[i++], Properties[P]);
- return O;
- };
- /***/ }),
- /* 259 */
- /***/ (function(module, exports, __webpack_require__) {
- // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
- var toIObject = __webpack_require__(8)
- , gOPN = __webpack_require__(45).f
- , toString = {}.toString;
- var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
- ? Object.getOwnPropertyNames(window) : [];
- var getWindowNames = function(it){
- try {
- return gOPN(it);
- } catch(e){
- return windowNames.slice();
- }
- };
- module.exports.f = function getOwnPropertyNames(it){
- return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
- };
- /***/ }),
- /* 260 */
- /***/ (function(module, exports, __webpack_require__) {
- // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
- var has = __webpack_require__(7)
- , toObject = __webpack_require__(19)
- , IE_PROTO = __webpack_require__(46)('IE_PROTO')
- , ObjectProto = Object.prototype;
- module.exports = Object.getPrototypeOf || function(O){
- O = toObject(O);
- if(has(O, IE_PROTO))return O[IE_PROTO];
- if(typeof O.constructor == 'function' && O instanceof O.constructor){
- return O.constructor.prototype;
- } return O instanceof Object ? ObjectProto : null;
- };
- /***/ }),
- /* 261 */
- /***/ (function(module, exports, __webpack_require__) {
- // all object keys, includes non-enumerable and symbols
- var gOPN = __webpack_require__(45)
- , gOPS = __webpack_require__(32)
- , anObject = __webpack_require__(4)
- , Reflect = __webpack_require__(2).Reflect;
- module.exports = Reflect && Reflect.ownKeys || function ownKeys(it){
- var keys = gOPN.f(anObject(it))
- , getSymbols = gOPS.f;
- return getSymbols ? keys.concat(getSymbols(it)) : keys;
- };
- /***/ }),
- /* 262 */
- /***/ (function(module, exports) {
- // 7.2.9 SameValue(x, y)
- module.exports = Object.is || function is(x, y){
- return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
- };
- /***/ }),
- /* 263 */
- /***/ (function(module, exports, __webpack_require__) {
- // 7.3.20 SpeciesConstructor(O, defaultConstructor)
- var anObject = __webpack_require__(4)
- , aFunction = __webpack_require__(36)
- , SPECIES = __webpack_require__(1)('species');
- module.exports = function(O, D){
- var C = anObject(O).constructor, S;
- return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
- };
- /***/ }),
- /* 264 */
- /***/ (function(module, exports, __webpack_require__) {
- var toInteger = __webpack_require__(35)
- , defined = __webpack_require__(11);
- // true -> String#at
- // false -> String#codePointAt
- module.exports = function(TO_STRING){
- return function(that, pos){
- var s = String(defined(that))
- , i = toInteger(pos)
- , l = s.length
- , a, b;
- if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
- a = s.charCodeAt(i);
- return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
- ? TO_STRING ? s.charAt(i) : a
- : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
- };
- };
- /***/ }),
- /* 265 */
- /***/ (function(module, exports, __webpack_require__) {
- var global = __webpack_require__(2)
- , core = __webpack_require__(20)
- , LIBRARY = __webpack_require__(31)
- , wksExt = __webpack_require__(72)
- , defineProperty = __webpack_require__(5).f;
- module.exports = function(name){
- var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
- if(name.charAt(0) != '_' && !(name in $Symbol))defineProperty($Symbol, name, {value: wksExt.f(name)});
- };
- /***/ }),
- /* 266 */
- /***/ (function(module, exports) {
- /**
- * Export generator function checks.
- */
- module.exports = isGenerator
- module.exports.fn = isGeneratorFunction
- /**
- * Check whether an object is a generator.
- *
- * @param {Object} obj
- * @return {Boolean}
- */
- function isGenerator (obj) {
- return obj &&
- typeof obj.next === 'function' &&
- typeof obj.throw === 'function'
- }
- /**
- * Check whether a function is generator.
- *
- * @param {Function} fn
- * @return {Boolean}
- */
- function isGeneratorFunction (fn) {
- return typeof fn === 'function' &&
- fn.constructor &&
- fn.constructor.name === 'GeneratorFunction'
- }
- /***/ })
- /******/ ]);
- //# sourceMappingURL=e2e.entry.js.map
|