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

fix(canonical-title-map): add use case for enumNames #8

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/lib/canonical-title-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ export default function(titleMap: Array<any>, originalEnum?: any) {
});
}
return canonical;
} else if (originalEnum) {
const canonical = [];
Copy link

@scottux scottux Jan 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definition of canonical doesn't seem to be used. I think it is safe to remove it.

return originalEnum.map((value, index) => {
if (typeof titleMap[index] === 'string') {
return {
name: titleMap[index],
value,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove trailing comma here.

}
}
return titleMap[index];
});
}
return titleMap;
}
9 changes: 9 additions & 0 deletions src/lib/canonical-title-map.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ describe('canonical-title-map.js', () => {
result.should.be.deep.equal(titlemap);
});

it('should return a titleMap for a enumNames list with enum values', () => {
let result = canonicalTitleMap([ 'name', 'firstname', 'phone' ], [ 'n', 'f', 'p' ]);
result.should.be.deep.equal([
{ name: 'name', value: 'n' },
{ name: 'firstname', value: 'f' },
{ name: 'phone', value: 'p' },
]);
});

it('should return a titleMap for a titleMap object without enum', () => {
let result = canonicalTitleMap(titlemapObj);
result.should.be.deep.equal(titlemap);
Expand Down