Verified Commit fdf51725 authored by aguestuser's avatar aguestuser

[215] fix broken `POST /phoneNumbers/recycle` route

parent 4709de67
......@@ -69,9 +69,7 @@ const routesOf = async router => {
router.post('/phoneNumbers/recycle', async ctx => {
const { phoneNumbers } = ctx.request.body
const result = await phoneNumberService.requestToRecycle({
phoneNumbers: phoneNumbers.split(','),
})
const result = await phoneNumberService.requestToRecycle(phoneNumbers.split(','))
merge(ctx, { status: httpStatusOfMany(result), body: result })
})
......
......@@ -374,21 +374,17 @@ describe('routes', () => {
})
describe('POST to /phoneNumbers/recycle', () => {
let recycleStub
beforeEach(() => (recycleStub = sinon.stub(phoneNumberService, 'recycle')))
afterEach(() => recycleStub.restore())
let requestToRecycle
beforeEach(() => (requestToRecycle = sinon.stub(phoneNumberService, 'requestToRecycle')))
afterEach(() => requestToRecycle.restore())
describe('when recycling succeeds', () => {
describe('when recycle request succeeds', () => {
beforeEach(() =>
recycleStub.returns(
requestToRecycle.returns(
Promise.resolve([
{
status: 'SUCCESS',
data: {
status: 'VERIFIED',
phoneNumber: '+19382223543',
twilioSid: 'PNc505ce2a87c34bfbe598c54120865bcf',
},
message: 'Issued request to recycle +19382223543',
},
]),
),
......@@ -403,13 +399,13 @@ describe('routes', () => {
})
})
describe('when recycling fails', () => {
describe('when recycle request fails', () => {
beforeEach(() =>
recycleStub.returns(
requestToRecycle.returns(
Promise.resolve([
{
status: 'ERROR',
message: 'Channel not found for +16154804259',
message: '+16154804259 has already been enqueued for recycling.',
},
]),
),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment