Skip to content

Commit

Permalink
fix: revert ef6f01a
Browse files Browse the repository at this point in the history
  • Loading branch information
Falx committed May 17, 2022
1 parent 1c557f7 commit 63bc029
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/http/representation/RepresentationPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {@link 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.
Expand Down
4 changes: 2 additions & 2 deletions src/storage/routing/PreferenceSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
7 changes: 4 additions & 3 deletions test/unit/storage/routing/PreferenceSupport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
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<void> => {
Expand Down

0 comments on commit 63bc029

Please sign in to comment.