Skip to content

Commit

Permalink
Merge pull request #15966 from Tcharl/constantref
Browse files Browse the repository at this point in the history
Constants in jhipster tests
  • Loading branch information
DanielFran authored Aug 14, 2021
2 parents c1f4095 + 7fe53f3 commit 51d32f4
Show file tree
Hide file tree
Showing 40 changed files with 801 additions and 651 deletions.
35 changes: 20 additions & 15 deletions test/app-client-custom-path.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const helpers = require('yeoman-test');
const getFilesForOptions = require('./utils/utils').getFilesForOptions;
const expectedFiles = require('./utils/expected-files');
const reactFiles = require('../generators/client/files-react').files;
const { SQL, H2_MEMORY, POSTGRESQL } = require('../jdl/jhipster/database-types');
const { ANGULAR_X, REACT } = require('../jdl/jhipster/client-framework-types');
const { JWT } = require('../jdl/jhipster/authentication-types');
const { EHCACHE } = require('../jdl/jhipster/cache-types');
const { MAVEN } = require('../jdl/jhipster/build-tool-types');

const outputPathCustomizer = paths => (paths ? paths.replace(/^src\/main\/webapp([$/])/, 'src/main/webapp2$1') : undefined);

Expand All @@ -31,20 +36,20 @@ describe('JHipster generator', () => {
})
.withPrompts({
baseName: 'jhipster',
clientFramework: 'angularX',
clientFramework: ANGULAR_X,
packageName: 'com.mycompany.myapp',
packageFolder: 'com/mycompany/myapp',
serviceDiscoveryType: false,
authenticationType: 'jwt',
cacheProvider: 'ehcache',
authenticationType: JWT,
cacheProvider: EHCACHE,
enableHibernateCache: true,
databaseType: 'sql',
devDatabaseType: 'h2Memory',
prodDatabaseType: 'postgresql',
databaseType: SQL,
devDatabaseType: H2_MEMORY,
prodDatabaseType: POSTGRESQL,
enableTranslation: true,
nativeLanguage: 'en',
languages: ['fr'],
buildTool: 'maven',
buildTool: MAVEN,
rememberMeKey: '5c37379956bd1242f5636c8cb322c2966ad81277',
skipClient: false,
skipUserManagement: false,
Expand Down Expand Up @@ -92,20 +97,20 @@ describe('JHipster generator', () => {
})
.withPrompts({
baseName: 'jhipster',
clientFramework: 'react',
clientFramework: REACT,
packageName: 'com.mycompany.myapp',
packageFolder: 'com/mycompany/myapp',
serviceDiscoveryType: false,
authenticationType: 'jwt',
cacheProvider: 'ehcache',
authenticationType: JWT,
cacheProvider: EHCACHE,
enableHibernateCache: true,
databaseType: 'sql',
devDatabaseType: 'h2Memory',
prodDatabaseType: 'postgresql',
databaseType: SQL,
devDatabaseType: H2_MEMORY,
prodDatabaseType: POSTGRESQL,
enableTranslation: true,
nativeLanguage: 'en',
languages: ['fr'],
buildTool: 'maven',
buildTool: MAVEN,
rememberMeKey: '5c37379956bd1242f5636c8cb322c2966ad81277',
skipClient: false,
skipUserManagement: false,
Expand All @@ -128,7 +133,7 @@ describe('JHipster generator', () => {
outputPathCustomizer: applyCustomizers,
enableTranslation: true,
serviceDiscoveryType: false,
authenticationType: 'jwt',
authenticationType: JWT,
testFrameworks: [],
})
);
Expand Down
31 changes: 16 additions & 15 deletions test/blueprint/app-blueprint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ const fse = require('fs-extra');
const jestExpect = require('expect');
const expect = require('chai').expect;
const jhipsterVersion = require('../../package.json').version;
const constants = require('../../generators/generator-constants');
const EnvironmentBuilder = require('../../cli/environment-builder');

const ANGULAR = constants.SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR;
const { SQL, H2_MEMORY, MYSQL } = require('../../jdl/jhipster/database-types');
const { ANGULAR_X } = require('../../jdl/jhipster/client-framework-types');
const { JWT } = require('../../jdl/jhipster/authentication-types');
const { EHCACHE } = require('../../jdl/jhipster/cache-types');

describe('JHipster application generator with blueprint', () => {
describe('generate application with a version-compatible blueprint', () => {
Expand Down Expand Up @@ -82,16 +83,16 @@ describe('JHipster application generator with blueprint', () => {
})
.withPrompts({
baseName: 'jhipster',
clientFramework: ANGULAR,
clientFramework: ANGULAR_X,
packageName: 'com.mycompany.myapp',
packageFolder: 'com/mycompany/myapp',
serviceDiscoveryType: false,
authenticationType: 'jwt',
cacheProvider: 'ehcache',
authenticationType: JWT,
cacheProvider: EHCACHE,
enableHibernateCache: true,
databaseType: 'sql',
devDatabaseType: 'h2Memory',
prodDatabaseType: 'mysql',
databaseType: SQL,
devDatabaseType: H2_MEMORY,
prodDatabaseType: MYSQL,
enableTranslation: true,
nativeLanguage: 'en',
languages: ['fr'],
Expand Down Expand Up @@ -177,16 +178,16 @@ describe('JHipster application generator with blueprint', () => {
})
.withPrompts({
baseName: 'jhipster',
clientFramework: ANGULAR,
clientFramework: ANGULAR_X,
packageName: 'com.mycompany.myapp',
packageFolder: 'com/mycompany/myapp',
serviceDiscoveryType: false,
authenticationType: 'jwt',
cacheProvider: 'ehcache',
authenticationType: JWT,
cacheProvider: EHCACHE,
enableHibernateCache: true,
databaseType: 'sql',
devDatabaseType: 'h2Memory',
prodDatabaseType: 'mysql',
databaseType: SQL,
devDatabaseType: H2_MEMORY,
prodDatabaseType: MYSQL,
enableTranslation: true,
nativeLanguage: 'en',
languages: ['fr'],
Expand Down
12 changes: 8 additions & 4 deletions test/blueprint/client-blueprint-custom-path.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
const expectedFiles = require('../utils/expected-files');
const ClientGenerator = require('../../generators/client');
const { MYSQL } = require('../../jdl/jhipster/database-types');
const { ANGULAR_X } = require('../../jdl/jhipster/client-framework-types');
const { JWT } = require('../../jdl/jhipster/authentication-types');
const { MAVEN } = require('../../jdl/jhipster/build-tool-types');

const mockBlueprintSubGen = class extends ClientGenerator {
constructor(args, opts) {
Expand Down Expand Up @@ -62,17 +66,17 @@ describe('JHipster client generator with blueprint with path customizer', () =>
.run(path.join(__dirname, '../../generators/client'))
.withOptions({
fromCli: true,
build: 'maven',
auth: 'jwt',
db: 'mysql',
build: MAVEN,
auth: JWT,
db: MYSQL,
skipInstall: true,
blueprint: blueprintName,
skipChecks: true,
})
.withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:client']])
.withPrompts({
baseName: 'jhipster',
clientFramework: 'angularX',
clientFramework: ANGULAR_X,
enableTranslation: true,
nativeLanguage: 'en',
languages: ['en', 'fr'],
Expand Down
17 changes: 9 additions & 8 deletions test/blueprint/client-blueprint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
const expectedFiles = require('../utils/expected-files');
const ClientGenerator = require('../../generators/client');
const constants = require('../../generators/generator-constants');

const ANGULAR = constants.SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR;
const { MYSQL } = require('../../jdl/jhipster/database-types');
const { ANGULAR_X } = require('../../jdl/jhipster/client-framework-types');
const { JWT } = require('../../jdl/jhipster/authentication-types');
const { MAVEN } = require('../../jdl/jhipster/build-tool-types');

const MockedClientGenerator = class MockedClientGenerator extends ClientGenerator {
constructor(args, opts) {
Expand Down Expand Up @@ -61,17 +62,17 @@ describe('JHipster client generator with blueprint', () => {
.run(path.join(__dirname, '../../generators/client'))
.withOptions({
fromCli: true,
build: 'maven',
auth: 'jwt',
db: 'mysql',
build: MAVEN,
auth: JWT,
db: MYSQL,
skipInstall: true,
blueprint: blueprintName,
skipChecks: true,
})
.withGenerators([[MockedClientGenerator, 'jhipster-myblueprint:client']])
.withPrompts({
baseName: 'jhipster',
clientFramework: ANGULAR,
clientFramework: ANGULAR_X,
enableTranslation: true,
nativeLanguage: 'en',
languages: ['fr', 'en'],
Expand Down Expand Up @@ -104,7 +105,7 @@ describe('JHipster client generator with blueprint', () => {
.withGenerators([[helpers.createDummyGenerator(), 'jhipster-myblueprint:client']])
.withPrompts({
baseName: 'jhipster',
clientFramework: ANGULAR,
clientFramework: ANGULAR_X,
enableTranslation: true,
nativeLanguage: 'en',
languages: ['fr', 'en'],
Expand Down
17 changes: 11 additions & 6 deletions test/blueprint/entity-blueprint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const helpers = require('yeoman-test');
const expectedFiles = require('../utils/expected-files').entity;
const EntityGenerator = require('../../generators/entity');
const constants = require('../../generators/generator-constants');
const { MapperTypes, ServiceTypes, PaginationTypes } = require('../../jdl/jhipster/entity-options');

const NO_SERVICE = ServiceTypes.NO;
const NO_PAGINATION = PaginationTypes.NO;
const NO_DTO = MapperTypes.NO;

const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR;

Expand Down Expand Up @@ -110,9 +115,9 @@ describe('JHipster entity generator with blueprint', () => {
fieldAdd: false,
relationshipAdd: false,
baseName: 'jhipster',
dto: 'no',
service: 'no',
pagination: 'no',
dto: NO_DTO,
service: NO_SERVICE,
pagination: NO_PAGINATION,
});
});

Expand Down Expand Up @@ -151,9 +156,9 @@ describe('JHipster entity generator with blueprint', () => {
.withPrompts({
fieldAdd: false,
relationshipAdd: false,
dto: 'no',
service: 'no',
pagination: 'no',
dto: NO_DTO,
service: NO_SERVICE,
pagination: NO_PAGINATION,
})
.on('end', done);
});
Expand Down
11 changes: 8 additions & 3 deletions test/blueprint/entity-client-blueprint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const helpers = require('yeoman-test');
const expectedFiles = require('../utils/expected-files').entity;
const EntityClientGenerator = require('../../generators/entity-client');
const constants = require('../../generators/generator-constants');
const { MapperTypes, ServiceTypes, PaginationTypes } = require('../../jdl/jhipster/entity-options');

const NO_SERVICE = ServiceTypes.NO;
const NO_PAGINATION = PaginationTypes.NO;
const NO_DTO = MapperTypes.NO;

const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR;
const ANGULAR_DIR = constants.ANGULAR_DIR;
Expand Down Expand Up @@ -50,9 +55,9 @@ describe('JHipster entity client generator with blueprint', () => {
.withPrompts({
fieldAdd: false,
relationshipAdd: false,
dto: 'no',
service: 'no',
pagination: 'no',
dto: NO_DTO,
service: NO_SERVICE,
pagination: NO_PAGINATION,
})
.on('end', done);
});
Expand Down
11 changes: 8 additions & 3 deletions test/blueprint/entity-i18n-blueprint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const helpers = require('yeoman-test');
const expectedFiles = require('../utils/expected-files').entity;
const EntityI18NGenerator = require('../../generators/entity-i18n');
const constants = require('../../generators/generator-constants');
const { MapperTypes, ServiceTypes, PaginationTypes } = require('../../jdl/jhipster/entity-options');

const NO_SERVICE = ServiceTypes.NO;
const NO_PAGINATION = PaginationTypes.NO;
const NO_DTO = MapperTypes.NO;

const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR;

Expand Down Expand Up @@ -61,9 +66,9 @@ describe('JHipster entity i18n generator with blueprint', () => {
.withPrompts({
fieldAdd: false,
relationshipAdd: false,
dto: 'no',
service: 'no',
pagination: 'no',
dto: NO_DTO,
service: NO_SERVICE,
pagination: NO_PAGINATION,
})
.run();
});
Expand Down
11 changes: 8 additions & 3 deletions test/blueprint/entity-server-blueprint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const helpers = require('yeoman-test');
const expectedFiles = require('../utils/expected-files').entity;
const EntityServerGenerator = require('../../generators/entity-server');
const constants = require('../../generators/generator-constants');
const { MapperTypes, ServiceTypes, PaginationTypes } = require('../../jdl/jhipster/entity-options');

const NO_SERVICE = ServiceTypes.NO;
const NO_PAGINATION = PaginationTypes.NO;
const NO_DTO = MapperTypes.NO;

const SERVER_MAIN_SRC_DIR = constants.SERVER_MAIN_SRC_DIR;
const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR;
Expand Down Expand Up @@ -62,9 +67,9 @@ describe('JHipster entity server generator with blueprint', () => {
.withPrompts({
fieldAdd: false,
relationshipAdd: false,
dto: 'no',
service: 'no',
pagination: 'no',
dto: NO_DTO,
service: NO_SERVICE,
pagination: NO_PAGINATION,
})
);

Expand Down
19 changes: 10 additions & 9 deletions test/blueprint/multiple-app-blueprints.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ const ClientGenerator = require('../../generators/client');
const ServerGenerator = require('../../generators/server');
const CommonGenerator = require('../../generators/common');
const LanguagesGenerator = require('../../generators/languages');
const constants = require('../../generators/generator-constants');

const ANGULAR = constants.SUPPORTED_CLIENT_FRAMEWORKS.ANGULAR;
const { MYSQL, SQL, H2_MEMORY } = require('../../jdl/jhipster/database-types');
const { ANGULAR_X } = require('../../jdl/jhipster/client-framework-types');
const { JWT } = require('../../jdl/jhipster/authentication-types');
const { EHCACHE } = require('../../jdl/jhipster/cache-types');

const createMockBlueprint = function (parent, spy) {
return class extends parent {
Expand Down Expand Up @@ -72,16 +73,16 @@ const options = {

const prompts = {
baseName: 'jhipster',
clientFramework: ANGULAR,
clientFramework: ANGULAR_X,
packageName: 'com.mycompany.myapp',
packageFolder: 'com/mycompany/myapp',
serviceDiscoveryType: false,
authenticationType: 'jwt',
cacheProvider: 'ehcache',
authenticationType: JWT,
cacheProvider: EHCACHE,
enableHibernateCache: true,
databaseType: 'sql',
devDatabaseType: 'h2Memory',
prodDatabaseType: 'mysql',
databaseType: SQL,
devDatabaseType: H2_MEMORY,
prodDatabaseType: MYSQL,
enableTranslation: true,
nativeLanguage: 'en',
languages: ['fr'],
Expand Down
Loading

0 comments on commit 51d32f4

Please sign in to comment.