"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
process.env.test = 'true';
const alsatian_1 = require("alsatian");
const servers_1 = require("./servers/");
const describeView_1 = require("../describeView");
const controllers_1 = require("./controllers");
const server_1 = require("@methodus/server");
let Servers = class Servers {
    serverSetup() {
        return __awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
                this.server = new servers_1.ExpressTestServer();
                this.server.on('ready', () => {
                    resolve();
                });
            }));
        });
    }
    serverKill() {
        return __awaiter(this, void 0, void 0, function* () {
            this.server.kill();
        });
    }
    dashboard() {
        return __awaiter(this, void 0, void 0, function* () {
            const response = yield describeView_1.DescribeView.dashboard();
            alsatian_1.Expect(response).toBeDefined();
        });
    }
    action() {
        return __awaiter(this, void 0, void 0, function* () {
            const response = yield describeView_1.DescribeView.action('TestController', 'update');
            alsatian_1.Expect(response).toBeDefined();
        });
    }
    getMethodusData() {
        return __awaiter(this, void 0, void 0, function* () {
            const response = yield describeView_1.DescribeView.getMethodusData();
            alsatian_1.Expect(response).toBeDefined();
        });
    }
    getMethodusDataClass() {
        return __awaiter(this, void 0, void 0, function* () {
            const response = yield describeView_1.DescribeView.getMethodusDataClass('TestController');
            alsatian_1.Expect(response).toBeDefined();
        });
    }
    list() {
        return __awaiter(this, void 0, void 0, function* () {
            const response = yield controllers_1.TestController.list({}, 1, 10, { headers: { 'host': 'localhost' } });
            yield controllers_1.TestController.create('some value', 'some key', 'some_name');
            yield controllers_1.TestController.read(11);
            yield controllers_1.TestController.getByField('some value', 1);
            yield controllers_1.TestController.update();
            yield controllers_1.TestController.delete('id');
            // await TestTarget.list({}, 1, 10);
            // await TestTarget.create('some value', 'some key', 'some_name');
            // await TestTarget.read(11);
            // await TestTarget.getByField('some value', 1);
            // await TestTarget.update();
            // await TestTarget.delete();
            alsatian_1.Expect(response).toBeDefined();
        });
    }
    dashboardMock() {
        return __awaiter(this, void 0, void 0, function* () {
            server_1.Mocker.mockServer(describeView_1.DescribeView);
            const response = yield describeView_1.DescribeView.dashboard();
            alsatian_1.Expect(response).toBeDefined();
        });
    }
    actionMock() {
        return __awaiter(this, void 0, void 0, function* () {
            server_1.Mocker.mockServer(describeView_1.DescribeView);
            const response = yield describeView_1.DescribeView.action('TestController', 'update');
            alsatian_1.Expect(response).toBeDefined();
        });
    }
};
__decorate([
    alsatian_1.AsyncSetupFixture,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], Servers.prototype, "serverSetup", null);
__decorate([
    alsatian_1.AsyncTeardownFixture,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], Servers.prototype, "serverKill", null);
__decorate([
    alsatian_1.AsyncTest('dashboard'),
    alsatian_1.Timeout(1000 * 1000),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], Servers.prototype, "dashboard", null);
__decorate([
    alsatian_1.AsyncTest('action'),
    alsatian_1.Timeout(1000 * 1000),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], Servers.prototype, "action", null);
__decorate([
    alsatian_1.AsyncTest('getMethodusData'),
    alsatian_1.Timeout(1000 * 1000),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], Servers.prototype, "getMethodusData", null);
__decorate([
    alsatian_1.AsyncTest('getMethodusDataClass'),
    alsatian_1.Timeout(1000 * 1000),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], Servers.prototype, "getMethodusDataClass", null);
__decorate([
    alsatian_1.AsyncTest('list'),
    alsatian_1.Timeout(1000 * 1000),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], Servers.prototype, "list", null);
__decorate([
    alsatian_1.AsyncTest('mock dashboard'),
    alsatian_1.Timeout(1000 * 1000),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], Servers.prototype, "dashboardMock", null);
__decorate([
    alsatian_1.AsyncTest('mock action'),
    alsatian_1.Timeout(1000 * 1000),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Promise)
], Servers.prototype, "actionMock", null);
Servers = __decorate([
    alsatian_1.TestFixture('Test Xserver configuration')
], Servers);
exports.Servers = Servers;
//# sourceMappingURL=describe.spec.js.map