Permalink
Browse files

add unit tests

  • Loading branch information...
1 parent 0d3ad0c commit 912c2f5dbdbf3b4b83a3c441f2992527676cddad @Filirom1 committed Mar 28, 2013
Showing with 38 additions and 2 deletions.
  1. +38 −2 test/apiGeneration.coffee
View
@@ -73,7 +73,7 @@ describe 'API generation tests', ->
]
, /Response not declared with the same id/
- it 'should fail on model with invalid id', ->
+ it 'should fail on model without properties', ->
assert.throws ->
swagger.generator express(), {}, [
api:
@@ -84,6 +84,42 @@ describe 'API generation tests', ->
]
, /Response1 does not declares properties/
+ it 'should not fail on model with properties', ->
+ swagger.generator express(), {}, [
+ api:
+ resourcePath: '/test'
+ apis: [path: '/test/1'],
+ models:
+ Response1:
+ id: 'Response1'
+ properties: name: type: 'string'
+ controller: require './fixtures/sourceCrud'
+ ]
+
+ it 'should not fail on model with additionalProperties', ->
+ swagger.generator express(), {}, [
+ api:
+ resourcePath: '/test'
+ apis: [path: '/test/1'],
+ models:
+ Response1:
+ id: 'Response1'
+ additionalProperties: type: 'string'
+ controller: require './fixtures/sourceCrud'
+ ]
+
+ it 'should not fail on model with items', ->
+ swagger.generator express(), {}, [
+ api:
+ resourcePath: '/test'
+ apis: [path: '/test/1'],
+ models:
+ Response1:
+ id: 'Response1'
+ items: type: 'string'
+ controller: require './fixtures/sourceCrud'
+ ]
+
it 'should fail on model already defined', ->
assert.throws ->
swagger.generator express(), {}, [
@@ -682,4 +718,4 @@ describe 'API generation tests', ->
nickname: 'remove'
]
]
- done()
+ done()

0 comments on commit 912c2f5

Please sign in to comment.