Skip to content

Commit

Permalink
test: add more covereact for rejects
Browse files Browse the repository at this point in the history
  • Loading branch information
willfarrell committed Mar 29, 2024
1 parent 584b19e commit fea2941
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion packages/util/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,30 @@ const getInternalRequest = {
promiseObject: Promise.resolve({
key: 'value'
})
// promiseReject: Promise.reject('promise')
}
}
const promiseThrowError = new Error('promiseThrow')
const getInternalRejected = {
internal: {
promiseReject: Promise.reject('promiseReject'),
promiseThrow: new Promise(() => {
throw promiseThrowError
})
}
}

test('getInternal should throw errors', async (t) => {
try {
await getInternal(true, getInternalRejected)
} catch (e) {
t.is(e.message, 'Failed to resolve internal values')
t.deepEqual(e.cause, {
package: '@middy/util',
data: ['promiseReject', promiseThrowError]
})
}
})

test('getInternal should get none from internal store', async (t) => {
const values = await getInternal(false, getInternalRequest)
t.deepEqual(values, {})
Expand Down

0 comments on commit fea2941

Please sign in to comment.