-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert EnumSpecIndex into a class #165
Conversation
private _encodings: EncodingsEnumSpecIndex; | ||
private _encodingIndicesByProperty: Dict<number[]>; | ||
|
||
constructor(mark: EnumSpec<Mark>, encodings: EncodingsEnumSpecIndex, encodingIndicesByProperty: Dict<number[]>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of adding these parameters, if the only case is to set them to undefined and {}.
Remove the params and just initialize them correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Now I see that you use them for the test. Still, you should make these params optional with default values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think let's remove these parameter anyway. Using constructor to cheat might produce an enumSpecIndex that's not practical in practice.
describe('isEmpty', () => { | ||
it('should return false if encoding property is set', () => { | ||
let enumSpecIndex = new EnumSpecIndex() | ||
.setEncodingProperty(0, Property.SCALE, SHORT_ENUM_SPEC); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why TS doesn't complain yet, but we never set these to SHORT_ENUM_SPEC and it doesn't match the type. Better fix them with full enum spec; otherwise, it might throw error when we upgrade to future version of TS.
Fix #164 - Refactor EnumSpecIndex to be a class with relevant tests.