Beta
Basic array operations - WoW Server
Loading description...
Algorithms
Arrays
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
You need to set
chai.config.truncateThreshold = 0
like this:Should be fixed ;)
The tests require the players to be kept track in a specific order (specifically, ordered by insert time ascending. Otherwise
remove
will yield different results). This is not mentioned, and very unexpected: the server should have a collection (and not an array) of players, which does not have a notion of implicit order.What do you think about adding incremential
Id
or some kind ofcreation timestamp
toCharacter
and modification of description to:Either that, or just specify that it's meant to be stored as a list and filtering is done as list filtering, so sequentially.
Array
only appears in the title and nowhere in the description.Updated description, hope it will be now clear.
Some test cases look like they are written with no proper knowledge of JS/TS:
This does not do what you expect: it's calling
server.remove("Troll 12", 5, undefined, undefined)
instead ofserver.remove("Troll 12", undefined, undefined, 5)
. It only passes the typing test becauseClass.Dh
's enum value is also5
(aka it's actuallyserver.remove("Troll 12", Class.Dh, undefined, undefined)
).In general this will be a pain for everyone to write code against this, including you. It'd be better to use a special
filter
object that has every field optional, then havecount
be the second argument.You are right.
It's relict of old interface before (new ideas) changes applied. I missed this one to updated by
undefined
params.And you are right, for normal use the filter object would make sense. I kinda didnt want to add more boiler plate things and didnt expect (at first) so "many" params.
Test fixed.
There are lots of things missing in the tests and description:
name
should be case-insensitiveremove
/removeFirst
does not test the above even thoughfind
doesIf count is undefined do NOT remove characters
, but this is not tested. But then why iscount
optional when beingundefined
just has no effects? It seems like a poorly designed API. (In fact the tests are already misusing this API, this will be a separate issue)remove
/removeFirst
at all, since a default no-op implementation will pass the tests chosen to be put intoname
for allfind
/remove
APIs to catch improper optional checkingThanks for feedback!
Working on fixes.
modified description
Added missing tests.
Changed base logic (undefined count should be replaced with default value: 1) (and modified description)
Added sample tests for removes
about empty
name
.. it seems kinda logic, but.. noone said that empty string isinvalid name
. so.. empty string as filter doesnt seems to be sth which (right now) should be treated as optinal.i wonder if its better to change description (so empty string is invalid name) or add validation if someone (by mistake) didnt treated it as optional
The point is that checking for
undefined
should be explicit, and not just checking on truthy/falsy values, since empty string is also falsy. There will definitely be someone doing this if you don't specifically test for it ;-)Oh, now i understand what you meant.
Today i learned one more thing about
js
. Thanks. Will fix.