"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    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) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const schematics_1 = require("@angular-devkit/schematics");
const xplat_utils_1 = require("@nstudio/xplat-utils");
const testing_1 = require("@nstudio/xplat/testing");
const testing_2 = require("../../utils/testing");
xplat_utils_1.setTest();
describe('xplat schematic', () => {
    let appTree;
    const defaultOptions = {
        npmScope: 'testing',
        prefix: 'ft',
    };
    beforeEach(() => {
        appTree = schematics_1.Tree.empty();
        appTree = testing_1.createEmptyWorkspace(appTree);
    });
    it('should create default xplat support for nativescript only', () => __awaiter(void 0, void 0, void 0, function* () {
        const options = Object.assign({}, defaultOptions);
        appTree.create('.prettierignore', '# sample');
        const tree = yield testing_2.runSchematic('xplat', options, appTree);
        expect(tree.exists('/libs/xplat/web/core/src/lib/index.ts')).toBeFalsy();
        expect(tree.exists('/libs/xplat/nativescript/utils/src/lib/index.ts')).toBeTruthy();
        const packagePath = '/package.json';
        const packageFile = xplat_utils_1.jsonParse(testing_1.getFileContent(tree, packagePath));
        const hasNativeScript = packageFile.dependencies[`@nativescript/core`];
        expect(hasNativeScript).not.toBeUndefined();
        const prettier = testing_1.getFileContent(tree, '.prettierignore');
        // console.log('prettier:', prettier);
        expect(prettier.indexOf('**/libs/xplat/nativescript*/plugins/**/*')).toBeGreaterThan(0);
    }));
});
