feat: implemented modifyRoute() method · wheresrhys/fetch-mock@f62e3d6 (original) (raw)

`@@ -251,6 +251,7 @@ describe('Routing', () => {

`

251

251

`});

`

252

252

`});

`

253

253

`describe('modifyRoute', () => {

`

``

254

`` +

// testChainableMethod(modifyRoute);

``

254

255

`it('can modify a matcher', async () => {

`

255

256

`fm.route('http://a.com/', 200, 'named');

`

256

257

`fm.modifyRoute('named', {

`

`@@ -315,11 +316,35 @@ describe('Routing', () => {

`

315

316

`fm.modifyRoute('named', {

`

316

317

`headers: null,

`

317

318

`}),

`

318

``

`` -

).toError('Cannot call modifyRoute() on sticky route named');

``

``

319

`+

).toThrow(

`

``

320

`` +

'Cannot call modifyRoute() on route named: route is sticky and cannot be modified',

``

``

321

`+

);

`

``

322

`+

});

`

``

323

+

``

324

`+

it('errors when route not found', () => {

`

``

325

`+

fm.route('http://a.com/', 200, 'named');

`

``

326

`+

expect(() =>

`

``

327

`+

fm.modifyRoute('wrong name', {

`

``

328

`+

headers: null,

`

``

329

`+

}),

`

``

330

`+

).toThrow(

`

``

331

`` +

'Cannot call modifyRoute() on route wrong name: route of that name not found',

``

``

332

`+

);

`

``

333

`+

});

`

``

334

+

``

335

`+

it('errors when trying to rename a route', () => {

`

``

336

`+

fm.route('http://a.com/', 200, { name: 'named' });

`

``

337

`+

expect(() =>

`

``

338

`+

fm.modifyRoute('named', {

`

``

339

`+

name: 'new name',

`

``

340

`+

}),

`

``

341

`+

).toThrow(

`

``

342

`` +

'Cannot rename the route named as new name: renaming routes is not supported',

``

``

343

`+

);

`

319

344

`});

`

320

345

`});

`

321

346

`describe('removeRoute', () => {

`

322

``

`` -

testChainableRoutingMethod(removeRoute);

``

``

347

`` +

testChainableMethod(removeRoute);

``

323

348

`it.skip('error informatively when name not found', () => {

`

324

349

`fm.route('http://a.com/', 200).route('http://b.com/', 201, 'named');

`

325

350

`expect(() => fm.removeRoute('misnamed')).toThrowError(

`