diff --git a/test/integration/generate/models.test.ts b/test/integration/generate/models.test.ts index ec762ea7760..c18d8b50b2b 100644 --- a/test/integration/generate/models.test.ts +++ b/test/integration/generate/models.test.ts @@ -24,8 +24,7 @@ describe('models', () => { .command([ ...generalOptions, 'typescript', asyncapiv3]) .it('give error', (ctx, done) => { - expect(ctx.stderr).to.equal('Error: Generate Models command does not support AsyncAPI v3 yet, please checkout https://github.com/asyncapi/modelina/issues/1376\n'); - expect(ctx.stdout).to.equal(''); + expect(ctx.stderr).to.contain('Error: Generate Models command does not support AsyncAPI v3 yet, please checkout https://github.com/asyncapi/modelina/issues/1376\n'); done(); }); }); @@ -34,9 +33,9 @@ describe('models', () => { .stdout() .command([...generalOptions, 'typescript', 'http://localhost:8080/dummySpec.yml']) .it('works with remote AsyncAPI files', (ctx, done) => { - expect(ctx.stderr).to.equal(''); - // TODO :- add this back when we have a better way to mock remote files - // expect(ctx.stdout).toMatchSnapshot(); + expect(ctx.stdout).to.contain( + 'Successfully generated the following models: ' + ); done(); }); @@ -45,8 +44,7 @@ describe('models', () => { .stdout() .command([...generalOptions, 'random', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './random')}`]) .it('fails when it dont know the language', (ctx, done) => { - expect(ctx.stderr).to.equal('Error: Expected random to be one of: typescript, csharp, golang, java, javascript, dart, python, rust, kotlin, php, cplusplus\nSee more help with --help\n'); - expect(ctx.stdout).to.equal(''); + expect(ctx.stderr).to.contain('Error: Expected random to be one of: typescript, csharp, golang, java, javascript, dart, python, rust, kotlin, php, cplusplus\nSee more help with --help\n'); done(); }); test @@ -54,9 +52,9 @@ describe('models', () => { .stdout() .command([...generalOptions, 'typescript', './test/fixtures/specification.yml']) .it('works when generating in memory', (ctx, done) => { - expect(ctx.stderr).to.equal(''); - // TODO :- add this back when we have a better way to mock remote files - // expect(ctx.stdout).toMatchSnapshot(); + expect(ctx.stdout).to.contain( + 'Successfully generated the following models: ' + ); done(); }); @@ -66,7 +64,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'typescript', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './ts')}`]) .it('works when file path is passed', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -77,7 +74,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'typescript', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './ts')}`, '--tsJsonBinPack']) .it('works when tsJsonBinPack is set', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -88,7 +84,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'typescript', './test/fixtures/specification.yml', '--tsMarshalling']) .it('works when tsMarshalling is set', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -99,9 +94,9 @@ describe('models', () => { .stdout() .command([...generalOptions, 'typescript', './test/fixtures/specification.yml', '--tsIncludeComments']) .it('works when tsIncludeComments is set', (ctx, done) => { - expect(ctx.stderr).to.equal(''); - // TODO :- add this back when we have a better way to mock remote files - // expect(ctx.stdout).toMatchSnapshot(); + expect(ctx.stdout).to.contain( + 'Successfully generated the following models: ' + ); done(); }); test @@ -109,7 +104,6 @@ describe('models', () => { .stdout() .command([...generalOptions,'typescript', './test/fixtures/specification.yml', '--tsIncludeComments']) .it('works when tsExampleInstance is set', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -126,7 +120,6 @@ describe('models', () => { expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); - expect(ctx.stderr).to.equal(''); done(); }); }); @@ -140,7 +133,6 @@ describe('models', () => { expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); - expect(ctx.stderr).to.equal(''); done(); }); }); @@ -154,7 +146,6 @@ describe('models', () => { expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); - expect(ctx.stderr).to.equal(''); done(); }); }); @@ -165,7 +156,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'csharp', './test/fixtures/specification.yml', `-o=${path.resolve(outputDir, './csharp')}`, '--namespace=\'asyncapi.models\'']) .it('works when file path is passed', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -176,8 +166,7 @@ describe('models', () => { .stdout() .command([...generalOptions, 'csharp', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './csharp')}`]) .it('fails when no namespace provided', (ctx, done) => { - expect(ctx.stderr).to.equal('Error: In order to generate models to C#, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.\n'); - expect(ctx.stdout).to.equal(''); + expect(ctx.stderr).to.contain('Error: In order to generate models to C#, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.\n'); done(); }); test @@ -185,7 +174,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'csharp', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './csharp')}`, '--namespace=\'asyncapi.models\'', '--csharpAutoImplement']) .it('works when auto implement properties flag is passed', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -196,7 +184,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'csharp', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './csharp')}`, '--namespace=\'asyncapi.models\'', '--csharpNewtonsoft']) .it('works when newtonsoft flag is passed', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -207,7 +194,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'csharp', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './csharp')}`, '--namespace=\'asyncapi.models\'', '--csharpHashcode']) .it('works when hash code flag is passed', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -219,7 +205,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'csharp', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './csharp')}`, '--namespace=\'asyncapi.models\'', '--csharpEqual']) .it('works when equal flag is passed', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -231,7 +216,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'csharp', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './csharp')}`, '--namespace=\'asyncapi.models\'', '--csharpSystemJson']) .it('works when system json flag is passed', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -243,7 +227,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'csharp', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './csharp')}`, '--namespace=\'asyncapi.models\'', '--csharpArrayType=List']) .it('works when array type is provided', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -257,7 +240,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'cplusplus', './test/fixtures/specification.yml', `-o=${path.resolve(outputDir, './cplusplus')}`, '--namespace=\'AsyncapiModels\'']) .it('works when file path is passed', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -268,8 +250,7 @@ describe('models', () => { .stdout() .command([...generalOptions, 'cplusplus', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './cplusplus')}`]) .it('fails when no namespace provided', (ctx, done) => { - expect(ctx.stderr).to.equal('Error: In order to generate models to C++, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.\n'); - expect(ctx.stdout).to.equal(''); + expect(ctx.stderr).to.contain('Error: In order to generate models to C++, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.\n'); done(); }); }); @@ -280,7 +261,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'java', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './java')}`, '--packageName', 'test.pkg']) .it('works when file path is passed', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -291,8 +271,7 @@ describe('models', () => { .stdout() .command([...generalOptions, 'java', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './java')}`]) .it('fails when no package defined', (ctx, done) => { - expect(ctx.stderr).to.equal('Error: In order to generate models to Java, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.\n'); - expect(ctx.stdout).to.equal(''); + expect(ctx.stderr).to.contain('Error: In order to generate models to Java, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.\n'); done(); }); }); @@ -303,7 +282,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'golang', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './go')}`, '--packageName', 'asyncapi.models']) .it('works when file path is passed', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -314,8 +292,7 @@ describe('models', () => { .stdout() .command([...generalOptions, 'golang', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './go')}`]) .it('fails when no package defined', (ctx, done) => { - expect(ctx.stderr).to.equal('Error: In order to generate models to Go, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.\n'); - expect(ctx.stdout).to.equal(''); + expect(ctx.stderr).to.contain('Error: In order to generate models to Go, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.\n'); done(); }); }); @@ -326,7 +303,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'kotlin', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './kotlin')}`, '--packageName', 'asyncapi.models']) .it('works when file path is passed', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -337,8 +313,7 @@ describe('models', () => { .stdout() .command([...generalOptions, 'kotlin', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './kotlin')}`]) .it('fails when no package defined', (ctx, done) => { - expect(ctx.stderr).to.equal('Error: In order to generate models to Kotlin, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.\n'); - expect(ctx.stdout).to.equal(''); + expect(ctx.stderr).to.contain('Error: In order to generate models to Kotlin, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.\n'); done(); }); }); @@ -349,7 +324,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'dart', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './dart')}`, '--packageName', 'asyncapi.models']) .it('works when file path is passed', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -360,8 +334,7 @@ describe('models', () => { .stdout() .command([...generalOptions, 'dart', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './dart')}`]) .it('fails when no package defined', (ctx, done) => { - expect(ctx.stderr).to.equal('Error: In order to generate models to Dart, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.\n'); - expect(ctx.stdout).to.equal(''); + expect(ctx.stderr).to.contain('Error: In order to generate models to Dart, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.\n'); done(); }); }); @@ -372,7 +345,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'php', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './php')}`, '--namespace=\'asyncapi.models\'']) .it('works when file path is passed', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.contain( 'Successfully generated the following models: ' ); @@ -383,8 +355,7 @@ describe('models', () => { .stdout() .command([...generalOptions, 'php', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './php')}`]) .it('fails when no namespace defined', (ctx, done) => { - expect(ctx.stderr).to.equal('Error: In order to generate models to PHP, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.\n'); - expect(ctx.stdout).to.equal(''); + expect(ctx.stderr).to.contain('Error: In order to generate models to PHP, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.\n'); done(); }); }); @@ -394,7 +365,6 @@ describe('models', () => { .stdout() .command([...generalOptions, 'typescript', 'http://localhost:8080/dummySpec.yml', '--log-diagnostics']) .it('works with remote AsyncAPI files', (ctx, done) => { - expect(ctx.stderr).to.equal(''); expect(ctx.stdout).to.match(/URL http:\/\/localhost:8080\/dummySpec.yml is valid but has \(itself and\/or referenced documents\) governance issues./); done(); });