forked from asyncapi/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.test.ts
68 lines (62 loc) · 2.34 KB
/
models.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { expect, test } from '@oclif/test';
import path from 'path';
import rimraf from 'rimraf';
import { createMockServer, stopMockServer } from '../../helpers';
const generalOptions = ['generate:models'];
const outputDir = './test/fixtures/generate/models';
describe('models', () => {
before(() => {
createMockServer();
});
after(() => {
stopMockServer();
rimraf.sync(outputDir);
});
test
.stderr()
.stdout()
.command([...generalOptions, 'typescript', 'http://localhost:8080/dummySpec.yml'])
.it('works with remote AsyncAPI files', (ctx, done) => {
expect(ctx.stdout).to.contain(
'Successfully generated the following models: '
);
done();
});
test
.stderr()
.stdout()
.command([...generalOptions, 'typescript', './test/fixtures/specification.yml'])
.it('works when file path is passed without specified output directory', (ctx, done) => {
expect(ctx.stdout).to.match(/Successfully generated the following models:\s+## Model name:/);
done();
});
test
.stderr()
.stdout()
.command([...generalOptions, 'typescript', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './ts')}`])
.it('works when file path is passed with specified output directory', (ctx, done) => {
expect(ctx.stdout).to.contain(
'Successfully generated the following models: '
);
done();
});
test
.stderr()
.stdout()
.command([...generalOptions,'typescript','http://localhost:8080/dummySpec.yml --proxyHost=host --proxyPort=8080'])
.it('should throw error when url is passed with proxyHost and proxyPort with invalid host ', (ctx, done) => {
expect(ctx.stdout).to.contain('');
expect(ctx.stderr).to.equal('error loading AsyncAPI document from url: Failed to download http://localhost:8080/dummySpec.yml --proxyHost=host --proxyPort=8080.\n');
done();
});
describe('with logging diagnostics', () => {
test
.stderr()
.stdout()
.command([...generalOptions, 'typescript', 'http://localhost:8080/dummySpec.yml', '--log-diagnostics'])
.it('works with remote AsyncAPI files', (ctx, done) => {
expect(ctx.stdout).to.match(/URL http:\/\/localhost:8080\/dummySpec.yml is valid but has \(itself and\/or referenced documents\) governance issues./);
done();
});
});
});