Skip to content

Commit

Permalink
fix(temporary): duplicates and detaching query parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzarbn committed Mar 30, 2021
1 parent c971ecb commit 56ecd05
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tailflow/laravel-orion",
"version": "1.0.0",
"version": "1.0.1",
"description": "Typescript SDK for Laravel Orion",
"keywords": [
"laravel orion",
Expand Down
8 changes: 4 additions & 4 deletions src/drivers/default/relations/belongsToMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class BelongsToMany<
const response = await this.httpClient.request(
`/attach`,
HttpMethod.POST,
{ duplicates },
{ duplicates: duplicates ? 1 : 0 },
{
resources: keys,
}
Expand All @@ -40,7 +40,7 @@ export class BelongsToMany<
const response = await this.httpClient.request(
`/attach`,
HttpMethod.POST,
{ duplicates },
{ duplicates: duplicates ? 1 : 0 },
{ resources }
);

Expand All @@ -67,7 +67,7 @@ export class BelongsToMany<
const response = await this.httpClient.request(
`/sync`,
HttpMethod.PATCH,
{ detaching },
{ detaching: detaching ? 1 : 0 },
{
resources: keys,
}
Expand All @@ -83,7 +83,7 @@ export class BelongsToMany<
const response = await this.httpClient.request(
`/sync`,
HttpMethod.PATCH,
{ detaching },
{ detaching: detaching ? 1 : 0 },
{ resources }
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('BelongsToMany tests', () => {
expect(attachResult.attached).toStrictEqual([2, 5, 7]);

const requests = server.pretender.handledRequests;
expect(requests[0].queryParams).toStrictEqual({ duplicates: 'false' });
expect(requests[0].queryParams).toStrictEqual({ duplicates: '0' });
});

test('attaching resources with duplicates', async () => {
Expand All @@ -51,7 +51,7 @@ describe('BelongsToMany tests', () => {
await belongsToManyRelation.attach([2, 5, 7], true);

const requests = server.pretender.handledRequests;
expect(requests[0].queryParams).toStrictEqual({ duplicates: 'true' });
expect(requests[0].queryParams).toStrictEqual({ duplicates: '1' });
});

test('attaching resources with fields', async () => {
Expand All @@ -73,7 +73,7 @@ describe('BelongsToMany tests', () => {
expect(attachResult.attached).toStrictEqual(['2', '5']);

const requests = server.pretender.handledRequests;
expect(requests[0].queryParams).toStrictEqual({ duplicates: 'false' });
expect(requests[0].queryParams).toStrictEqual({ duplicates: '0' });
});

test('attaching resources with fields with duplicates', async () => {
Expand All @@ -95,7 +95,7 @@ describe('BelongsToMany tests', () => {
);

const requests = server.pretender.handledRequests;
expect(requests[0].queryParams).toStrictEqual({ duplicates: 'true' });
expect(requests[0].queryParams).toStrictEqual({ duplicates: '1' });
});

test('detaching resources', async () => {
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('BelongsToMany tests', () => {
expect(syncResult.detached).toStrictEqual([2, 5, 7]);

const requests = server.pretender.handledRequests;
expect(requests[0].queryParams).toStrictEqual({ detaching: 'true' });
expect(requests[0].queryParams).toStrictEqual({ detaching: '1' });
});

test('syncing resources without detaching', async () => {
Expand All @@ -155,7 +155,7 @@ describe('BelongsToMany tests', () => {
await belongsToManyRelation.sync([2, 5, 7], false);

const requests = server.pretender.handledRequests;
expect(requests[0].queryParams).toStrictEqual({ detaching: 'false' });
expect(requests[0].queryParams).toStrictEqual({ detaching: '0' });
});

test('syncing resources with fields', async () => {
Expand All @@ -179,7 +179,7 @@ describe('BelongsToMany tests', () => {
expect(syncResult.detached).toStrictEqual(['2', '5']);

const requests = server.pretender.handledRequests;
expect(requests[0].queryParams).toStrictEqual({ detaching: 'true' });
expect(requests[0].queryParams).toStrictEqual({ detaching: '1' });
});

test('syncing resources with fields without detaching', async () => {
Expand All @@ -201,7 +201,7 @@ describe('BelongsToMany tests', () => {
);

const requests = server.pretender.handledRequests;
expect(requests[0].queryParams).toStrictEqual({ detaching: 'false' });
expect(requests[0].queryParams).toStrictEqual({ detaching: '0' });
});

test('toggling resources', async () => {
Expand Down

0 comments on commit 56ecd05

Please sign in to comment.