"use strict";
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var chai_1 = require("chai");
var memFs = require("mem-fs");
var fsEditor = require("mem-fs-editor");
var migrate_app_css_1 = require("../../steps/migrate_app_css");
var immutable_1 = require("immutable");
describe("migrate app css", function () {
    var editor;
    var options;
    var cwd = process.cwd();
    var src = cwd + "/src/test/fixtures/basic_ticket_sample_app";
    var dest = cwd + "/tmp/test/basic_ticket_sample_app";
    beforeEach(function () {
        editor = fsEditor.create(memFs.create());
        options = immutable_1.Map({ src: src, dest: dest, editor: editor });
    });
    it("should copy v1 CSS to an SCSS 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*/, migrate_app_css_1.default(options)];
                case 1:
                    _a.sent();
                    chai_1.expect(editor.exists(dest + "/src/stylesheets/app.scss")).to.be.true;
                    return [2 /*return*/];
            }
        });
    }); });
    it("should wrap the original CSS in a wildcard selector", function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
        var css;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, migrate_app_css_1.default(options)];
                case 1:
                    _a.sent();
                    css = editor.read(dest + "/src/stylesheets/app.scss");
                    chai_1.expect(css).to.match(/^\* \{/);
                    chai_1.expect(css).to.match(/\.ccinstance \{/);
                    return [2 /*return*/];
            }
        });
    }); });
    it("should add a comment where there is no CSS to wrap", function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
        var defaultCss, originalCss, css;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    defaultCss = "/* Add CSS here... */";
                    originalCss = editor.read(src + "/app.css");
                    editor.write(src + "/app.css", "");
                    return [4 /*yield*/, migrate_app_css_1.default(options)];
                case 1:
                    _a.sent();
                    css = editor.read(dest + "/src/stylesheets/app.scss");
                    chai_1.expect(css).to.equal(defaultCss);
                    editor.write(src + "/app.css", originalCss);
                    return [2 /*return*/];
            }
        });
    }); });
});
