diff --git a/src/utils.ts b/src/utils.ts index 22506e82c..4e382b8b2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -238,6 +238,11 @@ export async function getScores( body: JSON.stringify({ params }) }); const obj = await res.json(); + + if (obj.error) { + return Promise.reject(obj.error); + } + return options.returnValue === 'all' ? obj.result : obj.result[options.returnValue || 'scores']; diff --git a/test/e2e/utils/getScores.spec.ts b/test/e2e/utils/getScores.spec.ts new file mode 100644 index 000000000..622f7ebc5 --- /dev/null +++ b/test/e2e/utils/getScores.spec.ts @@ -0,0 +1,11 @@ +import { test, expect, describe } from 'vitest'; +import { getScores } from '../../../src/utils'; + +describe('test getScores', () => { + test('getScores should returns a promise rejection on error from score-api', async () => { + expect.assertions(1); + await expect( + getScores('test.eth', [], '1', ['0x0']) + ).to.rejects.toHaveProperty('code'); + }); +});