Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/dist/arm-js-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ Fix: Try adding ${collectionName} on your ARM config initialization.`;
return this._request({
resourceMethod: "delete",
resourceName: getProperty(currentRecord, "collectionName"),
resourceId: Number(getProperty(currentRecord, "id")),
resourceId: getProperty(currentRecord, "id"),
resourceParams: {},
resourcePayload: null,
resourceFallback: {},
Expand All @@ -593,7 +593,7 @@ Fix: Try adding ${collectionName} on your ARM config initialization.`;
return this._request({
resourceMethod: "get",
resourceName: getProperty(currentRecord, "collectionName"),
resourceId: Number(getProperty(currentRecord, "id")),
resourceId: getProperty(currentRecord, "id"),
resourceParams: {},
resourcePayload: null,
resourceFallback: {},
Expand Down
4 changes: 2 additions & 2 deletions packages/src/lib/api-resource-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ export default class ApiResourceManager {
return this._request({
resourceMethod: 'delete',
resourceName: getProperty(currentRecord, 'collectionName'),
resourceId: Number(getProperty(currentRecord, 'id')),
resourceId: getProperty(currentRecord, 'id'),
resourceParams: {},
resourcePayload: null,
resourceFallback: {},
Expand All @@ -737,7 +737,7 @@ export default class ApiResourceManager {
return this._request({
resourceMethod: 'get',
resourceName: getProperty(currentRecord, 'collectionName'),
resourceId: Number(getProperty(currentRecord, 'id')),
resourceId: getProperty(currentRecord, 'id'),
resourceParams: {},
resourcePayload: null,
resourceFallback: {},
Expand Down
7 changes: 5 additions & 2 deletions packages/tests/mirage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ export default function () {
: request.requestBody
})

this.delete('/addresses/:id', () => {
return { data: addresses.data[1] }
this.delete('/addresses/:id', (schema, request) => {
const { id } = request.params
return isNaN(Number(id))
? { data: { id, type: 'addresses', attributes: {} } }
: { data: addresses.data[1] }
})
},
})
Expand Down
32 changes: 32 additions & 0 deletions packages/tests/units/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ const execRecordTest = (ARM) => {
expect(record.get('attributes.address1')).toBe('Anabu Hills Test 4')
})

test('Verify reload with string collection record id', async () => {
ARM.pushPayload('addresses', [
{
id: 'JO-26181S4VPU65',
type: 'addresses',
attributes: { address1: 'String ID Address', kind: 'office' },
},
])
const record = ARM.peekRecord('addresses', 'JO-26181S4VPU65')
expect(record).toBeDefined()

const result = await record.reload()
expect(result).toBeDefined()
expect(record.get('isError')).toBe(false)
})

test('Verify rollbackAttributes functionality', async () => {
await ARM.findRecord('addresses', 2518368, null, {
autoResolve: false,
Expand Down Expand Up @@ -204,6 +220,22 @@ const execRecordTest = (ARM) => {
expect(ARM.peekRecord('addresses', 2518368)).toBeUndefined()
})

test('Verify destroyRecord with string collection record id', async () => {
ARM.pushPayload('addresses', [
{
id: 'JO-26181S4VPU65',
type: 'addresses',
attributes: { address1: 'String ID Address', kind: 'office' },
},
])
const record = ARM.peekRecord('addresses', 'JO-26181S4VPU65')
expect(record).toBeDefined()

const result = await record.destroyRecord()
expect(result).toBeDefined()
expect(ARM.peekRecord('addresses', 'JO-26181S4VPU65')).toBeUndefined()
})

test('Verify getCollection functionality', async () => {
await ARM.query(
'addresses',
Expand Down
Loading