<commit_before>import { join, resolve } from 'path';

import * as helpers from './helpers';
import { BuildContext } from './interfaces';
import * as config from './config';
import * as Constants from './constants';


describe('config', () => {

  describe('config.generateContext', () => {

    it('should set isWatch true with isWatch true context', () => {
      const context = config.generateContext({
        isWatch: true
      });
      expect(context.isWatch).toEqual(true);
    });

    it('should set isWatch false by default', () => {
      const context = config.generateContext();
      expect(context.isWatch).toEqual(false);
    });

    it('should set isProd false with isProd false context', () => {
      const context = config.generateContext({
        isProd: false
      });
      expect(context.isProd).toEqual(false);
    });

    it('should set default bundler when invalid value', () => {
      const context = config.generateContext();
      expect(context.bundler).toEqual('webpack');
    });

    it('should set default bundler when not set', () => {
      const context = config.generateContext();
      expect(context.bundler).toEqual('webpack');
    });

    it('should set isProd by default', () => {
      const context = config.generateContext();
      expect(context.isProd).toEqual(false);
    });

    it('should create an object when passed nothing', () => {
      const context = config.generateContext();
      expect(context).toBeDefined();
    });

    it('should set the correct defaults for a dev build', () => {
      // arrange
      const fakeConfig: any = { };
      config.setProcessEnv(fakeConfig);

      // act
      const context = config.generateContext({
        isProd: false
      });

      // assert
      expect(context.isProd).toEqual(false);
      expect(context.runAot).toEqual(false);
      expect(context.runMinifyJs).toEqual(false);
      expect(context.runMinifyCss).toEqual(false);
      expect(context.optimizeJs).toEqual(false);
      expect(fakeConfig[Constants.ENV_VAR_IONIC_ENV]).toEqual(Constants.ENV_VAR_DEV);

      expect(context.rootDir).toEqual(process.cwd());
      expect(context.tmpDir).toEqual(join(process.cwd(), Constants.TMP_DIR));
      expect(context.srcDir).toEqual(join(process.cwd(), Constants.SRC_DIR));
      expect(fakeConfig[Constants.ENV_VAR_DEEPLINKS_DIR]).toEqual(context.srcDir);
      expect(context.wwwDir).toEqual(join(process.cwd(), Constants.WWW_DIR));
      expect(context.wwwIndex).toEqual('index.html');
      expect(context.buildDir).toEqual(join(process.cwd(), Constants.WWW_DIR, Constants.BUILD_DIR));
      expect(context.pagesDir).toEqual(join(context.srcDir, 'pages'));
      expect(context.componentsDir).toEqual(join(context.srcDir, 'components'));
      expect(context.directivesDir).toEqual(join(context.srcDir, 'directives'));
      expect(context.pipesDir).toEqual(join(context.srcDir, 'pipes'));
      expect(context.providersDir).toEqual(join(context.srcDir, 'providers'));
      expect(context.nodeModulesDir).toEqual(join(process.cwd(), Constants.NODE_MODULES));
      expect(context.ionicAngularDir).toEqual(join(process.cwd(), Constants.NODE_MODULES, Constants.IONIC_ANGULAR));
      expect(fakeConfig[Constants.ENV_VAR_AT_ANGULAR_DIR]).toEqual(join(process.cwd(), Constants.NODE_MODULES, Constants.AT_ANGULAR));
      expect(context.coreCompilerFilePath).toEqual(join(context.ionicAngularDir, 'compiler'));
      expect(context.coreDir).toEqual(context.ionicAngularDir);
      expect(fakeConfig[Constants.ENV_VAR_RXJS_DIR]).toEqual(join(process.cwd(), Constants.NODE_MODULES, Constants.RXJS));
      expect(fakeConfig[Constants.ENV_VAR_IONIC_ANGULAR_TEMPLATE_DIR]).toEqual(join(context.ionicAngularDir, 'templates'));
      expect(context.platform).toEqual(null);
      expect(context.target).toEqual(null);
      expect(fakeConfig[Constants.ENV_VAR_IONIC_ANGULAR_ENTRY_POINT]).toEqual(join(context.ionicAngularDir, 'index.js'));
      expect(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR]).toEqual(join(__dirname, '..', '..'));
      expect(fakeConfig[Constants.ENV_VAR_GENERATE_SOURCE_MAP]).toEqual('true');
      expect(fakeConfig[Constants.ENV_VAR_SOURCE_MAP_TYPE]).toEqual(Constants.SOURCE_MAP_TYPE_EXPENSIVE);
      expect(fakeConfig[Constants.ENV_TS_CONFIG]).toEqual(join(process.cwd(), 'tsconfig.json'));
      expect(fakeConfig[Constants.ENV_READ_CONFIG_JSON]).toEqual('true');
      expect(fakeConfig[Constants.ENV_APP_ENTRY_POINT]).toEqual(join(context.srcDir, 'app', 'main.ts'));
      expect(fakeConfig[Constants.ENV_APP_NG_MODULE_PATH]).toEqual(join(context.srcDir, 'app', 'app.module.ts'));
      expect(fakeConfig[Constants.ENV_APP_NG_MODULE_CLASS]).toEqual('AppModule');
      expect(fakeConfig[Constants.ENV_GLOB_UTIL]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'dist', 'util', 'glob-util.js'));
      expect(fakeConfig[Constants.ENV_CLEAN_BEFORE_COPY]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_CLOSURE_JAR]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'bin', 'closure-compiler.jar'));
      expect(fakeConfig[Constants.ENV_OUTPUT_JS_FILE_NAME]).toEqual('main.js');
      expect(fakeConfig[Constants.ENV_OUTPUT_CSS_FILE_NAME]).toEqual('main.css');
      expect(fakeConfig[Constants.ENV_WEBPACK_FACTORY]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'dist', 'webpack', 'ionic-webpack-factory.js'));
      expect(fakeConfig[Constants.ENV_WEBPACK_LOADER]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'dist', 'webpack', 'loader.js'));
      expect(fakeConfig[Constants.ENV_OPTIMIZATION_LOADER]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'dist', 'webpack', 'optimization-loader.js'));
      expect(fakeConfig[Constants.ENV_AOT_WRITE_TO_DISK]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_PRINT_ORIGINAL_DEPENDENCY_TREE]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_PRINT_MODIFIED_DEPENDENCY_TREE]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_PRINT_WEBPACK_DEPENDENCY_TREE]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_TYPE_CHECK_ON_LINT]).toBeTruthy();
      expect(fakeConfig[Constants.ENV_BAIL_ON_LINT_ERROR]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_ENABLE_LINT]).toEqual('true');
      expect(fakeConfig[Constants.ENV_DISABLE_LOGGING]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_START_WATCH_TIMEOUT]).toEqual('3000');
      expect(fakeConfig[Constants.ENV_NG_MODULE_FILE_NAME_SUFFIX]).toEqual('.module.ts');

      expect(fakeConfig[Constants.ENV_ACTION_SHEET_CONTROLLER_CLASSNAME]).toEqual('ActionSheetController');
      expect(fakeConfig[Constants.ENV_ACTION_SHEET_CONTROLLER_PATH]).toEqual(join(context.ionicAngularDir, 'components', 'action-sheet', 'action-sheet-controller.js'));
      expect(fakeConfig[Constants.ENV_ACTION_SHEET_VIEW_CONTROLLER_PATH]).toEqual(join(context.ionicAngularDir, 'components', 'action-sheet', 'action-sheet.js'));
      expect(fakeConfig[Constants.ENV_ACTION_SHEET_COMPONENT_PATH]).toEqual(join(context.ionicAngularDir, 'components', 'action-sheet', 'action-sheet-component.js'));
      expect(fakeConfig[Constants.ENV_ACTION_SHEET_COMPONENT_FACTORY_PATH]).toEqual(join(context.ionicAngularDir, 'components', 'action-sheet', 'action-sheet-component.ngfactory.js'));<commit_msg>test(lint): fix typeCheckOnLint flag tests<commit_after>import { join, resolve } from 'path';

