fix: revert ef6f01a

This commit is contained in:
Thomas Dupont 2022-05-16 10:58:56 +02:00 committed by Joachim Van Herwegen
parent 5989a1fdc5
commit afed963a23
3 changed files with 11 additions and 6 deletions

View File

@ -6,8 +6,12 @@
* "The weight is normalized to a real number in the range 0 through 1, * "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 * where 0.001 is the least preferred and 1 is the most preferred; a
* value of 0 means "not acceptable"." * value of 0 means "not acceptable"."
*
* Because of an open issue in Components.js we cannot use `Record<string, number>` right now.
* https://github.com/LinkedSoftwareDependencies/Components-Generator.js/issues/103
*/ */
export type ValuePreferences = Record<string, number>; // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
export type ValuePreferences = {[key: string ]: number };
/** /**
* A single entry of a {@link ValuePreferences} object. * A single entry of a {@link ValuePreferences} object.

View File

@ -14,8 +14,8 @@ export class PreferenceSupport {
private readonly preferences: RepresentationPreferences; private readonly preferences: RepresentationPreferences;
private readonly converter: RepresentationConverter; private readonly converter: RepresentationConverter;
public constructor(type: string, converter: RepresentationConverter) { public constructor(preferences: RepresentationPreferences, converter: RepresentationConverter) {
this.preferences = { type: { [type]: 1 }}; this.preferences = preferences;
this.converter = converter; this.converter = converter;
} }

View File

@ -6,16 +6,17 @@ import { PreferenceSupport } from '../../../../src/storage/routing/PreferenceSup
import { BadRequestHttpError } from '../../../../src/util/errors/BadRequestHttpError'; import { BadRequestHttpError } from '../../../../src/util/errors/BadRequestHttpError';
describe('A PreferenceSupport', (): void => { describe('A PreferenceSupport', (): void => {
const type = 'internal/quads'; let preferences: RepresentationPreferences;
const preferences: RepresentationPreferences = { type: { [type]: 1 }};
let converter: RepresentationConverter; let converter: RepresentationConverter;
let support: PreferenceSupport; let support: PreferenceSupport;
const type = 'internal/quads';
const identifier: ResourceIdentifier = 'identifier' as any; const identifier: ResourceIdentifier = 'identifier' as any;
const representation: Representation = 'representation' as any; const representation: Representation = 'representation' as any;
beforeEach(async(): Promise<void> => { beforeEach(async(): Promise<void> => {
preferences = { type: { [type]: 1 }};
converter = { canHandle: jest.fn() } as any; 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<void> => { it('returns true if the converter supports the input.', async(): Promise<void> => {