diff --git a/src/http/representation/RepresentationPreferences.ts b/src/http/representation/RepresentationPreferences.ts index c1adcd5e4..6eb5565dd 100644 --- a/src/http/representation/RepresentationPreferences.ts +++ b/src/http/representation/RepresentationPreferences.ts @@ -6,8 +6,12 @@ * "The weight is normalized to a real number in the range 0 through 1, * where 0.001 is the least preferred and 1 is the most preferred; a * value of 0 means "not acceptable"." + * + * Because of an open issue in Components.js we cannot use `Record` right now. + * https://github.com/LinkedSoftwareDependencies/Components-Generator.js/issues/103 */ -export type ValuePreferences = Record; +// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style +export type ValuePreferences = {[key: string ]: number }; /** * A single entry of a {@link ValuePreferences} object. diff --git a/src/storage/routing/PreferenceSupport.ts b/src/storage/routing/PreferenceSupport.ts index 886b59460..7fbed602e 100644 --- a/src/storage/routing/PreferenceSupport.ts +++ b/src/storage/routing/PreferenceSupport.ts @@ -14,8 +14,8 @@ export class PreferenceSupport { private readonly preferences: RepresentationPreferences; private readonly converter: RepresentationConverter; - public constructor(type: string, converter: RepresentationConverter) { - this.preferences = { type: { [type]: 1 }}; + public constructor(preferences: RepresentationPreferences, converter: RepresentationConverter) { + this.preferences = preferences; this.converter = converter; } diff --git a/test/unit/storage/routing/PreferenceSupport.test.ts b/test/unit/storage/routing/PreferenceSupport.test.ts index 8ecfe32d0..eb11c5052 100644 --- a/test/unit/storage/routing/PreferenceSupport.test.ts +++ b/test/unit/storage/routing/PreferenceSupport.test.ts @@ -6,16 +6,17 @@ import { PreferenceSupport } from '../../../../src/storage/routing/PreferenceSup import { BadRequestHttpError } from '../../../../src/util/errors/BadRequestHttpError'; describe('A PreferenceSupport', (): void => { - const type = 'internal/quads'; - const preferences: RepresentationPreferences = { type: { [type]: 1 }}; + let preferences: RepresentationPreferences; let converter: RepresentationConverter; let support: PreferenceSupport; + const type = 'internal/quads'; const identifier: ResourceIdentifier = 'identifier' as any; const representation: Representation = 'representation' as any; beforeEach(async(): Promise => { + preferences = { type: { [type]: 1 }}; converter = { canHandle: jest.fn() } as any; - support = new PreferenceSupport(type, converter); + support = new PreferenceSupport(preferences, converter); }); it('returns true if the converter supports the input.', async(): Promise => {