Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

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;
}
11 changes: 10 additions & 1 deletion 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 All @@ -56,4 +65,4 @@ describe('canonical-title-map.js', () => {
result.should.be.deep.equal(titlemap);
});
});
});
});