Skip to content

Commit

Permalink
feat: links now comply with route override
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateus Garcia committed Apr 20, 2023
1 parent b990c56 commit a8c9369
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class TransformMixinService<T> {
include: string[] = [],
table = this.currentResourceName
): ResourceData<T> {
const urlTable = camelToKebab(table);
const urlTable = this.config?.['overrideRoute'] || camelToKebab(table);
const attributes = {} as Attributes<Omit<T, 'id'>>;
const relationships = {} as Partial<Relationships<T>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,23 @@ describe('GetOne methode test', () => {
}
});

it('should be correct if route is overriden', async () => {
expect.assertions(2);
configParam.overrideRoute = 'overridden';

const response = await typeormService.getOne({
query: defaultField,
route: { id: params },
});

expect(response.data['relationships'].addresses.links.related).toContain(
'overridden'
);
expect(response.data['relationships'].addresses.links.self).toContain(
'overridden'
);
});

it('should be error if item not exist', async () => {
expect.assertions(1);
configParam.requiredSelectField = false;
Expand Down

0 comments on commit a8c9369

Please sign in to comment.