-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3134 from wing328/js_travis
[Javascript] Add auto-generated test files and .travis.yml to JS API client
- Loading branch information
Showing
40 changed files
with
1,759 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
modules/swagger-codegen/src/main/resources/Javascript/api_test.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
(function(root, factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
// AMD. | ||
define(['expect.js', '../../src/index'], factory); | ||
} else if (typeof module === 'object' && module.exports) { | ||
// CommonJS-like environments that support module.exports, like Node. | ||
factory(require('expect.js'), require('../../src/index')); | ||
} else { | ||
// Browser globals (root is window) | ||
factory(root.expect, root.{{moduleName}}); | ||
} | ||
}(this, function(expect, {{moduleName}}) { | ||
'use strict'; | ||
var instance; | ||
beforeEach(function() { | ||
instance = new {{moduleName}}.{{classname}}(); | ||
}); | ||
|
||
var getProperty = function(object, getter, property) { | ||
// Use getter method if present; otherwise, get the property directly. | ||
if (typeof object[getter] === 'function') | ||
return object[getter](); | ||
else | ||
return object[property]; | ||
} | ||
|
||
var setProperty = function(object, setter, property, value) { | ||
// Use setter method if present; otherwise, set the property directly. | ||
if (typeof object[setter] === 'function') | ||
object[setter](value); | ||
else | ||
object[property] = value; | ||
} | ||
|
||
describe('{{classname}}', function() { | ||
{{#operations}} | ||
{{#operation}} | ||
describe('{{operationId}}', function() { | ||
it('should call {{operationId}} successfully', function(done) { | ||
//uncomment below and update the code to test {{operationId}} | ||
//instance.{{operationId}}(pet, function(error) { | ||
// if (error) throw error; | ||
//expect().to.be(); | ||
//}); | ||
done(); | ||
}); | ||
}); | ||
{{/operation}} | ||
{{/operations}} | ||
}); | ||
|
||
})); |
1 change: 1 addition & 0 deletions
1
modules/swagger-codegen/src/main/resources/Javascript/mocha.opts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--timeout 10000 |
64 changes: 64 additions & 0 deletions
64
modules/swagger-codegen/src/main/resources/Javascript/model_test.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
(function(root, factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
// AMD. | ||
define(['expect.js', '../../src/index'], factory); | ||
} else if (typeof module === 'object' && module.exports) { | ||
// CommonJS-like environments that support module.exports, like Node. | ||
factory(require('expect.js'), require('../../src/index')); | ||
} else { | ||
// Browser globals (root is window) | ||
factory(root.expect, root.{{moduleName}}); | ||
} | ||
}(this, function(expect, {{moduleName}}) { | ||
'use strict'; | ||
var instance; | ||
beforeEach(function() { | ||
{{#models}} | ||
{{#model}} | ||
{{^isEnum}} | ||
instance = new {{moduleName}}.{{classname}}(); | ||
{{/isEnum}} | ||
{{/model}} | ||
{{/models}} | ||
}); | ||
|
||
var getProperty = function(object, getter, property) { | ||
// Use getter method if present; otherwise, get the property directly. | ||
if (typeof object[getter] === 'function') | ||
return object[getter](); | ||
else | ||
return object[property]; | ||
} | ||
|
||
var setProperty = function(object, setter, property, value) { | ||
// Use setter method if present; otherwise, set the property directly. | ||
if (typeof object[setter] === 'function') | ||
object[setter](value); | ||
else | ||
object[property] = value; | ||
} | ||
|
||
describe('{{classname}}', function() { | ||
it('should create an instance of {{classname}}', function() { | ||
// uncomment below and update the code to test {{classname}} | ||
//var instane = new {{moduleName}}.{{classname}}(); | ||
//expect(instance).to.be.a({{moduleName}}.{{classname}}); | ||
}); | ||
|
||
{{#models}} | ||
{{#model}} | ||
{{#vars}} | ||
it('should have the property {{name}} (base name: "{{baseName}}")', function() { | ||
// uncomment below and update the code to test the property {{name}} | ||
//var instane = new {{moduleName}}.{{classname}}(); | ||
//expect(instance).to.be(); | ||
}); | ||
|
||
{{/vars}} | ||
{{/model}} | ||
{{/models}} | ||
}); | ||
|
||
})); |
7 changes: 7 additions & 0 deletions
7
modules/swagger-codegen/src/main/resources/Javascript/travis.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- "6" | ||
- "6.1" | ||
- "5" | ||
- "5.11" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- "6" | ||
- "6.1" | ||
- "5" | ||
- "5.11" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--timeout 10000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.