"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const bignumber_js_1 = __importDefault(require("bignumber.js"));
const internal_1 = require("../../../internal");
const mocks_1 = require("../../../testUtils/mocks");
const types_1 = require("../../../types");
jest.mock('~/api/entities/Checkpoint', require("../../../testUtils/mocks/entities").mockCheckpointModule('~/api/entities/Checkpoint'));
jest.mock('~/api/entities/CheckpointSchedule', require("../../../testUtils/mocks/entities").mockCheckpointScheduleModule('~/api/entities/CheckpointSchedule'));
jest.mock('~/base/Procedure', require("../../../testUtils/mocks/procedure").mockProcedureModule('~/base/Procedure'));
describe('CorporateAction class', () => {
    let context;
    let id;
    let ticker;
    let declarationDate;
    let kind;
    let description;
    let targets;
    let defaultTaxWithholding;
    let taxWithholdings;
    let corporateAction;
    beforeAll(() => {
        mocks_1.dsMockUtils.initMocks();
        mocks_1.entityMockUtils.initMocks();
        mocks_1.procedureMockUtils.initMocks();
    });
    beforeEach(() => {
        context = mocks_1.dsMockUtils.getContextInstance();
        id = new bignumber_js_1.default(1);
        ticker = 'SOME_TICKER';
        declarationDate = new Date('10/14/1987 UTC');
        kind = types_1.CorporateActionKind.UnpredictableBenefit;
        description = 'someDescription';
        targets = {
            identities: [],
            treatment: types_1.TargetTreatment.Exclude,
        };
        defaultTaxWithholding = new bignumber_js_1.default(10);
        taxWithholdings = [];
        corporateAction = new internal_1.CorporateAction({
            id,
            ticker,
            kind,
            declarationDate,
            description,
            targets,
            defaultTaxWithholding,
            taxWithholdings,
        }, context);
    });
    afterEach(() => {
        mocks_1.dsMockUtils.reset();
        mocks_1.entityMockUtils.reset();
        mocks_1.procedureMockUtils.reset();
    });
    afterAll(() => {
        mocks_1.dsMockUtils.cleanup();
        mocks_1.procedureMockUtils.cleanup();
    });
    test('should extend CorporateActionBase', () => {
        expect(internal_1.CorporateAction.prototype instanceof internal_1.CorporateActionBase).toBe(true);
    });
    describe('method: modifyCheckpoint', () => {
        test('should prepare the procedure and return the resulting transaction queue', () => __awaiter(void 0, void 0, void 0, function* () {
            const expectedQueue = 'someQueue';
            const args = {
                checkpoint: new Date(),
            };
            mocks_1.procedureMockUtils
                .getPrepareStub()
                .withArgs({ args: Object.assign({ corporateAction }, args), transformer: undefined }, context)
                .resolves(expectedQueue);
            const queue = yield corporateAction.modifyCheckpoint(args);
            expect(queue).toBe(expectedQueue);
        }));
    });
});
//# sourceMappingURL=CorporateAction.js.map