"use strict";
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var chai_1 = require("chai");
var path_1 = require("path");
var memFs = require("mem-fs");
var fsEditor = require("mem-fs-editor");
var setup_npm_offline_cache_1 = require("../../steps/setup_npm_offline_cache");
var immutable_1 = require("immutable");
describe("setup npm offline cache", function () {
    var editor;
    var options;
    var cwd = process.cwd();
    var src = cwd + "/src/test/fixtures/basic_ticket_sample_app";
    var dest = cwd + "/src/test/fixtures/basic_ticket_sample_app/v2";
    beforeEach(function () {
        editor = fsEditor.create(memFs.create());
        options = immutable_1.Map({ src: src, dest: dest, editor: editor });
    });
    it("should create a .yarnrc config file", function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, setup_npm_offline_cache_1.default(options)];
                case 1:
                    _a.sent();
                    chai_1.expect(editor.exists(dest + "/.yarnrc")).to.be.true;
                    return [2 /*return*/];
            }
        });
    }); });
    it("should set the yarn-offline-mirror path to point to the migrator", function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
        var toMatch;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, setup_npm_offline_cache_1.default(options)];
                case 1:
                    _a.sent();
                    toMatch = "yarn-offline-mirror \"" + path_1.join(process.cwd(), "npm-packages-offline-cache") + "\"";
                    chai_1.expect(editor.read(dest + "/.yarnrc")).to.match(new RegExp(toMatch));
                    return [2 /*return*/];
            }
        });
    }); });
});
