Skip to content

Commit

Permalink
fix(delivery-expo): Ensure error properties are correctly indexed
Browse files Browse the repository at this point in the history
  • Loading branch information
bengourley committed Apr 15, 2020
1 parent 0b65c33 commit a65b5a2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/delivery-expo/delivery.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = (client, fetch = global.fetch) => {
enqueue('event', { url, opts })
return cb(null)
}
client._logger.info(`Sending event ${event.events[0].errorClass}: ${event.events[0].errorMessage}`)
client._logger.info(`Sending event ${event.events[0].errors[0].errorClass}: ${event.events[0].errors[0].errorMessage}`)
send(url, opts, err => {
if (err) return onerror(err, { url, opts }, 'event', cb)
cb(null)
Expand Down
35 changes: 26 additions & 9 deletions packages/delivery-expo/test/delivery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('delivery: expo', () => {
expect(err).toBeUndefined()

const payload = {
events: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }]
events: [{ errors: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }]
}
const config = {
apiKey: 'aaaaaaaa',
Expand Down Expand Up @@ -96,7 +96,9 @@ describe('delivery: expo', () => {
server.listen((err) => {
expect(err).toBeUndefined()

const payload = { events: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }
const payload = {
events: [{ errors: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }]
}
const config = {
apiKey: 'aaaaaaaa',
endpoints: { notify: 'blah', sessions: `http://0.0.0.0:${server.address().port}/sessions/` },
Expand Down Expand Up @@ -132,7 +134,9 @@ describe('delivery: expo', () => {
'./network-status': MockNetworkStatus
})

const payload = { events: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }
const payload = {
events: [{ errors: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }]
}
const config = {
apiKey: 'aaaaaaaa',
endpoints: { notify: 'http://0.0.0.0:9999/notify/' },
Expand Down Expand Up @@ -166,7 +170,9 @@ describe('delivery: expo', () => {
server.listen((err) => {
expect(err).toBeUndefined()

const payload = { events: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }
const payload = {
events: [{ errors: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }]
}
const config = {
apiKey: 'aaaaaaaa',
endpoints: { notify: `http://0.0.0.0:${server.address().port}/notify/` },
Expand Down Expand Up @@ -198,7 +204,9 @@ describe('delivery: expo', () => {
'./network-status': MockNetworkStatus
})

const payload = { events: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }
const payload = {
events: [{ errors: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }]
}
const config = {
apiKey: 'aaaaaaaa',
endpoints: { sessions: 'http://0.0.0.0:9999/sessions/' },
Expand Down Expand Up @@ -234,7 +242,9 @@ describe('delivery: expo', () => {

server.listen((err) => {
expect(err).toBeFalsy()
const payload = { events: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }
const payload = {
events: [{ errors: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }]
}
const config = {
apiKey: 'aaaaaaaa',
endpoints: { notify: `http://0.0.0.0:${server.address().port}/notify/` },
Expand Down Expand Up @@ -272,7 +282,9 @@ describe('delivery: expo', () => {

server.listen((err) => {
expect(err).toBeFalsy()
const payload = { events: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }
const payload = {
events: [{ errors: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }]
}
const config = {
apiKey: 'aaaaaaaa',
endpoints: { notify: `http://0.0.0.0:${server.address().port}/notify/` },
Expand Down Expand Up @@ -302,7 +314,10 @@ describe('delivery: expo', () => {
'./network-status': MockNetworkStatus
})

const payload = { sample: 'payload', attemptImmediateDelivery: false }
const payload = {
events: [{ errors: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }],
attemptImmediateDelivery: false
}
const config = {
apiKey: 'aaaaaaaa',
endpoints: { notify: 'https://some-address.com' },
Expand Down Expand Up @@ -384,7 +399,9 @@ describe('delivery: expo', () => {
'./redelivery': NoopRedelivery,
'./network-status': MockNetworkStatus
})
const payload = { events: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }
const payload = {
events: [{ errors: [{ errorClass: 'Error', errorMessage: 'foo is not a function' }] }]
}
const config = {
apiKey: 'aaaaaaaa',
endpoints: { notify: 'http://some-address.com' },
Expand Down

0 comments on commit a65b5a2

Please sign in to comment.