Skip to content

Commit 95a3030

Browse files
Improve tests
1 parent 71df035 commit 95a3030

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

test/data/apis.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use strict';
22

3-
import {Inject, AutoWired} from 'typescript-ioc';
4-
53
import {Path, Server, GET, POST, PUT, DELETE, HttpMethod,
64
PathParam, QueryParam, CookieParam, HeaderParam,
75
FormParam, Param, Context, ServiceContext, ContextRequest,
86
ContextResponse, ContextLanguage, ContextAccept,
97
ContextNext, AcceptLanguage, Accept, FileParam,
108
Errors, Return, BodyOptions} from 'typescript-rest';
119

10+
import * as swagger from '../../src/decorators';
11+
1212
interface Address {
1313
street: string;
1414
}
@@ -20,6 +20,7 @@ interface Person {
2020

2121
@Accept('text/plain')
2222
@Path('mypath')
23+
@swagger.Tags('My Services')
2324
export class MyService {
2425
@GET
2526
@Accept('text/html')
@@ -58,4 +59,12 @@ export class PromiseService {
5859
});
5960
}
6061

62+
@GET
63+
@Path('myFile')
64+
@swagger.Produces('application/pdf')
65+
testFile( @QueryParam('testParam')test?: string ): Promise<Return.DownloadBinaryData> {
66+
return new Promise<Return.DownloadBinaryData>((resolve, reject) => {
67+
resolve(null);
68+
});
69+
}
6170
}

test/unit/definitions.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ describe('Definition generation', () => {
1111
const metadata = new MetadataGenerator('./test/data/apis.ts').generate();
1212
const spec = new SpecGenerator(metadata, getDefaultOptions()).getSpec();
1313

14-
describe('Simple Services', () => {
15-
it('should generate a definition for decorated services', () => {
14+
describe('MyService', () => {
15+
it('should generate paths for decorated services', () => {
1616
expect(spec.paths).to.have.property('/mypath');
17+
expect(spec.paths).to.have.property('/mypath/secondpath');
1718
});
1819
});
1920
});

0 commit comments

Comments
 (0)