Skip to content

Commit

Permalink
Fix oppia#7363: Repair getTypeFromBackendName in ParamTypeObjectFacto…
Browse files Browse the repository at this point in the history
…ry.ts (oppia#7364)
  • Loading branch information
vojtechjelinek authored and DubeySandeep committed Aug 12, 2019
1 parent 4f76925 commit f8d542f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class ParamTypeObjectFactory {
// The bracket notation is needed since 'backendName' is a dynamic property
// and is not defined on 'registry'.
/* eslint-disable dot-notation */
return this.registry['backendName'];
return this.registry[backendName];
/* eslint-enable dot-notation */
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ describe('ParamType objects', () => {
expect(paramType.getDefaultType()).toBe(paramType.registry.UnicodeString);
});

it('should return correct values for existing types', () => {
Object.entries(paramType.registry).forEach(([backendName, value]) => {
expect(paramType.getTypeFromBackendName(backendName)).toEqual(value);
});
});

it('should throw for non-existant types', () => {
expect(() => {
paramType.getTypeFromBackendName('MissingType');
Expand Down

0 comments on commit f8d542f

Please sign in to comment.