From ef6f01a82cc3c17d6b77b824ace707e2602732a0 Mon Sep 17 00:00:00 2001 From: Joachim Van Herwegen Date: Tue, 3 Nov 2020 10:38:22 +0100 Subject: [PATCH] refactor: Change PreferenceSupport constructor to work with Components.js --- src/storage/routing/PreferenceSupport.ts | 4 ++-- test/unit/storage/routing/PreferenceSupport.test.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/storage/routing/PreferenceSupport.ts b/src/storage/routing/PreferenceSupport.ts index 67d1c1d7a..164834631 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(preferences: RepresentationPreferences, converter: RepresentationConverter) { - this.preferences = preferences; + public constructor(type: string, converter: RepresentationConverter) { + this.preferences = { type: [{ value: type, weight: 1 }]}; this.converter = converter; } diff --git a/test/unit/storage/routing/PreferenceSupport.test.ts b/test/unit/storage/routing/PreferenceSupport.test.ts index 4498e3f53..4a8ecb3ee 100644 --- a/test/unit/storage/routing/PreferenceSupport.test.ts +++ b/test/unit/storage/routing/PreferenceSupport.test.ts @@ -6,16 +6,16 @@ import { PreferenceSupport } from '../../../../src/storage/routing/PreferenceSup import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError'; describe('A PreferenceSupport', (): void => { - let preferences: RepresentationPreferences; + const type = 'internal/quads'; + const preferences: RepresentationPreferences = { type: [{ value: type, weight: 1 }]}; let converter: RepresentationConverter; let support: PreferenceSupport; const identifier: ResourceIdentifier = 'identifier' as any; const representation: Representation = 'representation' as any; beforeEach(async(): Promise => { - preferences = { type: []}; converter = { canHandle: jest.fn() } as any; - support = new PreferenceSupport(preferences, converter); + support = new PreferenceSupport(type, converter); }); it('returns true if the converter supports the input.', async(): Promise => {