text: "use strict";
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
      if (k2 === undefined) k2 = k;
      Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  }) : (function(o, m, k, k2) {
      if (k2 === undefined) k2 = k;
      o[k2] = m[k];
  }));
  var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
      Object.defineProperty(o, "default", { enumerable: true, value: v });
  }) : function(o, v) {
      o["default"] = v;
  });
  var __importStar = (this && this.__importStar) || function (mod) {
      if (mod && mod.__esModule) return mod;
      var result = {};
      if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
      __setModuleDefault(result, mod);
      return result;
  };
  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());
      });
  };
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  const schematics_1 = require("@angular-devkit/schematics");
  const testing_1 = require("@angular-devkit/schematics/testing");
  const path = __importStar(require("path"));
  // const { spawnSync } = require('child_process');
  const react_ts_pkg_json_1 = __importDefault(require("./react-ts-pkg.json"));
  const collectionPath = path.join(__dirname, '../collection.json');
  const defaultOptions = {
      issuer: 'https://dev-737523.okta.com/oauth2/default',
      clientId: '0oaifymbuodpH8nAi0h7'
  };
  describe('OktaDev Schematics: React + TypeScript', () => {
      it('requires required issuer option', () => __awaiter(void 0, void 0, void 0, function* () {
          const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
          const schematic = yield runner.runSchematicAsync('add-auth', {}, schematics_1.Tree.empty());
          yield expectAsync(schematic.toPromise()).toBeRejected();
      }));
      it('works', () => __awaiter(void 0, void 0, void 0, function* () {
          const tree = new testing_1.UnitTestTree(new schematics_1.HostTree);
          // Add package.json
          tree.create('/package.json', JSON.stringify(react_ts_pkg_json_1.default));
          const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
          yield runner.runSchematicAsync('add-auth', Object.assign({}, defaultOptions), tree).toPromise();
          expect(tree.files.length).toEqual(5);
          expect(tree.files.sort()).toEqual(['/package.json', '/src/App.test.tsx', '/src/App.tsx', '/src/Home.tsx',
              '/src/okta.d.ts']);
          const componentContent = tree.readContent('/src/App.tsx');
          expect(componentContent).toMatch(/class App extends Component/);
          expect(componentContent).toContain(`issuer: '${defaultOptions.issuer}'`);
          expect(componentContent).toContain(`client_id: '${defaultOptions.clientId}'`);
      }));
      it('fail with no package.json', () => __awaiter(void 0, void 0, void 0, function* () {
          const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
          const schematic = yield runner.runSchematicAsync('add-auth', Object.assign({}, defaultOptions), schematics_1.Tree.empty());
          yield expectAsync(schematic.toPromise()).toBeRejected();
      }));
      it('fail when no frameworks', () => __awaiter(void 0, void 0, void 0, function* () {
          const pkgNoFrameworks = Object.assign({}, react_ts_pkg_json_1.default);
          delete pkgNoFrameworks.dependencies;
          const tree = new testing_1.UnitTestTree(new schematics_1.HostTree);
          tree.create('/package.json', JSON.stringify(pkgNoFrameworks));
          const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
          const schematic = yield runner.runSchematicAsync('add-auth', Object.assign({}, defaultOptions), schematics_1.Tree.empty());
          yield expectAsync(schematic.toPromise()).toBeRejected();
      }));
  });
  //# sourceMappingURL=react-ts_spec.js.map