"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var aspect_1 = require("@dojo/core/aspect");
var Suite_1 = require("../Suite");
var Test_1 = require("../Test");
function getInterface(executor) {
    var currentSuite;
    return {
        suite: function (name, factory) {
            var parent = currentSuite;
            var suite = new Suite_1.default({ name: name });
            if (!parent) {
                executor.addTest(suite);
            }
            else {
                parent.add(suite);
            }
            currentSuite = suite;
            factory.call(suite, suite);
            currentSuite = parent;
        },
        test: function (name, test) {
            if (!currentSuite) {
                throw new Error('A test must be declared within a suite');
            }
            currentSuite.add(new Test_1.default({ name: name, test: test, parent: currentSuite }));
        },
        before: function (fn) {
            if (!currentSuite) {
                throw new Error("A suite lifecycle method must be declared within a suite");
            }
            aspect_1.on(currentSuite, 'before', fn);
        },
        after: function (fn) {
            if (!currentSuite) {
                throw new Error("A suite lifecycle method must be declared within a suite");
            }
            aspect_1.on(currentSuite, 'after', fn);
        },
        beforeEach: function (fn) {
            if (!currentSuite) {
                throw new Error("A suite lifecycle method must be declared within a suite");
            }
            aspect_1.on(currentSuite, 'beforeEach', fn);
        },
        afterEach: function (fn) {
            if (!currentSuite) {
                throw new Error("A suite lifecycle method must be declared within a suite");
            }
            aspect_1.on(currentSuite, 'afterEach', fn);
        }
    };
}
exports.default = getInterface;
//# sourceMappingURL=tdd.js.map