"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const testing_1 = require("@angular-devkit/schematics/testing");
const test_1 = require("@schematics/angular/utility/test");
describe('Angular JSON Config Schematic', () => {
    const schematicRunner = new testing_1.SchematicTestRunner('nativescript-schematics', path.join(__dirname, '../collection.json'));
    const projName = 'leproj';
    const defaultOptions = {
        name: projName,
    };
    const configPath = `/angular.json`;
    describe('with default options (name only)', () => {
        let tree;
        beforeAll(() => __awaiter(this, void 0, void 0, function* () {
            tree = yield schematicRunner.runSchematicAsync('angular-json', defaultOptions).toPromise();
        }));
        it('should create angular.json files', () => {
            expect(tree.files).toContain(configPath);
        });
        it('should insert the project name', () => {
            expect(test_1.getFileContent(tree, configPath)).toContain(`"${projName}":`);
        });
        it('should insert "." as sourceRoot', () => {
            expect(test_1.getFileContent(tree, configPath)).toContain(`"sourceRoot": "."`);
        });
    });
    it('should insert the prefix option', () => __awaiter(this, void 0, void 0, function* () {
        const prefix = 'custom-prefix';
        const tree = yield schematicRunner.runSchematicAsync('angular-json', Object.assign({}, defaultOptions, { prefix })).toPromise();
        expect(test_1.getFileContent(tree, configPath)).toContain(`"prefix": "${prefix}"`);
    }));
    it('should insert the sourceRoot option', () => __awaiter(this, void 0, void 0, function* () {
        const sourceRoot = 'src';
        const tree = yield schematicRunner.runSchematicAsync('angular-json', Object.assign({}, defaultOptions, { sourceRoot })).toPromise();
        expect(test_1.getFileContent(tree, configPath)).toContain(`"sourceRoot": "${sourceRoot}"`);
    }));
    it('should create files inside path when specified', () => __awaiter(this, void 0, void 0, function* () {
        const path = '/path/to/my/app';
        const appJsonPath = `${path}/angular.json`;
        const options = Object.assign({}, defaultOptions, { path });
        const tree = yield schematicRunner.runSchematicAsync('angular-json', options).toPromise();
        expect(tree.files).toContain(appJsonPath);
    }));
});
//# sourceMappingURL=index_spec.js.map