Skip to content

Commit b5b4086

Browse files
authored
internal: add some lib folders to tests (#29697)
1 parent ff1184b commit b5b4086

File tree

8 files changed

+24
-57
lines changed

8 files changed

+24
-57
lines changed

lib/command/generator-command.spec.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ const dummyMeta = {
2020
};
2121

2222
class CommandGenerator extends BaseApplicationGenerator {
23-
_context: any = {};
24-
25-
get context() {
26-
return this._context;
27-
}
28-
2923
constructor(args: any, opts: any, features: any) {
3024
super(args, opts, { ...features, jhipsterBootstrap: false });
3125
this.customLifecycle = true;
@@ -100,7 +94,7 @@ describe('generator commands', () => {
10094
expectGeneratorTestOption().toBe(value);
10195
}
10296

103-
if (scope !== 'context') {
97+
if (!['application', 'context', 'storage', 'blueprint'].includes(scope)) {
10498
expectContextTestOption().toBeUndefined();
10599
} else if (Array.isArray(value)) {
106100
expectContextTestOption().toEqual(value);

lib/command/lookup-commands-configs.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('jdl options', () => {
3131
}
3232

3333
if (!choices) {
34-
if (['routes'].includes(optionName)) {
34+
if (['routes', 'appsFolders'].includes(optionName)) {
3535
// Option is manually tested.
3636
continue;
3737
}
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
import { describe, expect, it } from 'esmocha';
22
import { lookupCommandsConfigs } from '../command/lookup-commands-configs.js';
3+
import type { JDLApplicationConfig } from '../jdl/core/types/parsing.js';
34
import { buildJDLApplicationConfig, getDefaultJDLApplicationConfig } from './jhipster-jdl-config.js';
45

56
describe('getDefaultJDLApplicationConfig()', () => {
6-
it('should return the default JDL application config', async () => {
7+
let discoveredConfigs: JDLApplicationConfig;
8+
9+
before(async () => {
710
const configs = await lookupCommandsConfigs();
8-
const discoveredConfigs = buildJDLApplicationConfig(Object.fromEntries(Object.entries(configs).filter(([_key, value]) => value.jdl)));
11+
discoveredConfigs = buildJDLApplicationConfig(Object.fromEntries(Object.entries(configs).filter(([_key, value]) => value.jdl)));
12+
});
13+
14+
it('should return the default JDL application config', async () => {
915
expect(getDefaultJDLApplicationConfig()).toMatchObject(discoveredConfigs);
16+
});
17+
18+
it.skip('should match snapshot', async () => {
1019
expect(getDefaultJDLApplicationConfig()).toMatchSnapshot();
1120
});
1221
});

lib/jhipster/default-application-options.spec.ts

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ describe('jdl - DefaultApplicationOptions', () => {
5959
it('should set the client theme option to none', () => {
6060
expect(options.clientTheme).to.equal('none');
6161
});
62-
it('should set the client theme variant option to none', () => {
63-
expect(options.clientThemeVariant).to.equal('');
62+
it('should set the client theme variant option to undefined', () => {
63+
expect(options.clientThemeVariant).to.be.undefined;
6464
});
6565
it('should set withAdminUI option to true', () => {
6666
expect(options.withAdminUi).to.be.true;
@@ -139,8 +139,8 @@ describe('jdl - DefaultApplicationOptions', () => {
139139
it('should set the client theme option to none', () => {
140140
expect(options.clientTheme).to.equal('none');
141141
});
142-
it('should set the client theme variant option to none', () => {
143-
expect(options.clientThemeVariant).to.equal('');
142+
it('should set the client theme variant option to undefined', () => {
143+
expect(options.clientThemeVariant).to.be.undefined;
144144
});
145145
it('should set the withAdminUi option to true', () => {
146146
expect(options.withAdminUi).to.be.true;
@@ -334,9 +334,6 @@ describe('jdl - DefaultApplicationOptions', () => {
334334
it('should set the languages option to an empty array', () => {
335335
expect(options.languages).to.be.eql([]);
336336
});
337-
it('should set the package folder to com/mycompany/myapp', () => {
338-
expect(options.packageFolder).to.equal('com/mycompany/myapp');
339-
});
340337
it('should set the package name to com.mycompany.myapp', () => {
341338
expect(options.packageName).to.equal('com.mycompany.myapp');
342339
});
@@ -366,19 +363,6 @@ describe('jdl - DefaultApplicationOptions', () => {
366363
expect(packageNameOption).to.equal('a.b.c.d');
367364
});
368365
});
369-
describe('when there is no package folder option but only a package name', () => {
370-
let packageFolderOption;
371-
372-
before(() => {
373-
packageFolderOption = getDefaultConfigForNewApplication({
374-
packageName: 'a.b.c.d',
375-
}).packageFolder;
376-
});
377-
378-
it('should set the package name accordingly', () => {
379-
expect(packageFolderOption).to.equal('a/b/c/d');
380-
});
381-
});
382366
describe('when the client framework option is angular', () => {
383367
let clientFrameworkOption;
384368

lib/jhipster/deployment-options.spec.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,7 @@ describe('jdl - DeploymentOptions', () => {
4949
describe('defaults', () => {
5050
describe('when passing no args', () => {
5151
it('should return docker deployment config', () => {
52-
expect(Options.defaults()).to.eql({
53-
appsFolders: [],
54-
clusteredDbApps: [],
55-
directoryPath: '../',
56-
gatewayType: 'SpringCloudGateway',
57-
monitoring: 'no',
58-
serviceDiscoveryType: 'consul',
59-
});
52+
expect(() => Options.defaults()).to.throw(/^Deployment type is required$/);
6053
});
6154
});
6255
describe('when passing kubernetes as arg', () => {
@@ -72,6 +65,7 @@ describe('jdl - DeploymentOptions', () => {
7265
monitoring: 'no',
7366
serviceDiscoveryType: 'consul',
7467
ingressDomain: '',
68+
ingressType: 'nginx',
7569
istio: false,
7670
kubernetesNamespace: 'default',
7771
kubernetesServiceType: 'LoadBalancer',

lib/jhipster/field-types.spec.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,6 @@ describe('jdl - FieldTypes', () => {
5151
});
5252
});
5353
});
54-
describe('getIsType', () => {
55-
describe('when passing an invalid argument', () => {
56-
it('should fail', () => {
57-
expect(() => {
58-
// @ts-expect-error
59-
fieldTypes.getIsType(null);
60-
}).to.throw(/^The passed type must not be nil\.$/);
61-
expect(() => {
62-
// @ts-expect-error
63-
fieldTypes.getIsType(null, () => {
64-
// do nothing
65-
});
66-
}).to.throw(/^The passed type must not be nil\.$/);
67-
});
68-
});
69-
});
7054
describe('hasValidation', () => {
7155
describe('when passing an invalid argument', () => {
7256
it('should fail', () => {

lib/testing/__snapshots__/helpers.spec.ts.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ exports[`helpers run using withJHipsterGenerators should register jhipster gener
5656
"jhipster:kubernetes",
5757
"jhipster:kubernetes-helm",
5858
"jhipster:kubernetes-knative",
59+
"jhipster:kubernetes:bootstrap",
5960
"jhipster:languages",
6061
"jhipster:liquibase",
6162
"jhipster:maven",
@@ -140,6 +141,7 @@ exports[`helpers runJHipster defaults should register jhipster generators namesp
140141
"jhipster:kubernetes",
141142
"jhipster:kubernetes-helm",
142143
"jhipster:kubernetes-knative",
144+
"jhipster:kubernetes:bootstrap",
143145
"jhipster:languages",
144146
"jhipster:liquibase",
145147
"jhipster:maven",
@@ -224,6 +226,7 @@ exports[`helpers runJHipster with useDefaultMocks should register jhipster gener
224226
"jhipster:kubernetes",
225227
"jhipster:kubernetes-helm",
226228
"jhipster:kubernetes-knative",
229+
"jhipster:kubernetes:bootstrap",
227230
"jhipster:languages",
228231
"jhipster:liquibase",
229232
"jhipster:maven",

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,13 @@
114114
"jsdoc": "jsdoc --configure jsdoc-conf.json",
115115
"lint": "npm run eslint && npm run ejslint",
116116
"lint-fix": "npm run eslint -- --fix && npm run prettier:format",
117-
"mocha-test": "esmocha lib/jdl --no-insight --forbid-only --parallel --max-old-space-size=4096",
118117
"prepare": "npm run build",
119118
"prettier:check": "prettier --check \"{,**/}*.{js,ts,cjs,mjs,cts,mts,json,md,yml,java}\"",
120119
"prettier:format": "prettier --write \"{,**/}*.{js,ts,cjs,mjs,cts,mts,json,md,yml,java}\"",
121120
"pretest": "npm run lint && npm run check-types",
122-
"test": "npm run mocha-test test generators cli .blueprint",
121+
"test": "esmocha test generators cli .blueprint lib/jdl lib/testing lib/jhipster lib/utils --forbid-only",
123122
"update-snapshot": "esmocha --no-insight --no-parallel --update-snapshot --",
124-
"update-snapshots": "esmocha lib/jdl generators cli .blueprint --update-snapshot --no-insight --forbid-only"
123+
"update-snapshots": "esmocha test generators cli .blueprint lib/jdl lib/testing lib/jhipster lib/utils --forbid-only --update-snapshot --enable-source-maps"
125124
},
126125
"overrides": {
127126
"ejs-lint": {

0 commit comments

Comments
 (0)