import * as helpers from './helpers';
import { BuildContext } from './interfaces';
import * as config from './config';
import * as Constants from './constants';


describe('config', () => {

  describe('config.generateContext', () => {

    it('should set isWatch true with isWatch true context', () => {
      const context = config.generateContext({
        isWatch: true
      });
      expect(context.isWatch).toEqual(true);
    });

    it('should set isWatch false by default', () => {
      const context = config.generateContext();
      expect(context.isWatch).toEqual(false);
    });

    it('should set isProd false with isProd false context', () => {
      const context = config.generateContext({
        isProd: false
      });
      expect(context.isProd).toEqual(false);
    });

    it('should set default bundler when invalid value', () => {
      const context = config.generateContext();
      expect(context.bundler).toEqual('webpack');
    });

    it('should set default bundler when not set', () => {
      const context = config.generateContext();
      expect(context.bundler).toEqual('webpack');
    });

    it('should set isProd by default', () => {
      const context = config.generateContext();
      expect(context.isProd).toEqual(false);
    });

    it('should create an object when passed nothing', () => {
      const context = config.generateContext();
      expect(context).toBeDefined();
    });

    it('should set the correct defaults for a dev build', () => {
      // arrange
      const fakeConfig: any = { };
      config.setProcessEnv(fakeConfig);

      // act
      const context = config.generateContext({
        isProd: false
      });

      // assert
      expect(context.isProd).toEqual(false);
      expect(context.runAot).toEqual(false);
      expect(context.runMinifyJs).toEqual(false);
      expect(context.runMinifyCss).toEqual(false);
      expect(context.optimizeJs).toEqual(false);
      expect(fakeConfig[Constants.ENV_VAR_IONIC_ENV]).toEqual(Constants.ENV_VAR_DEV);

      expect(context.rootDir).toEqual(process.cwd());
      expect(context.tmpDir).toEqual(join(process.cwd(), Constants.TMP_DIR));
      expect(context.srcDir).toEqual(join(process.cwd(), Constants.SRC_DIR));
      expect(fakeConfig[Constants.ENV_VAR_DEEPLINKS_DIR]).toEqual(context.srcDir);
      expect(context.wwwDir).toEqual(join(process.cwd(), Constants.WWW_DIR));
      expect(context.wwwIndex).toEqual('index.html');
      expect(context.buildDir).toEqual(join(process.cwd(), Constants.WWW_DIR, Constants.BUILD_DIR));
      expect(context.pagesDir).toEqual(join(context.srcDir, 'pages'));
      expect(context.componentsDir).toEqual(join(context.srcDir, 'components'));
      expect(context.directivesDir).toEqual(join(context.srcDir, 'directives'));
      expect(context.pipesDir).toEqual(join(context.srcDir, 'pipes'));
      expect(context.providersDir).toEqual(join(context.srcDir, 'providers'));
      expect(context.nodeModulesDir).toEqual(join(process.cwd(), Constants.NODE_MODULES));
      expect(context.ionicAngularDir).toEqual(join(process.cwd(), Constants.NODE_MODULES, Constants.IONIC_ANGULAR));
      expect(fakeConfig[Constants.ENV_VAR_AT_ANGULAR_DIR]).toEqual(join(process.cwd(), Constants.NODE_MODULES, Constants.AT_ANGULAR));
      expect(context.coreCompilerFilePath).toEqual(join(context.ionicAngularDir, 'compiler'));
      expect(context.coreDir).toEqual(context.ionicAngularDir);
      expect(fakeConfig[Constants.ENV_VAR_RXJS_DIR]).toEqual(join(process.cwd(), Constants.NODE_MODULES, Constants.RXJS));
      expect(fakeConfig[Constants.ENV_VAR_IONIC_ANGULAR_TEMPLATE_DIR]).toEqual(join(context.ionicAngularDir, 'templates'));
      expect(context.platform).toEqual(null);
      expect(context.target).toEqual(null);
      expect(fakeConfig[Constants.ENV_VAR_IONIC_ANGULAR_ENTRY_POINT]).toEqual(join(context.ionicAngularDir, 'index.js'));
      expect(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR]).toEqual(join(__dirname, '..', '..'));
      expect(fakeConfig[Constants.ENV_VAR_GENERATE_SOURCE_MAP]).toEqual('true');
      expect(fakeConfig[Constants.ENV_VAR_SOURCE_MAP_TYPE]).toEqual(Constants.SOURCE_MAP_TYPE_EXPENSIVE);
      expect(fakeConfig[Constants.ENV_TS_CONFIG]).toEqual(join(process.cwd(), 'tsconfig.json'));
      expect(fakeConfig[Constants.ENV_READ_CONFIG_JSON]).toEqual('true');
      expect(fakeConfig[Constants.ENV_APP_ENTRY_POINT]).toEqual(join(context.srcDir, 'app', 'main.ts'));
      expect(fakeConfig[Constants.ENV_APP_NG_MODULE_PATH]).toEqual(join(context.srcDir, 'app', 'app.module.ts'));
      expect(fakeConfig[Constants.ENV_APP_NG_MODULE_CLASS]).toEqual('AppModule');
      expect(fakeConfig[Constants.ENV_GLOB_UTIL]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'dist', 'util', 'glob-util.js'));
      expect(fakeConfig[Constants.ENV_CLEAN_BEFORE_COPY]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_CLOSURE_JAR]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'bin', 'closure-compiler.jar'));
      expect(fakeConfig[Constants.ENV_OUTPUT_JS_FILE_NAME]).toEqual('main.js');
      expect(fakeConfig[Constants.ENV_OUTPUT_CSS_FILE_NAME]).toEqual('main.css');
      expect(fakeConfig[Constants.ENV_WEBPACK_FACTORY]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'dist', 'webpack', 'ionic-webpack-factory.js'));
      expect(fakeConfig[Constants.ENV_WEBPACK_LOADER]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'dist', 'webpack', 'loader.js'));
      expect(fakeConfig[Constants.ENV_OPTIMIZATION_LOADER]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'dist', 'webpack', 'optimization-loader.js'));
      expect(fakeConfig[Constants.ENV_AOT_WRITE_TO_DISK]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_PRINT_ORIGINAL_DEPENDENCY_TREE]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_PRINT_MODIFIED_DEPENDENCY_TREE]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_PRINT_WEBPACK_DEPENDENCY_TREE]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_TYPE_CHECK_ON_LINT]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_BAIL_ON_LINT_ERROR]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_ENABLE_LINT]).toEqual('true');
      expect(fakeConfig[Constants.ENV_DISABLE_LOGGING]).toBeFalsy();
      expect(fakeConfig[Constants.ENV_START_WATCH_TIMEOUT]).toEqual('3000');
      expect(fakeConfig[Constants.ENV_NG_MODULE_FILE_NAME_SUFFIX]).toEqual('.module.ts');

      expect(fakeConfig[Constants.ENV_ACTION_SHEET_CONTROLLER_CLASSNAME]).toEqual('ActionSheetController');
      expect(fakeConfig[Constants.ENV_ACTION_SHEET_CONTROLLER_PATH]).toEqual(join(context.ionicAngularDir, 'components', 'action-sheet', 'action-sheet-controller.js'));
      expect(fakeConfig[Constants.ENV_ACTION_SHEET_VIEW_CONTROLLER_PATH]).toEqual(join(context.ionicAngularDir, 'components', 'action-sheet', 'action-sheet.js'));
      expect(fakeConfig[Constants.ENV_ACTION_SHEET_COMPONENT_PATH]).toEqual(join(context.ionicAngularDir, 'components', 'action-sheet', 'action-sheet-component.js'));
      expect(fakeConfig[Constants.ENV_ACTION_SHEET_COMPONENT_FACTORY_PATH]).toEqual(join(context.ionicAngularDir, 'components', 'action-sheet', 'action-sheet-component.ngfactory.js'));
{'fraction_non_alphanumeric': 0.1476183958390364, 'fraction_numerical': 0.0005474952094169176, 'mean_word_length': 5.434610303830912, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4192167', 'n_tokens_mistral': 4484, 'n_tokens_neox': 4583, 'n_words': 477}