-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(applications): updating types for application package (#827)
- Loading branch information
Showing
40 changed files
with
1,276 additions
and
346 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"semi": false, | ||
"semi": true, | ||
"singleQuote": true | ||
} |
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,175 @@ | ||
import { Client } from '@vonage/server-client'; | ||
import { ApplicationResponse } from '../../lib'; | ||
|
||
import { BASE_URL, testApplication, capabilitiesToTest } from '../common'; | ||
|
||
const applicationToCreate = JSON.parse(JSON.stringify(testApplication)); | ||
|
||
delete applicationToCreate.id; | ||
delete applicationToCreate.keys?.publicKey; | ||
|
||
const expectedApplication = JSON.parse(JSON.stringify(testApplication)); | ||
|
||
expectedApplication.keys = { | ||
...testApplication.keys, | ||
privateKey: `-----BEGIN PRIVATE KEY-----bar----END PRIVATE KEY-----`, | ||
}; | ||
|
||
export default [ | ||
{ | ||
label: 'create simple application', | ||
requests: [ | ||
[ | ||
`/v2/applications`, | ||
'POST', | ||
Client.transformers.snakeCaseObjectKeys(applicationToCreate, true), | ||
], | ||
], | ||
responses: [ | ||
[ | ||
200, | ||
{ | ||
...Client.transformers.snakeCaseObjectKeys( | ||
{ | ||
...testApplication, | ||
keys: expectedApplication.keys, | ||
}, | ||
true, | ||
), | ||
_links: { | ||
self: { | ||
href: `${BASE_URL}/v2/applications/${testApplication.id}`, | ||
}, | ||
}, | ||
} as ApplicationResponse, | ||
], | ||
], | ||
clientMethod: 'createApplication', | ||
parameters: [applicationToCreate], | ||
generator: false, | ||
error: false, | ||
expected: Client.transformers.snakeCaseObjectKeys( | ||
expectedApplication, | ||
true, | ||
true, | ||
), | ||
}, | ||
{ | ||
label: 'create application with custom key', | ||
requests: [ | ||
[ | ||
`/v2/applications`, | ||
'POST', | ||
Client.transformers.snakeCaseObjectKeys( | ||
{ | ||
...applicationToCreate, | ||
keys: { | ||
public_key: expectedApplication.keys.publicKey, | ||
}, | ||
}, | ||
true, | ||
), | ||
], | ||
], | ||
responses: [ | ||
[ | ||
200, | ||
{ | ||
...Client.transformers.snakeCaseObjectKeys( | ||
{ | ||
...testApplication, | ||
keys: expectedApplication.keys, | ||
}, | ||
true, | ||
), | ||
_links: { | ||
self: { | ||
href: `${BASE_URL}/v2/applications/${testApplication.id}`, | ||
}, | ||
}, | ||
} as ApplicationResponse, | ||
], | ||
], | ||
clientMethod: 'createApplication', | ||
parameters: [ | ||
{ | ||
...applicationToCreate, | ||
keys: { | ||
publicKey: expectedApplication.keys.publicKey, | ||
}, | ||
}, | ||
], | ||
generator: false, | ||
error: false, | ||
expected: Client.transformers.snakeCaseObjectKeys( | ||
expectedApplication, | ||
true, | ||
true, | ||
), | ||
}, | ||
capabilitiesToTest.map(([name, capability]) => ({ | ||
label: `create application with ${name} capability`, | ||
requests: [ | ||
[ | ||
`/v2/applications`, | ||
'POST', | ||
Client.transformers.snakeCaseObjectKeys( | ||
{ | ||
...applicationToCreate, | ||
capabilities: { | ||
[name]: capability, | ||
}, | ||
}, | ||
true, | ||
), | ||
], | ||
], | ||
responses: [ | ||
[ | ||
200, | ||
{ | ||
...Client.transformers.snakeCaseObjectKeys( | ||
{ | ||
...testApplication, | ||
keys: expectedApplication.keys, | ||
capabilities: { | ||
[name]: capability, | ||
}, | ||
}, | ||
true, | ||
), | ||
_links: { | ||
self: { | ||
href: `${BASE_URL}/v2/applications/${testApplication.id}`, | ||
}, | ||
}, | ||
} as ApplicationResponse, | ||
], | ||
], | ||
clientMethod: 'createApplication', | ||
parameters: [ | ||
{ | ||
...applicationToCreate, | ||
capabilities: { | ||
[name]: capability, | ||
}, | ||
}, | ||
], | ||
generator: false, | ||
error: false, | ||
expected: Client.transformers.camelCaseObjectKeys( | ||
Client.transformers.snakeCaseObjectKeys( | ||
{ | ||
...expectedApplication, | ||
capabilities: { | ||
[name]: Client.transformers.snakeCaseObjectKeys(capability, true), | ||
}, | ||
}, | ||
true, | ||
true, | ||
), | ||
true, | ||
true, | ||
), | ||
})), | ||
].flat(); |
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,14 @@ | ||
import { testApplication } from '../common'; | ||
|
||
export default [ | ||
{ | ||
label: 'delete simple application', | ||
requests: [[`/v2/applications/${testApplication.id}`, 'DELETE']], | ||
responses: [[204]], | ||
clientMethod: 'deleteApplication', | ||
parameters: [testApplication.id], | ||
generator: false, | ||
error: false, | ||
expected: undefined, | ||
}, | ||
]; |
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,71 @@ | ||
import { Client } from '@vonage/server-client'; | ||
import { ApplicationResponse } from '../../lib'; | ||
|
||
import { BASE_URL, testApplication, capabilitiesToTest } from '../common'; | ||
|
||
export default [ | ||
{ | ||
label: 'get simple application', | ||
requests: [[`/v2/applications/${testApplication.id}`, 'GET']], | ||
responses: [ | ||
[ | ||
200, | ||
{ | ||
...Client.transformers.snakeCaseObjectKeys(testApplication, true), | ||
_links: { | ||
self: { | ||
href: `${BASE_URL}/v2/applications/${testApplication.id}`, | ||
}, | ||
}, | ||
} as ApplicationResponse, | ||
], | ||
], | ||
clientMethod: 'getApplication', | ||
parameters: [testApplication.id], | ||
generator: false, | ||
error: false, | ||
expected: Client.transformers.snakeCaseObjectKeys( | ||
testApplication, | ||
true, | ||
true, | ||
), | ||
}, | ||
capabilitiesToTest.map(([name, capability]) => ({ | ||
label: `get application with ${name} capability`, | ||
requests: [[`/v2/applications/${testApplication.id}`, 'GET']], | ||
responses: [ | ||
[ | ||
200, | ||
{ | ||
...Client.transformers.snakeCaseObjectKeys(testApplication, true), | ||
capabilities: { | ||
[name]: Client.transformers.snakeCaseObjectKeys(capability, true), | ||
}, | ||
_links: { | ||
self: { | ||
href: `${BASE_URL}/v2/applications/${testApplication.id}`, | ||
}, | ||
}, | ||
} as ApplicationResponse, | ||
], | ||
], | ||
clientMethod: 'getApplication', | ||
parameters: [testApplication.id], | ||
generator: false, | ||
error: false, | ||
expected: Client.transformers.camelCaseObjectKeys( | ||
Client.transformers.snakeCaseObjectKeys( | ||
{ | ||
...testApplication, | ||
capabilities: { | ||
[name]: Client.transformers.snakeCaseObjectKeys(capability, true), | ||
}, | ||
}, | ||
true, | ||
true, | ||
), | ||
true, | ||
true, | ||
), | ||
})), | ||
].flat(); |
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,28 @@ | ||
import appTests from './get'; | ||
import listTests from './list'; | ||
import createTests from './create'; | ||
import updateTests from './update'; | ||
import deleteTests from './delete'; | ||
|
||
export default [ | ||
{ | ||
label: 'Get Application', | ||
tests: appTests, | ||
}, | ||
{ | ||
label: 'List Applications', | ||
tests: listTests, | ||
}, | ||
{ | ||
label: 'Create Application', | ||
tests: createTests, | ||
}, | ||
{ | ||
label: 'Update Application', | ||
tests: updateTests, | ||
}, | ||
{ | ||
label: 'Delete Application', | ||
tests: deleteTests, | ||
}, | ||
]; |
Oops, something went wrong.