Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit testing, update testing infrastructure (add nyc, add uncache…
…d require, remove defaults in test.js), eslint-disable no-console in config.js, refactoring checkChallenge (#287) * refactor MIBL * fix * smaller * clearer function naming * tweaked handicap code * handicap minor changes * standardize number of handicap stones and number of periods functions * move handicap to periods, make rank a specific function this is because number of handicap and number of periods share many similarities, while rank function is different, among which "your rank is too low", and arg and notif conversions to displayable ranks (ex: 5k) * fix devel's canadian return, and enhance canadian check no need to multiply arg if we divide notif by number of stones this way we also get a notif per stone same as fischer and all other time controls * minor fixes * move handicap periods function above main periodtime function this matches chronological order * move handicap and periods part 2 * move getBlitzLiveCorr to match chronological order * simplify isMin code * rename .minMax to .miniMaxi * remove familyObject * much clearer undefined check for number args * clearer canadian periodtime info * clearer canadian explanation * minor * clearer * fix old description * enhanced argNameString check check argNameString before checking config[argNameString] so we avoid undefined error while also checking strictly for undefined for booleanly false number values such as 0 * fix * replace setting[0] setting[1] setting[2] with [timecontrolName, timecontrolDescr, timecontrolNotif] = timecontrolArr; * fix canadian periodtime unconverted notification displayed * rename checkMinMaxCondition to checkNotifIsInMinMaxArgRange * fix non-byoyomi time controls always rejecting challenge number of periods * fix display canadian periodtime for all the X stones * fix .includes * be non-strict in minmax comparisons minhandicap 0 maxhandicap 2 should allow - min => 0 or higher - max => 2 or lower 0,1, 2 being non-strict would allow only value 1 * fix binary division loss of precision: multiply arg, dont divide notif for canadian periodtime (for all the X stones) * clearer comments, check for timecontrol at the earliest * unfinished * fix mismatch from devel after auto fix merge conflicts to latest * add getMinMaxReject, refactor to be more abstract * use object to access timecontrol info, add sanity check timecontrol notif * various fixes in connection.js from local testing in checkChallenge.test.js * rename test/uhmaeat.test.js -> test/checkChallenge.test.js * add testing for minmaintimeblitz and minperiodtimeblitz * add maintime and periodtime blitz in byoyomi testing (to debug config) config is currently not renewed before each "it" * fix test with a workaround: overwrite old config inputs this is not clean but works, until we can review and enhance it * add byoyomi live timesettings testing * add nested describe for "Bans" and "Byoyomi time settings" * add tests for byoyomi correspondence time settings * fix indentation * fix connection.js based on added rank testing * add min max rank testing * add testing for handicap and fakerank * add missing fakerank test * add canadian testing * Updated test infrastructure * fix merge conflicts * add .nyc_output to .gitignore, replace let with const in testing * remove fixed manual need to erase previous config before each test these spots were marked like this: // remove old vars // this is not clean but it is a workaround until we review this * remove allowed families defaults in test.js and fix connection.js these lines in test.js: config.allowed_boardsizes[19] = true; config.allow_all_komis = true; config.allowed_speeds['live'] = true; config.allowed_timecontrols['fischer'] = true; are not needed in test.js, which does not check challenges, so they should be in checkChallenge.test.js however removing them showed that our connection.js does not check for config.boardsizes (for example), which makes sense because we have defaults so they are assumed always defined so adding a check in connection.js makes connection.js more solid, and it also allows to have a cleaner test.js these removed values should be tested in checkChallenge.test.js individually, not globally * add abstraction layers to avoid repetitions in allowed families * add no numbers of periods check for non-byoyomi time controls * add semicolon }); in describes in checkChallenge.test.js * fix maintime and periodtime being checked even if they should not for example "simple" time control has no main time, so we can skip the main time check * add limited time controls tests, ex: "none" has no time settings so do not check unexisting settings * add testing for canadian time controls * add canadian maintime testing * add testing for ranked unranked precedence rules * add testing for fischer time settings * add testing for simple time settings * add absolute time settings testing * add testing for allowed families, refactor allowed families * fix boardsizes in connection.js and test against connection.js, not config.js * replace let with const in checkChallenge.test.js * minor fixes * add .vscode to gitignore * minor various tweaks and fixes * minor * various fixes, move some functions to /utils * fix * add process exports functions for allowed families and bans * fixes * add checkChallengeHandicap, noautohandicap is true if minhandicap > 0 * finished adding all fixed from @Dorus 's review * refactor booleans ranked unranked checks * fix * split checkChallenge Mandatory into User and Bot * minor fix indentation * fix config undefined in new instances of Connection * add getNewConnection() * clearer noautohandicap description * follow logical order foreign modules / utils shared / gtp2ogs modules * remove console import in config.js if bot admin inputs a wrong set of argv and values, it's a good idea to stop current run of gtp2ogs with a throw and kill gtp2ogs, rather than use console.error which also requires process.exit console.error is better used in other modules where the error (ex: gamedata change, bot failed to start in one game) is not a reason to stop our gtp2ogs altogether, so we beautify the line of error in logging however throw is simpler and already provides line of error information * disable no-console ESLint rule in config.js explanations are in DEV.md * remove debug line, minor cleanup * fix order * add unit testing for rankedonly and unrankedonly * add speeds sanity check: unknown speeds make time settings uncheckable unknown speed "turbo" would make --minmaintimeturbo uncheckable (does not exist) * unknown speed makes challenge uncheckable, add sanity check * move sanity Checks on top of checkChallenge, add unit testing move err method out of class Connection remove unused ok method * fix remove duplicate tests * add link to visual studio code testing extensions in DEV.md * fix no handicap games * fixes * fix formatting in checkChallenge.test.js Co-authored-by: Dorus <[email protected]>
- Loading branch information