Skip to content
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

Merged
merged 9 commits into from
Aug 2, 2016

Conversation

espressoroaster
Copy link
Member

@espressoroaster espressoroaster commented Aug 2, 2016

Fix #164 - Refactor EnumSpecIndex to be a class with relevant tests.

private _encodings: EncodingsEnumSpecIndex;
private _encodingIndicesByProperty: Dict<number[]>;

constructor(mark: EnumSpec<Mark>, encodings: EncodingsEnumSpecIndex, encodingIndicesByProperty: Dict<number[]>) {
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

@espressoroaster espressoroaster changed the title [WIP] Convert EnumSpecIndex into a class Convert EnumSpecIndex into a class Aug 2, 2016
describe('isEmpty', () => {
it('should return false if encoding property is set', () => {
let enumSpecIndex = new EnumSpecIndex()
.setEncodingProperty(0, Property.SCALE, SHORT_ENUM_SPEC);
Copy link
Member

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.

@kanitw kanitw merged commit 841b572 into master Aug 2, 2016
@kanitw kanitw deleted the fo/164-convert-enumSpecIndex-class branch August 2, 2016 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants