"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const actions_core_1 = require("@segment/actions-core");
const test_data_1 = require("../../../../lib/test-data");
const index_1 = __importDefault(require("../../index"));
const nock_1 = __importDefault(require("nock"));
const testDestination = (0, actions_core_1.createTestIntegration)(index_1.default);
const actionSlug = 'identifyUser';
const destinationSlug = 'Mixpanel';
const seedName = `${destinationSlug}#${actionSlug}`;
describe(`Testing snapshot for ${destinationSlug}'s ${actionSlug} destination action:`, () => {
    it('required fields', async () => {
        const action = index_1.default.actions[actionSlug];
        const [eventData, settingsData] = (0, test_data_1.generateTestData)(seedName, index_1.default, action, true);
        (0, nock_1.default)(/.*/).persist().get(/.*/).reply(200);
        (0, nock_1.default)(/.*/).persist().post(/.*/).reply(200);
        (0, nock_1.default)(/.*/).persist().put(/.*/).reply(200);
        const event = (0, actions_core_1.createTestEvent)({
            properties: eventData
        });
        const responses = await testDestination.testAction(actionSlug, {
            event: event,
            mapping: event.properties,
            settings: settingsData,
            auth: undefined
        });
        const request = responses[0].request;
        const rawBody = await request.text();
        try {
            const json = JSON.parse(rawBody);
            expect(json).toMatchSnapshot();
            return;
        }
        catch (err) {
            expect(rawBody).toMatchSnapshot();
        }
        expect(request.headers).toMatchSnapshot();
    });
    it('all fields', async () => {
        const action = index_1.default.actions[actionSlug];
        const [eventData, settingsData] = (0, test_data_1.generateTestData)(seedName, index_1.default, action, false);
        (0, nock_1.default)(/.*/).persist().get(/.*/).reply(200);
        (0, nock_1.default)(/.*/).persist().post(/.*/).reply(200);
        (0, nock_1.default)(/.*/).persist().put(/.*/).reply(200);
        const event = (0, actions_core_1.createTestEvent)({
            properties: eventData
        });
        const responses = await testDestination.testAction(actionSlug, {
            event: event,
            mapping: event.properties,
            settings: settingsData,
            auth: undefined
        });
        const request = responses[0].request;
        const rawBody = await request.text();
        try {
            const json = JSON.parse(rawBody);
            expect(json).toMatchSnapshot();
            return;
        }
        catch (err) {
            expect(rawBody).toMatchSnapshot();
        }
    });
});
//# sourceMappingURL=snapshot.test.js.map