"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 core_1 = require("@angular-devkit/core");
const chai_1 = require("chai");
const testing_1 = require("@angular-devkit/schematics/testing");
const path = require("path");
const json_file_1 = require("../helpers/json-file");
const collectionPath = path.join(__dirname, "../../collection.json");
const workspaceOptions = {
    name: "workspace",
    newProjectRoot: "projects",
    version: "6.0.0",
};
const appOptions = {
    name: "schematest",
};
let appTree;
let tree;
const schematicRunner = new testing_1.SchematicTestRunner("ng-add", collectionPath);
describe("Add Onn Graph node", () => {
    beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
        appTree = yield schematicRunner
            .runExternalSchematicAsync("@schematics/angular", "workspace", workspaceOptions)
            .toPromise();
        appTree = yield schematicRunner
            .runExternalSchematicAsync("@schematics/angular", "application", appOptions, appTree)
            .toPromise();
        tree = yield schematicRunner
            .runSchematicAsync("ng-add", {
            project: "default",
            test: true,
            demoToInstall: false,
            addOns: ["graphNode"],
            dappDemo: "minimalContract",
        }, appTree)
            .toPromise();
    }));
    it("Add On Graph Node should create graph node folder", () => __awaiter(void 0, void 0, void 0, function* () {
        (0, chai_1.expect)(tree.exists((0, core_1.normalize)("/add-ons/graph-node/Dockerfile"))).to.be.true;
    }));
    it("It Add Graph Node scripts", () => __awaiter(void 0, void 0, void 0, function* () {
        // const packageJson = tree.read("package.json")!.toString("utf-8");
        const packageJson = new json_file_1.JSONFile(tree, "package.json");
        (0, chai_1.expect)(packageJson.get(['scripts', 'create-graph-local'])).to.be.equal('cd subgraph && graph create --node http://localhost:8020/ angular-web3/your-contract');
    }));
});
//# sourceMappingURL=add-ons-graph-node.js.map