diff --git a/core/templates/dev/head/domain/exploration/ParamTypeObjectFactory.ts b/core/templates/dev/head/domain/exploration/ParamTypeObjectFactory.ts index b9392d862b44..efa9bf275c13 100644 --- a/core/templates/dev/head/domain/exploration/ParamTypeObjectFactory.ts +++ b/core/templates/dev/head/domain/exploration/ParamTypeObjectFactory.ts @@ -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 */ } } diff --git a/core/templates/dev/head/domain/exploration/ParamTypeObjectFactorySpec.ts b/core/templates/dev/head/domain/exploration/ParamTypeObjectFactorySpec.ts index 8d691369f9c8..ed3afc62324f 100644 --- a/core/templates/dev/head/domain/exploration/ParamTypeObjectFactorySpec.ts +++ b/core/templates/dev/head/domain/exploration/ParamTypeObjectFactorySpec.ts @@ -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');