refactor: Change PreferenceSupport constructor to work with Components.js

This commit is contained in:
Joachim Van Herwegen 2020-11-03 10:38:22 +01:00
parent 50dfea1a27
commit ef6f01a82c
2 changed files with 5 additions and 5 deletions

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(preferences: RepresentationPreferences, converter: RepresentationConverter) { public constructor(type: string, converter: RepresentationConverter) {
this.preferences = preferences; this.preferences = { type: [{ value: type, weight: 1 }]};
this.converter = converter; this.converter = converter;
} }

View File

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