All files / test dataProvider.ts

100% Statements 32/32
100% Branches 0/0
100% Functions 1/1
100% Lines 32/32

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 608x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x   8x 8x                         8x                         8x 8x 8x   8x 8x 8x 8x 8x 8x 8x 8x    
import { appInstall, DEFAULT_ACCESS_TOKEN, DEFAULT_CLIENT_ID, DEFAULT_CLIENT_SECRET, DEFAULT_USER } from '@orchesty/nodejs-connectors/test/DataProvider';
import { container, db, oauth2Provider, sender } from '@orchesty/nodejs-connectors/test/TestAbstract';
import CoreFormsEnum from '@orchesty/nodejs-sdk/dist/lib/Application/Base/CoreFormsEnum';
import { ACCESS_TOKEN } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Provider/OAuth2/OAuth2Provider';
import { TOKEN } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/Basic/ABasicApplication';
import { CLIENT_ID, CLIENT_SECRET } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/IOAuth2Application';
import { orchestyOptions } from '@orchesty/nodejs-sdk/dist/lib/Config/Config';
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
import { mockOnce } from '@orchesty/nodejs-sdk/dist/test/MockServer';
import WflowSubscribeWebhookBatch from '../src/Batch/WflowSubscribeWebhookBatch';
import WflowUnsubscribeWebhookBatch from '../src/Batch/WflowUnsubscribeWebhookBatch';
import WflowGetDocumentConnector from '../src/Connector/WflowGetDocumentConnector';
import WflowGetDocumentMainFileConnector from '../src/Connector/WflowGetDocumentMainFileConnector';
import WflowGetDocumentTypesConnector from '../src/Connector/WflowGetDocumentTypesConnector';
import WflowGetOrganizationsConnector from '../src/Connector/WflowGetOrganizationsConnector';
import WflowPutDocumentConnector from '../src/Connector/WflowPutDocumentConnector';
import WflowUpdateDocumentStateConnector from '../src/Connector/WflowUpdateDocumentStateConnector';
import WflowApplication, { NAME as WFLOW_APP, ORGANIZATION, ORGANIZATION_FORM } from '../src/WflowApplication';
 
export default function init(): void {
    appInstall(WFLOW_APP, DEFAULT_USER, {
        [CoreFormsEnum.AUTHORIZATION_FORM]: {
            [CLIENT_ID]: DEFAULT_CLIENT_ID,
            [CLIENT_SECRET]: DEFAULT_CLIENT_SECRET,
            [TOKEN]: {
                [ACCESS_TOKEN]: DEFAULT_ACCESS_TOKEN,
            },
        },
        [ORGANIZATION_FORM]: {
            [ORGANIZATION]: 'test',
        },
    });
 
    mockOnce([
        {
            request: {
                method: HttpMethods.GET,
                url: new RegExp(`${orchestyOptions.workerApi}/document/Webhook.*`),
            },
            response: {
                code: 200,
                body: [],
            },
        },
    ]);
 
    const getOrganizationsConnector = new WflowGetOrganizationsConnector().setDb(db).setSender(sender);
    const app = new WflowApplication(oauth2Provider, getOrganizationsConnector);
    container.setApplication(app);
 
    container.setNode(new WflowGetDocumentConnector(), app);
    container.setNode(new WflowGetDocumentMainFileConnector(), app);
    container.setNode(new WflowGetDocumentTypesConnector(), app);
    container.setNode(new WflowUpdateDocumentStateConnector(), app);
    container.setNode(new WflowSubscribeWebhookBatch(), app);
    container.setNode(new WflowUnsubscribeWebhookBatch(), app);
    container.setNode(new WflowPutDocumentConnector(), app);
    container.setNode(getOrganizationsConnector, app);
}