-
-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c450461
commit 0b6fd22
Showing
32 changed files
with
175 additions
and
116 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
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 |
---|---|---|
@@ -1,13 +1,17 @@ | ||
module.exports = { | ||
testRegex: '\\.spec\\.(ts|js)$', | ||
testRegex: '.*\\.spec\\.(ts|js)$', | ||
testPathIgnorePatterns: [ | ||
'/node_modules/', | ||
'<rootDir>/dist/', | ||
'<rootDir>/samples/', | ||
], | ||
testEnvironment: 'node', | ||
moduleNameMapper: { | ||
'\\.hbs$': '<rootDir>/src/templates/__mocks__/index.js', | ||
}, | ||
collectCoverageFrom: [ | ||
'src/**/*.ts', | ||
'!src/**/*.d.ts', | ||
'!src/templates/**', | ||
'!**/node_modules/**', | ||
], | ||
}; |
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 |
---|---|---|
@@ -1,31 +1,35 @@ | ||
import * as OpenAPI from './index'; | ||
|
||
describe('index', () => { | ||
it('parses v2 without issues', async () => { | ||
// await OpenAPI.generate({ | ||
// input: './test/mock/v2/spec.json', | ||
// output: './test/result/v2/', | ||
// useOptions: true | ||
// }); | ||
await OpenAPI.generate({ | ||
input: './test/spec/v3.json', | ||
output: './temp/v3/', | ||
write: false, | ||
}); | ||
}); | ||
|
||
it('parses v3 without issues', async () => { | ||
// await OpenAPI.generate({ | ||
// input: './test/mock/v3/spec.json', | ||
// output: './test/result/v3/', | ||
// useOptions: true | ||
// }); | ||
await OpenAPI.generate({ | ||
input: './test/spec/v3.json', | ||
output: './temp/v3/', | ||
write: false, | ||
}); | ||
}); | ||
|
||
it('downloads and parses v2 without issues', async () => { | ||
// await OpenAPI.generate({ | ||
// input: 'https://raw.githubusercontent.com/ferdikoomen/openapi-typescript-codegen/master/test/mock/v2/spec.json', | ||
// output: './test/result/v2-downloaded/' | ||
// }); | ||
await OpenAPI.generate({ | ||
input: 'https://raw.githubusercontent.com/ferdikoomen/openapi-typescript-codegen/master/test/spec/v2.json', | ||
output: './temp/v2-downloaded/', | ||
write: false, | ||
}); | ||
}); | ||
|
||
it('downloads and parses v3 without issues', async () => { | ||
// await OpenAPI.generate({ | ||
// input: 'https://raw.githubusercontent.com/ferdikoomen/openapi-typescript-codegen/master/test/mock/v3/spec.json', | ||
// output: './test/result/v3-downloaded/' | ||
// }); | ||
await OpenAPI.generate({ | ||
input: 'https://raw.githubusercontent.com/ferdikoomen/openapi-typescript-codegen/master/test/spec/v3.json', | ||
output: './temp/v3-downloaded/', | ||
write: false, | ||
}); | ||
}); | ||
}); |
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
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,15 @@ | ||
import * as path from 'path'; | ||
|
||
import { isSubDirectory } from './isSubdirectory'; | ||
|
||
describe('isSubDirectory', () => { | ||
it('should return correct result', () => { | ||
expect(isSubDirectory(path.resolve('/'), path.resolve('/'))).toBeFalsy(); | ||
expect(isSubDirectory(path.resolve('.'), path.resolve('.'))).toBeFalsy(); | ||
expect(isSubDirectory(path.resolve('./project'), path.resolve('./project'))).toBeFalsy(); | ||
expect(isSubDirectory(path.resolve('./project'), path.resolve('../'))).toBeFalsy(); | ||
expect(isSubDirectory(path.resolve('./project'), path.resolve('../../'))).toBeFalsy(); | ||
expect(isSubDirectory(path.resolve('./'), path.resolve('./output'))).toBeTruthy(); | ||
expect(isSubDirectory(path.resolve('./'), path.resolve('../output'))).toBeTruthy(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { relative } from 'path'; | ||
import * as path from 'path'; | ||
|
||
export function isSubDirectory(parent: string, child: string) { | ||
return relative(child, parent).startsWith('..'); | ||
return path.relative(child, parent).startsWith('..'); | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import path from 'path'; | ||
import * as path from 'path'; | ||
|
||
import { exists, readFile } from './fileSystem'; | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import http from 'http'; | ||
import * as http from 'http'; | ||
|
||
/** | ||
* Download the spec file from a HTTP resource | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import https from 'https'; | ||
import * as https from 'https'; | ||
|
||
/** | ||
* Download the spec file from a HTTPS resource | ||
|
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,12 @@ | ||
import * as Handlebars from 'handlebars/runtime'; | ||
|
||
import { registerHandlebarHelpers } from './registerHandlebarHelpers'; | ||
|
||
describe('registerHandlebarHelpers', () => { | ||
it('should register the helpers', () => { | ||
registerHandlebarHelpers(); | ||
const helpers = Object.keys(Handlebars.helpers); | ||
expect(helpers).toContain('equals'); | ||
expect(helpers).toContain('notEquals'); | ||
}); | ||
}); |
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,21 @@ | ||
import { registerHandlebarTemplates } from './registerHandlebarTemplates'; | ||
|
||
describe('registerHandlebarTemplates', () => { | ||
it('should return correct templates', () => { | ||
const templates = registerHandlebarTemplates(); | ||
expect(templates.index).toBeDefined(); | ||
expect(templates.exports.model).toBeDefined(); | ||
expect(templates.exports.schema).toBeDefined(); | ||
expect(templates.exports.service).toBeDefined(); | ||
expect(templates.core.settings).toBeDefined(); | ||
expect(templates.core.apiError).toBeDefined(); | ||
expect(templates.core.getFormData).toBeDefined(); | ||
expect(templates.core.getQueryString).toBeDefined(); | ||
expect(templates.core.isSuccess).toBeDefined(); | ||
expect(templates.core.request).toBeDefined(); | ||
expect(templates.core.requestOptions).toBeDefined(); | ||
expect(templates.core.requestUsingFetch).toBeDefined(); | ||
expect(templates.core.requestUsingXHR).toBeDefined(); | ||
expect(templates.core.result).toBeDefined(); | ||
}); | ||
}); |
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,10 @@ | ||
import { sort } from './sort'; | ||
|
||
describe('sort', () => { | ||
it('should return correct index', () => { | ||
expect(sort('a', 'b')).toEqual(-1); | ||
expect(sort('b', 'a')).toEqual(1); | ||
expect(sort('a', 'a')).toEqual(0); | ||
expect(sort('', '')).toEqual(0); | ||
}); | ||
}); |
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,12 @@ | ||
import { unique } from './unique'; | ||
|
||
describe('unique', () => { | ||
it('should return correct index', () => { | ||
expect(unique('a', 0, ['a', 'b', 'c'])).toBeTruthy(); | ||
expect(unique('a', 1, ['a', 'b', 'c'])).toBeFalsy(); | ||
expect(unique('a', 2, ['a', 'b', 'c'])).toBeFalsy(); | ||
expect(unique('a', 0, ['a', 'b', 'c'])).toBeTruthy(); | ||
expect(unique('a', 1, ['z', 'a', 'b'])).toBeTruthy(); | ||
expect(unique('a', 2, ['y', 'z', 'a'])).toBeTruthy(); | ||
}); | ||
}); |
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.