|
1 | 1 | import axios from 'axios'; |
2 | 2 | import MockAdapter from 'axios-mock-adapter'; |
3 | 3 | import { TemplateApiClient } from '../template-api-client'; |
4 | | -import { RoutingConfig } from '../types/generated'; |
5 | 4 |
|
6 | 5 | const axiosMock = new MockAdapter(axios); |
7 | 6 |
|
@@ -486,80 +485,4 @@ describe('TemplateAPIClient', () => { |
486 | 485 | expect(result.error).toBeUndefined(); |
487 | 486 | }); |
488 | 487 | }); |
489 | | - |
490 | | - describe('createRoutingConfig', () => { |
491 | | - test('should return error', async () => { |
492 | | - axiosMock.onPost('/v1/routing-configuration').reply(400, { |
493 | | - statusCode: 400, |
494 | | - technicalMessage: 'Bad request', |
495 | | - details: { |
496 | | - message: 'Something went wrong', |
497 | | - }, |
498 | | - }); |
499 | | - |
500 | | - const client = new TemplateApiClient(); |
501 | | - |
502 | | - const result = await client.createRoutingConfig( |
503 | | - { |
504 | | - name: 'test', |
505 | | - campaignId: 'campaign-id', |
506 | | - cascade: [], |
507 | | - cascadeGroupOverrides: [], |
508 | | - }, |
509 | | - testToken |
510 | | - ); |
511 | | - |
512 | | - expect(result.error).toEqual({ |
513 | | - errorMeta: { |
514 | | - code: 400, |
515 | | - description: 'Bad request', |
516 | | - details: { |
517 | | - message: 'Something went wrong', |
518 | | - }, |
519 | | - }, |
520 | | - }); |
521 | | - |
522 | | - expect(result.data).toBeUndefined(); |
523 | | - |
524 | | - expect(axiosMock.history.post.length).toBe(1); |
525 | | - }); |
526 | | - |
527 | | - test('should return routing config', async () => { |
528 | | - const data: RoutingConfig = { |
529 | | - campaignId: 'campaign-id', |
530 | | - cascade: [], |
531 | | - cascadeGroupOverrides: [], |
532 | | - clientId: 'client-id', |
533 | | - createdAt: new Date().toISOString(), |
534 | | - id: 'id', |
535 | | - name: 'name', |
536 | | - status: 'DRAFT', |
537 | | - updatedAt: new Date().toISOString(), |
538 | | - }; |
539 | | - |
540 | | - axiosMock.onPost('/v1/routing-configuration').reply(201, { |
541 | | - statusCode: 201, |
542 | | - data, |
543 | | - }); |
544 | | - |
545 | | - const client = new TemplateApiClient(); |
546 | | - |
547 | | - const body = { |
548 | | - campaignId: data.campaignId, |
549 | | - cascade: data.cascade, |
550 | | - cascadeGroupOverrides: data.cascadeGroupOverrides, |
551 | | - name: data.name, |
552 | | - }; |
553 | | - |
554 | | - const result = await client.createRoutingConfig(body, testToken); |
555 | | - |
556 | | - expect(axiosMock.history.post.length).toBe(1); |
557 | | - expect(JSON.parse(axiosMock.history.post[0].data)).toEqual(body); |
558 | | - expect(axiosMock.history.post[0].headers?.Authorization).toBe(testToken); |
559 | | - |
560 | | - expect(result.data).toEqual(data); |
561 | | - |
562 | | - expect(result.error).toBeUndefined(); |
563 | | - }); |
564 | | - }); |
565 | 488 | }); |
0 commit comments