"use strict";
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var chai_1 = require("chai");
var implementation_suite_1 = require("../../test/implementation-suite");
var slow_fs_1 = require("../drivers/slow-fs");
describe('the slow (delayed) file system implementation', function () {
    var delay = 200;
    var accuracyFactor = 0.9;
    implementation_suite_1.assertFileSystemContract(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
        return [2 /*return*/, new slow_fs_1.SlowFs(delay)];
    }); }); }, { retries: 15, interval: 2, timeout: 40, noExtraEventsGrace: 10 });
    describe("delayed methods", function () {
        var fs;
        var startTimestamp;
        beforeEach(function () {
            startTimestamp = Date.now();
            return Promise.resolve(new slow_fs_1.SlowFs(delay)).then(function (newFs) { return fs = newFs; });
        });
        it("delay the dir creation, reading tree and deleting", function () {
            return fs.ensureDirectory(implementation_suite_1.dirName)
                .then(function () { return fs.loadDirectoryTree(); })
                .then(function () { return fs.deleteDirectory(implementation_suite_1.dirName); })
                .then(function () { return chai_1.expect(Date.now() - startTimestamp).to.be.at.least(delay * 3 * accuracyFactor); });
        });
        it("delay the file saving, reading and deleting", function () {
            return fs.saveFile(implementation_suite_1.fileName, implementation_suite_1.content)
                .then(function () { return fs.loadTextFile(implementation_suite_1.fileName); })
                .then(function () { return fs.deleteFile(implementation_suite_1.fileName); })
                .then(function () { return chai_1.expect(Date.now() - startTimestamp).to.be.at.least(delay * 3 * accuracyFactor); });
        });
    });
});
//# sourceMappingURL=slow-fs.spec.js.map