Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagobustamante committed May 11, 2017
1 parent 71df035 commit 95a3030
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions test/data/apis.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';

import {Inject, AutoWired} from 'typescript-ioc';

import {Path, Server, GET, POST, PUT, DELETE, HttpMethod,
PathParam, QueryParam, CookieParam, HeaderParam,
FormParam, Param, Context, ServiceContext, ContextRequest,
ContextResponse, ContextLanguage, ContextAccept,
ContextNext, AcceptLanguage, Accept, FileParam,
Errors, Return, BodyOptions} from 'typescript-rest';

import * as swagger from '../../src/decorators';

interface Address {
street: string;
}
Expand All @@ -20,6 +20,7 @@ interface Person {

@Accept('text/plain')
@Path('mypath')
@swagger.Tags('My Services')
export class MyService {
@GET
@Accept('text/html')
Expand Down Expand Up @@ -58,4 +59,12 @@ export class PromiseService {
});
}

@GET
@Path('myFile')
@swagger.Produces('application/pdf')
testFile( @QueryParam('testParam')test?: string ): Promise<Return.DownloadBinaryData> {
return new Promise<Return.DownloadBinaryData>((resolve, reject) => {
resolve(null);
});
}
}
5 changes: 3 additions & 2 deletions test/unit/definitions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ describe('Definition generation', () => {
const metadata = new MetadataGenerator('./test/data/apis.ts').generate();
const spec = new SpecGenerator(metadata, getDefaultOptions()).getSpec();

describe('Simple Services', () => {
it('should generate a definition for decorated services', () => {
describe('MyService', () => {
it('should generate paths for decorated services', () => {
expect(spec.paths).to.have.property('/mypath');
expect(spec.paths).to.have.property('/mypath/secondpath');
});
});
});

0 comments on commit 95a3030

Please sign in to comment.