-
-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathmodels.test.ts
49 lines (45 loc) · 1.48 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
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', `-o=${ path.resolve(outputDir, './ts')}`])
.it('works when file path is passed', (ctx, done) => {
expect(ctx.stdout).to.contain(
'Successfully generated the following models: '
);
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();
});
});
});