<commit_before>/**
 * Copyright 2013-2021 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see https://www.jhipster.tech/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/* eslint-disable no-unused-expressions */

const { expect } = require('chai');
const {
  getConfigForMonolithApplication,
  getConfigForGatewayApplication,
  getConfigForMicroserviceApplication,
  getDefaultConfigForNewApplication,
} = require('../../../jdl/jhipster/default-application-options');

describe('DefaultApplicationOptions', () => {
  describe('getConfigForMonolithApplication', () => {
    context('without passing custom options', () => {
      let options;

      before(() => {
        options = getConfigForMonolithApplication();
      });

      it('should set the application type to monolith', () => {
        expect(options.applicationType).to.equal('monolith');
      });
      it('should set the server port to 8080', () => {
        expect(options.serverPort).to.equal('8080');
      });
      it('should set the authentication type to jwt', () => {
        expect(options.authenticationType).to.equal('jwt');
      });
      it('should set the cache provider to ehcache', () => {
        expect(options.cacheProvider).to.equal('ehcache');
      });
      it('should set the user management skipping option to false', () => {
        expect(options.skipUserManagement).to.be.false;
      });
      it('should set the client framework option to angular', () => {
        expect(options.clientFramework).to.equal('angularX');
      });
      it('should set the client theme option to none', () => {
        expect(options.clientTheme).to.equal('none');
      });
      it('should set the client theme variant option to none', () => {
        expect(options.clientThemeVariant).to.equal('');
      });
      it('should set withAdminUI option to true', () => {
        expect(options.withAdminUi).to.be.true;
      });
    });
    context('when passing a custom client theme and no variant', () => {
      let clientThemeVariantOption;

      before(() => {
        clientThemeVariantOption = getConfigForMonolithApplication({
          clientTheme: 'custom',
        }).clientThemeVariant;
      });

      it('should set the client theme variant to the primary', () => {
        expect(clientThemeVariantOption).to.equal('primary');
      });
    });
    context('when the authentication type is oauth2', () => {
      let skipUserManagementOption;

      before(() => {
        skipUserManagementOption = getConfigForMonolithApplication({
          authenticationType: 'oauth2',
        }).skipUserManagement;
      });

      it('should set the user management skipping option to true', () => {
        expect(skipUserManagementOption).to.be.true;
      });
    });
    context('when passing custom options', () => {
      let options;

      before(() => {
        options = getConfigForMonolithApplication({
          applicationType: 'custom',
        });
      });

      it('should ignore the application type', () => {
        expect(options.applicationType).to.equal('monolith');
      });
    });
  });
  describe('getConfigForGatewayApplication', () => {
    context('without passing custom options', () => {
      let options;

      before(() => {
        options = getConfigForGatewayApplication();
      });

      it('should set the application type to gateway', () => {
        expect(options.applicationType).to.equal('gateway');
      });
      it('should set the server port to 8080', () => {
        expect(options.serverPort).to.equal('8080');
      });
      it('should set the authentication type to jwt', () => {
        expect(options.authenticationType).to.equal('jwt');
      });
      it('should set the cache provider to ehcache', () => {
        expect(options.cacheProvider).to.equal('ehcache');
      });
      it('should set the user management skipping option to false', () => {<commit_msg>Fix npm test for default application options with Gateway<commit_after>/**
 * Copyright 2013-2021 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see https://www.jhipster.tech/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/* eslint-disable no-unused-expressions */

const { expect } = require('chai');
const {
  getConfigForMonolithApplication,
  getConfigForGatewayApplication,
  getConfigForMicroserviceApplication,
  getDefaultConfigForNewApplication,
} = require('../../../jdl/jhipster/default-application-options');

describe('DefaultApplicationOptions', () => {
  describe('getConfigForMonolithApplication', () => {
    context('without passing custom options', () => {
      let options;

      before(() => {
        options = getConfigForMonolithApplication();
      });

      it('should set the application type to monolith', () => {
        expect(options.applicationType).to.equal('monolith');
      });
      it('should set the server port to 8080', () => {
        expect(options.serverPort).to.equal('8080');
      });
      it('should set the authentication type to jwt', () => {
        expect(options.authenticationType).to.equal('jwt');
      });
      it('should set the cache provider to ehcache', () => {
        expect(options.cacheProvider).to.equal('ehcache');
      });
      it('should set the user management skipping option to false', () => {
        expect(options.skipUserManagement).to.be.false;
      });
      it('should set the client framework option to angular', () => {
        expect(options.clientFramework).to.equal('angularX');
      });
      it('should set the client theme option to none', () => {
        expect(options.clientTheme).to.equal('none');
      });
      it('should set the client theme variant option to none', () => {
        expect(options.clientThemeVariant).to.equal('');
      });
      it('should set withAdminUI option to true', () => {
        expect(options.withAdminUi).to.be.true;
      });
    });
    context('when passing a custom client theme and no variant', () => {
      let clientThemeVariantOption;

      before(() => {
        clientThemeVariantOption = getConfigForMonolithApplication({
          clientTheme: 'custom',
        }).clientThemeVariant;
      });

      it('should set the client theme variant to the primary', () => {
        expect(clientThemeVariantOption).to.equal('primary');
      });
    });
    context('when the authentication type is oauth2', () => {
      let skipUserManagementOption;

      before(() => {
        skipUserManagementOption = getConfigForMonolithApplication({
          authenticationType: 'oauth2',
        }).skipUserManagement;
      });

      it('should set the user management skipping option to true', () => {
        expect(skipUserManagementOption).to.be.true;
      });
    });
    context('when passing custom options', () => {
      let options;

      before(() => {
        options = getConfigForMonolithApplication({
          applicationType: 'custom',
        });
      });

      it('should ignore the application type', () => {
        expect(options.applicationType).to.equal('monolith');
      });
    });
  });
  describe('getConfigForGatewayApplication', () => {
    context('without passing custom options', () => {
      let options;

      before(() => {
        options = getConfigForGatewayApplication();
      });

      it('should set the application type to gateway', () => {
        expect(options.applicationType).to.equal('gateway');
      });
      it('should set the server port to 8080', () => {
        expect(options.serverPort).to.equal('8080');
      });
      it('should set the authentication type to jwt', () => {
        expect(options.authenticationType).to.equal('jwt');
      });
      it('should set the cache provider to no', () => {
        expect(options.cacheProvider).to.equal('no');
      });
      it('should disable hibernate cache', () => {
        expect(options.enableHibernateCache).to.be.false;
      });
      it('should set the user management skipping option to false', () => {
{'fraction_non_alphanumeric': 0.13812996625666704, 'fraction_numerical': 0.006530967671710025, 'mean_word_length': 2.933219178082192, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 64, 'https://': 4, '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': '6739113', 'n_tokens_mistral': 2439, 'n_tokens_neox': 2353, 'n_words': 655}